eclipse / upm

UPM is a high level repository that provides software drivers for a wide variety of commonly used sensors and actuators. These software drivers interact with the underlying hardware platform through calls to MRAA APIs.
MIT License
658 stars 411 forks source link

invalid GPIO pin specified for upboard with ubuntu16.04 and python #685

Open Sterben1111 opened 4 years ago

Sterben1111 commented 4 years ago

when i tried to run a test program in up wiki to test the board, it told me that " ValueError: Invalid GPIO pin specified"

I don't know what happened, so i think i need some help

error:
Traceback (most recent call last):
  File "light.py", line 11, in <module>
    pin = mraa.Gpio(pin_no,owner=False,raw=True)
  File "/usr/lib/python2.7/dist-packages/mraa.py", line 1122, in __init__
    this = _mraa.new_Gpio(pin, owner, raw)
ValueError: Invalid GPIO pin specified

and the code:

#!/usr/bin/python

import sys
import mraa
import time

# Use pin 7 by default
pin_no = 13

# Export the GPIO pin for use
pin = mraa.Gpio(pin_no,owner=False,raw=True)

# Small delay to allow udev rules to execute (necessary only on up)
time.sleep(0.1)

# Configure the pin direction
pin.dir(mraa.DIR_OUT)

# Loop
while True:
    # Turn the LED on and wait for 0.5 seconds
    pin.write(1)
    time.sleep(0.5)
    # Turn the LED off and wait for 0.5 seconds
    pin.write(0)
    time.sleep(0.5)

Besides, there is the GPIO list:

ls /sys/class/gpio/
export       gpiochip228  gpiochip341  unexport
gpiochip225  gpiochip314  gpiochip414

And I also can not export more new pin in the folder, which confused me a lot and i think it may relate to my question.

Thanks!

Propanu commented 4 years ago

Hi @Sterben1111, when using raw=True you need to specify the Linux sysfs number for the pin. Set it to False if you want to use the board pin number. You can also use the short form pin = mraa.Gpio(pin_no).