Open clach04 opened 1 year ago
to make python version portable want to move to gpiod, but there are MANY python libs.
They both have different APIs.
Others;
problem with current ones tried is conflict with SPI pin:
(py3venv) pi@pizero:~/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python $ cat cs_issue.py
import gpiod # expected to be sudo apt install python3-libgpiod # https://www.acmesystems.it/libgpiod#:~:text=Manage%20GPIO%20lines%20in%20Python3%20and%20C%20with,calls%20and%20data%20structures%20behind%20a%20straightforward%20API. print(dir(gpiod)) print(gpiod.__file__) print(gpiod.version_string()) CS_PIN = 8 chip = gpiod.Chip('gpiochip0') """ $ gpioinfo |grep 8 line 8: unnamed "spi0 CS0" output active-low [used] """ _CS_PIN = chip.get_line(CS_PIN) _CS_PIN.request(consumer=__file__, type=gpiod.LINE_REQ_DIR_OUT)
(py3venv) pi@pizero:~/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python $ cat alt_cs_issue.py
import gpiod # expected to be https://github.com/hhk7734/python3-gpiod print(dir(gpiod)) print(gpiod.__file__) CS_PIN = 8 chip = gpiod.chip('gpiochip0') """ $ gpioinfo |grep 8 line 8: unnamed "spi0 CS0" output active-low [used] """ _CS_PIN = chip.get_line(CS_PIN) config = gpiod.line_request() config.consumer = __file__ config.request_type = gpiod.line_request.DIRECTION_OUTPUT _CS_PIN.request(config=config)
errors:
(py3venv) pi@pizero:~/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python $ python alt_cs_issue.py ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'chip', 'chip_iter', 'find_line', 'kernel', 'libgpiod', 'libgpiodcxx', 'line', 'line_bulk', 'line_event', 'line_iter', 'line_request', 'make_chip_iter'] /home/pi/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python/py3venv/lib/python3.7/site-packages/gpiod/__init__.py Traceback (most recent call last): File "alt_cs_issue.py", line 17, in <module> _CS_PIN.request(config=config) File "/home/pi/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python/py3venv/lib/python3.7/site-packages/gpiod/libgpiodcxx/__init__.py", line 572, in request rv = libgpiod.gpiod_line_request(_m_line, conf, default_val) File "/home/pi/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python/py3venv/lib/python3.7/site-packages/gpiod/libgpiod/__init__.py", line 499, in gpiod_line_request return gpiod_line_request_bulk(bulk, config, [default_val]) File "/home/pi/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python/py3venv/lib/python3.7/site-packages/gpiod/libgpiod/__init__.py", line 542, in gpiod_line_request_bulk return _line_request_values(bulk, config, default_vals) File "/home/pi/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python/py3venv/lib/python3.7/site-packages/gpiod/libgpiod/__init__.py", line 403, in _line_request_values status = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, req) OSError: [Errno 16] Device or resource busy pi@pizero:~/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python $ python3 cs_issue.py ['Chip', 'ChipIter', 'LINE_REQ_DIR_AS_IS', 'LINE_REQ_DIR_IN', 'LINE_REQ_DIR_OUT', 'LINE_REQ_EV_BOTH_EDGES', 'LINE_REQ_EV_FALLING_EDGE', 'LINE_REQ_EV_RISING_EDGE', 'LINE_REQ_FLAG_ACTIVE_LOW', 'LINE_REQ_FLAG_OPEN_DRAIN', 'LINE_REQ_FLAG_OPEN_SOURCE', 'Line', 'LineBulk', 'LineEvent', 'LineIter', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'find_line', 'version_string'] /usr/lib/python3/dist-packages/gpiod.cpython-37m-arm-linux-gnueabihf.so 1.2 Traceback (most recent call last): File "cs_issue.py", line 15, in <module> _CS_PIN.request(consumer=__file__, type=gpiod.LINE_REQ_DIR_OUT) OSError: [Errno 16] Device or resource busy
to make python version portable want to move to gpiod, but there are MANY python libs.
They both have different APIs.
Others;
problem with current ones tried is conflict with SPI pin:
(py3venv) pi@pizero:~/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python $ cat cs_issue.py
(py3venv) pi@pizero:~/c/eink_ssd1619_er-epm042-1/ER-EPM042-1_Raspberry_Pi/ER-EPM042A1-1R/python $ cat alt_cs_issue.py
errors: