I am trying to run a python scrip on Edison-arduino breakout board.
The script is as followed:Header 1
led = mraa.Gpio(9)
It runs successfully. After that, I create a systemd .services file for running it upon system startup. The new file called example.service is under /lib/systemd/system. I also add it to boot-up chain by issuing "systemctl daemon-reload &systemctl enable example".example.service
Description=Daemon to handle my own routine (made by cjia)
Now I meet an issue:
1. Once system is booting from cold off. Service is invoked as expected and script runs well.
2. If I hit reset button on Arduino breakout to reboot system. Service is invoked but reported as failure. I checked log by using "systemctrl status example". It reported python assertion on "led=mraa.Gpio(9)".
Python 2.7.3 (default, Jun 19 2015, 07:08:38)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mraa
Traceback (most recent call last):
File "", line 1, in
NameError: name 'pin' is not defined
The release I used is 2.1. Mraa version is v0.7.2.
So far, it could only be reproduced upon reset.
I also checked sysfs for gpio devices and find some differences.Cold bootreset/reboot
export gpio126 gpio129 gpio131 gpio134 gpiochip232
gpio124 gpio127 gpio13 gpio132 gpio9 gpiochip248
gpio125 gpio128 gpio130 gpio133 gpiochip0 unexport
root@edison:~# ls /sys/class/gpio
export gpio129 gpio183 gpio243 gpio262 gpiochip0
gpio124 gpio130 gpio207 gpio256 gpio263 gpiochip200
gpio125 gpio131 gpio214 gpio257 gpio40 gpiochip216
gpio126 gpio132 gpio215 gpio258 gpio41 gpiochip232
gpio127 gpio133 gpio240 gpio259 gpio43 gpiochip248
gpio128 gpio134 gpio241 gpio261 gpio49 unexport
I can not figure out why this happen. Could you help me?
I noticed the issue is not in fact because of the system service, I noticed that the simple script does not work upon rebooting the board with the reset button. I'm not sure what is wrong but I doubt it is related to Python, it might have to do with mraa.
arfoll, do you have any ideas why this is happening? I tested it on the latest version of mraa 0.8.1.
You're executing this too early, system is very aggressive, you haven't finished booting After=syslog.target, instead of this try Type=idle or just add a sleep 5 && in front of your command. You could also in your script catch the execption and then pause your script for a while and then try again.
I tried to change the service type to idle and found it weird that it still had issues, that's why I tried to test the script and noticed that it failed after rebooting the board. As I mentioned not sure why since it is very simple, and considering that it works perfectly when booting the board from being cold off.
Oh if it's just doing it on cold boot then it's an Edison bug with soft reboot. It's a known one, the gpio expander controlling the muxes doesn't get restarted correctly. Might be fixed in latest image, not sure. Always do a cold reboot.