0

Adafruit_BBIO.GPIO troubles with systemd service
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit_BBIO.GPIO troubles with systemd service

by ManMan88 on Wed Sep 04, 2019 7:09 am

Hi,

I'm using Beaglebone Black c, with Ubuntu 18.04.3 LTS running on a 16gb sd card.

I have a python script which uses the Adafruit_BBIO.GPIO module.
This script runs just fine when it is launched manually.

I want this script to run automatically when BBB boots.
So I created a systemd service for that.
The service runs the script, however, it encounters permission errors:

Code: Select all | TOGGLE FULL SIZE
Sep 04 10:40:34 arm python[2506]: Adafruit_BBIO: gpio_export: 66 couldn't write "/sys/class/gpio/export": 1-Operation not permitted
Sep 04 10:40:34 arm python[2506]: Adafruit_BBIO: gpio_set_direction(): 66 couldn't open '/sys/class/gpio/gpio66/direction': 2-No such file or directory


These errors are the result of calling the command:
Code: Select all | TOGGLE FULL SIZE
GPIO.setup("P8_7", GPIO.OUT)


I tried so many things to fix it with no success.
Mainly, I tried to change the /sys/class/gpio/export (and others) permission with chmod or chgrp - nothing worked.

This is my service:
Code: Select all | TOGGLE FULL SIZE
[Unit]
Description="bringup beaglebone_upstart"
After=network.target

[Service]
Type=simple
ExecStart=/usr/sbin/beaglebone_upstart-start
WorkingDirectory=/home/ubuntu

[Install]
WantedBy=multi-user.target


The /usr/sbin/beaglebone_upstart-start ultimately launches a ROS launch file which runs a python script (ROS node) which uses the Adafruit_BBIO.GPIO module.
Again - this works fine when launched manually with roslaunch... or with python <script.py>.

Does anyone has an idea how to solve it?
Thank you!

ManMan88
 
Posts: 1
Joined: Wed Sep 04, 2019 6:53 am

Please be positive and constructive with your questions and comments.