Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digital IO Error with Orange Pi Zero #924

Open
wn2try opened this issue Jan 7, 2025 · 2 comments
Open

Digital IO Error with Orange Pi Zero #924

wn2try opened this issue Jan 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@wn2try
Copy link

wn2try commented Jan 7, 2025

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
@wn2try wn2try added the bug Something isn't working label Jan 7, 2025
@wn2try
Copy link
Author

wn2try commented Jan 7, 2025

(serial-env) nz@orangepizero:~/mihome$ python testGpio.py
Hello blinka!
> /home/nz/serial-env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod/libgpiod_pin_2_x.py(52)init()
-> self._line_request = self._chip.request_lines(
(Pdb) s
> /home/nz/serial-env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod/libgpiod_pin_2_x.py(53)init()
-> config={int(self._num): None},
(Pdb) a
self = 13
mode = 0
pull = None
(Pdb) p _num
*** NameError: name '_num' is not defined
(Pdb) s
AttributeError: 'Pin' object has no attribute '_num'

@wn2try
Copy link
Author

wn2try commented Jan 7, 2025

(serial-env) nz@orangepizero:~$ uname -a
Linux orangepizero 6.6.62-current-sunxi #1 SMP Sun Nov 17 14:08:59 UTC 2024 armv7l GNU/Linux
(serial-env) nz@orangepizero:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Armbian 24.11.1 bookworm
Release:	12
Codename:	bookworm
(serial-env) nz@orangepizero:~$ pip show gpiod Adafruit-Blinka
Name: gpiod
Version: 2.2.3
Summary: Python bindings for libgpiod
Home-page: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
Author: Bartosz Golaszewski
Author-email: [email protected]
License: LGPLv2.1
Location: /home/nz/serial-env/lib/python3.11/site-packages
Requires: 
Required-by: 
---
Name: Adafruit-Blinka
Version: 8.50.0
Summary: CircuitPython APIs for non-CircuitPython versions of Python such as CPython on Linux and MicroPython.
Home-page: https://github.com/adafruit/Adafruit_Blinka
Author: Adafruit Industries
Author-email: [email protected]
License: MIT
Location: /home/nz/serial-env/lib/python3.11/site-packages
Requires: adafruit-circuitpython-typing, Adafruit-PlatformDetect, Adafruit-PureIO, binho-host-adapter, pyftdi, sysv-ipc
Required-by: adafruit-circuitpython-busdevice, adafruit-circuitpython-connectionmanager, adafruit-circuitpython-max31865, adafruit-circuitpython-requests, adafruit-circuitpython-typing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant