pimoroni / pms5003-python

Python library for the PMS5003 particulate sensor
MIT License
51 stars 19 forks source link

Issue with gpiodevice #21

Open tijmenvandenbrink opened 1 year ago

tijmenvandenbrink commented 1 year ago

Hi,

I'm getting the following error after upgrading pms5003 from 0.0.5 to 1.0.0. I'm running on:

Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian

I get the following error:

Press Ctrl+C to exit!

StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tijmen/projects/enviroplus_exporter/enviroplus_exporter.py", line 52, in <module>
    pms5003 = PMS5003()
  File "/home/tijmen/projects/enviroplus_exporter/.env/lib/python3.9/site-packages/pms5003/__init__.py", line 109, in __init__
    self._pin_enable, self._pin_reset = gpiodevice.get_pins_for_platform(PLATFORMS)
  File "/home/tijmen/projects/enviroplus_exporter/.env/lib/python3.9/site-packages/gpiodevice/__init__.py", line 153, in get_pins_for_platform
    result.append(get_pin(pin, user_label, settings))
  File "/home/tijmen/projects/enviroplus_exporter/.env/lib/python3.9/site-packages/gpiodevice/__init__.py", line 138, in get_pin
    chip = find_chip_by_pins(pin)
  File "/home/tijmen/projects/enviroplus_exporter/.env/lib/python3.9/site-packages/gpiodevice/errors.py", line 45, in wrapper
    errors.append(next(i))
SystemError: <built-in method close of gpiod._ext.Chip object at 0x7fb1f3a850> returned a result with an error set

Any idea how to resolve this?

Gadgetoid commented 7 months ago

It might be worth updating this library and trying again. I've been busy changing/breaking things.

Use the unstable install from within your virtual environment-

git clone https://github.com/pimoroni/pms5003-python/
cd pms5003-python
pip install .

I ran into this same error just yesterday and I can't quite recall why. I think I was calling 'Chip.request_lines' incorrectly, but the library should not do this.