armbian in orange Pi creates script process in rc-local.service but don't executes correctly


Go to solution Solved by andreygoncalves,

Recommended Posts

  • Solution

Hello guys.

Could you help me resolv a problem with orange pi (armbian)?

The problem is the following:
I created a small script in Python that read a I/O of orange Pi, that is read the state of a button(switch). If I execute it on terminal It works fine... But my problem is when I put in inicialization of SO(/lib/systemd/system/rc-local.service ), the linux created a process correctly but when a press the button not happen anything.

 

root@orangepizero:~# ps -aux|grep press
root      1306 83.7  1.9  11268  4852 ?        Rs   18:54   0:38 /usr/bin/python /usr/local/sbin/press_button.py

 

SO of Orange Pi Zero:
Linux orangepizero 5.10.21-sunxi #21.02.3 SMP Mon Mar 8 00:28:04 UTC 2021 armv7l GNU/Linux

 

Obs: I tried put the script in rc.local, used crontab too, put in init.d.... but always the same problem, the linux created the process but dont happen anything when I pressed the button... But if I execute on bash the script It read the button correctly.

 

Script python:


 

import os

import sys

from pyA20.gpio import gpio

from pyA20.gpio import port

from time import sleep
#initialize the linphonecsh
os.system("linphonecsh init")

os.system("linphonecsh register --username 8000 --host 10.100.14.210 --password 8000")
os.system("linphonecsh soundcard playback 0")
os.system("linphonecsh soundcard capture 0")
os.system("linphonecsh soundcard ring 0")

#initialize the gpio module / initialise le GPIO

gpio.init()

button = port.PA12

#setup the port
gpio.setcfg(button, gpio.INPUT)

 

while True:

if gpio.input(button)==0:

sleep(1)
print("button pressed")                                                                                                                                                                                                                                                                                                                                                                                                  os.system("./test_autodial.sh")

 

I'm already suspecting that it's a problem with this OS version.

Hope someone can help me.

Thank you very much.

 

Link to post
Share on other sites
Armbian is a community driven open source project. Do you like to contribute your code?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...