Skip to content

Digital IO Error with Orange Pi Zero #924

Open
@wn2try

Description

Board Name

Orange Pi Zero

Steps

run testGpio.py for gpio testing:

import board
import digitalio

print("Hello blinka!")

# Try to create a Digital input
pin = digitalio.DigitalInOut(board.PA13)

print("Digital IO ok!")

Description

(serial-env) nz@orangepizero:~/mihome$ python testGpio.py
Hello blinka!
Traceback (most recent call last):
  File "/home/nz/mihome/testGpio.py", line 7, in <module>
    pin = digitalio.DigitalInOut(board.PA13)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nz/serial-env/lib/python3.11/site-packages/digitalio.py", line 197, in __init__
    self.direction = Direction.INPUT
    ^^^^^^^^^^^^^^
  File "/home/nz/serial-env/lib/python3.11/site-packages/digitalio.py", line 227, in direction
    self._pin.init(mode=Pin.IN)
  File "/home/nz/serial-env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod/libgpiod_pin_2_x.py", line 53, in init
    config={int(self._num): None},
                ^^^^^^^^^
AttributeError: 'Pin' object has no attribute '_num'

Additional information

looks like the issue is related to the following code in libgpiod_pin_2_x.py.
somehow "_num" is not initialized here.

    def __init__(self, pin_id):
        self.id = pin_id
        chip_id = 0
        if isinstance(pin_id, tuple):
            chip_id, self._num = pin_id

manually assign pin_id to _num can fix the issue.

    def __init__(self, pin_id):
        self.id = pin_id
        chip_id = 0
        self._num = pin_id
        if isinstance(pin_id, tuple):
            chip_id, self._num = pin_id

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions