bub Posted August 23, 2017 Share Posted August 23, 2017 Hi to all, I'm newer so I hope your comprehension. my board Orange Pi Zero 512 my python script for turno on/off rele board works well, but only if call it directly form terminal. If call it from cgi, crontab don't controll the rele board: gpio.init() semms crashed but the script complete its work. What I'm wrong? Thanks ---- from pyA20.gpio import gpio from pyA20.gpio import port gpioinit = gpio.init() gpioscfg = gpio.setcfg(port.PA19, gpio.OUTPUT) gpio.output(port.PA19, gpio.LOW) print "ok" ----- Link to comment Share on other sites More sharing options...
StuxNet Posted August 23, 2017 Share Posted August 23, 2017 Well if it 'seems' to crash I'm going to go ahead and assume it doesn't. If it does, provide log or error code. I'm going to assume it doesn't though if it works from command line. I'm not sure what you mean by CGI and I'm also going to assume that you're running the entire script from command line and not each line of code from the python shell/prompt. (I make this distinction because of personal experience) That being said, what command are you calling with crontab? Don't know why it would make a difference but seems worth mentioning: gpioinit variable is redundant since you aren't calling it later on. Try just gpio.init(). Same for setcfg(). So like this... ---- from pyA20.gpio import gpio from pyA20.gpio import port gpio.init() gpio.setcfg(port.PA19, gpio.OUTPUT) gpio.output(port.PA19, gpio.LOW) print "ok" ----- Link to comment Share on other sites More sharing options...
bub Posted August 23, 2017 Author Share Posted August 23, 2017 right! Thanks for the answer yes, I'm running the script from command line and not each line of code... Perhaps I've resolved: was only a problem of privilege, I've put "sudo user nopassword" on visudo and now gpio.init() don't stop working Thanks Link to comment Share on other sites More sharing options...
StuxNet Posted August 23, 2017 Share Posted August 23, 2017 Meant to ask that along with the crontab question. Glad you solved it. Link to comment Share on other sites More sharing options...
bub Posted August 23, 2017 Author Share Posted August 23, 2017 nothing wrong with crontab ;-) Link to comment Share on other sites More sharing options...
Recommended Posts