Adafruit_BBIO.GPIO troubles with systemd service

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ManMan88
 
Posts: 1
Joined: Wed Sep 04, 2019 6:53 am

Adafruit_BBIO.GPIO troubles with systemd service

Post by ManMan88 »

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

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

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

[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!

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: Adafruit_BBIO.GPIO troubles with systemd service

Post by drewfustini »

I think this could be related to not having the correct udev rules on
the Ubuntu image you are using.

I'll check with Robert Nelson who I believe produces the Ubuntu image.
He also does the official BeagleBoard.org Debian images and kernel
builds.

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”