Problems to define a GPIO pin as input in Begalebone black

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
NICOCASAL
 
Posts: 14
Joined: Sun Sep 30, 2018 1:52 pm

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by NICOCASAL »

Thank you

I was able to solve the problem using the sudo python command.

However, I still can not enable the permanent internet connection ( when the BBB boot).
I also need a command that allows me to run several programs (codes) automatically when the BBB boot (turns off and on).

Can you please help me to find the correct commands?

Best regards

Hugo

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

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by drewfustini »

NICOCASAL wrote:Thank you
However, I still can not enable the permanent internet connection ( when the BBB boot).
Are you using Ethernet or WiFi?

To run a command automatically, you can configure systemd to run a service:
systemd: Writing and Enabling a Service

User avatar
NICOCASAL
 
Posts: 14
Joined: Sun Sep 30, 2018 1:52 pm

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by NICOCASAL »

thank very much

I am using the internet sevice through cellular router( Digi WR11).

Now , I have already permanent internet service. The following step is to run the scripts automatically when the BBB reboot or power on.

To test I am using the code to blink USR3 led ( see examples/robot path in the folder cloud9 ).

I used the following commands:

root@beaglebone:/var/lib/cloud9# crontab -e

In nano editor :

@reboot /var/lib/cloud9/examples/ robot /blink.py

But it does not work .

Can you please give me some suggest?

Regards

Hugo

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

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by drewfustini »

This does not look like a valid command:

Code: Select all

@reboot /var/lib/cloud9/examples/ robot /blink.py
It appears that you may have spaces in that path: "/ robot /"

If there are in fact spaces in the directory name, I would suggest renaming it without spaces.

User avatar
NICOCASAL
 
Posts: 14
Joined: Sun Sep 30, 2018 1:52 pm

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by NICOCASAL »

Hello

I already can to run the scripts automatically , but now I have a problem .

When I run any script in cloud9( inside BBB) in automatic mode ( running at startup), ie, at reboot or power on and off the unit and if I include the command line GPIO.setup("Px_xx",GPIO.IN) , the program don't execute. However , when I run the same scripts without this line , it works well.

I tested with several GPIO inputs pins and the same always happens

Also, when I run the same scripts in manual mode in cloud9 , all work well.

How Can I see the errors in the scripts

Do you have some idea what happen?

Bellow , I show one simple script :



import Adafruit_BBIO.GPIO as GPIO
import time


GPIO.setup("P9_16",GPIO.IN) # this line is the problem
GPIO.setup("USR3",GPIO.OUT)

while True:
GPIO.output("USR3",GPIO.HIGH)
time.sleep(2)
GPIO.output("USR3",GPIO.LOW)
time.sleep(2)

Thank you in advance

Hugo

User avatar
NICOCASAL
 
Posts: 14
Joined: Sun Sep 30, 2018 1:52 pm

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by NICOCASAL »

Hello again

I forgot send you the error message.

Bellow can you find it

I tested a bit more and I saw this happen if I configure any GPIO pin as input or output in the same script where USRx pin is used.

Regard

Hugo

Important: use os.getenv(PORT, 8080) as the port and os.getenv(IP, 0.0.0.0) as the host in your scripts!



Traceback (most recent call last):

File "/var/lib/cloud9/Telemetria/alarmaprueba3.py", line 5, in <module>

GPIO.setup("P9_16",GPIO.IN)

ValueError: Set gpio direction failed, missing file or invalid permissions.

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

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by drewfustini »

It is important to see the output of the version script to determine if your BeagleBone is configured correctly.

Please try running this script:

Code: Select all

sudo /opt/scripts/tools/version.sh
and paste the output in your reply.

User avatar
NICOCASAL
 
Posts: 14
Joined: Sun Sep 30, 2018 1:52 pm

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by NICOCASAL »

Thank you

Here the output of the version script.

root@beaglebone:~# sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[73593ebe3b7d3cc381eeb502d45ccb33a6ec5e78]
eeprom:[A335BNLT000C1820BBBG1530]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2018-08-30]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]
kernel:[4.14.67-ti-r73]
nodejs:[v6.14.4]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20180803.0-0rcnee0~stretch+20180804]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[librobotcontrol]:[1.0.2-git20180829.0-0rcnee0~stretch+20180830]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee1~stretch+20180328]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[ 1.099565] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[ 1.111578] gpio-of-helper ocp:cape-universal: ready
END

Regards

Hugo

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

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by drewfustini »

Thanks, I will try to reproduce this issue when running in the Cloud9 IDE on my BeagleBone Black

User avatar
NICOCASAL
 
Posts: 14
Joined: Sun Sep 30, 2018 1:52 pm

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by NICOCASAL »

Hello Drew

Did you have opportunity to revise my problem?

Thanks
Hugo

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

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by drewfustini »

From the console terminal inside Cloud9, please run these commands and paste the output:

Code: Select all

id

grep gpio /etc/group

ls -l /sys/class/gpio/gpio*/value 

User avatar
HUGOCASAL
 
Posts: 1
Joined: Tue Nov 20, 2018 3:25 pm

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by HUGOCASAL »

Hello

This is the information

Regards


debian@beaglebone:/var/lib/cloud9$ id
uid=1000(debian) gid=1000(debian) groups=1000(debian),4(adm),15(kmem),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),100(users),101(systemd-journal),108(i2c),111(bluetooth),112(netdev),115(cloud9ide),992(xenomai),993(weston-launch),994(tisdk),995(spi),996(admin),997(eqep),998(pwm),999(gpio)
debian@beaglebone:/var/lib/cloud9$ grep gpio /etc/group
gpio:x:999:debian
debian@beaglebone:/var/lib/cloud9$ ls -l /sys/class/gpio/gpio*/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio10/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio110/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio111/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio112/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio113/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio114/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio115/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio116/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio117/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio11/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio12/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio13/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio14/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio15/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio20/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio22/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio23/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio26/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio27/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio2/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio30/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio31/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio32/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio33/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio34/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio35/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio36/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio37/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio38/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio39/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio3/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio44/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio45/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio47/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio48/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio49/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio4/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio50/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio51/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio5/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio60/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio61/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio62/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio63/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio65/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio66/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio67/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio68/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio69/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio70/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio71/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio72/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio73/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio74/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio75/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio76/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio77/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio78/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio79/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio7/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio80/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio81/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio86/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio87/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio88/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio89/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio8/value
-rw-rw-r-- 1 root gpio 4096 Dec 31 1999 /sys/class/gpio/gpio9/value
debian@beaglebone:/var/lib/cloud9$

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

Re: Problems to define a GPIO pin as input in Begalebone bl

Post by drewfustini »

Thanks. I am asking Robert C Nelson who creates the BeagleBone Debian images. I think it may be an issue that the Cloud9 IDE user is not in the gpio group. I will followup after I hear back from Robert.

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

Return to “Beagle Bone & Adafruit Beagle Bone products”