pms5003-python icon indicating copy to clipboard operation
pms5003-python copied to clipboard

Issue with gpiodevice

Open tijmenvandenbrink opened this issue 1 year ago • 2 comments
trafficstars

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?

tijmenvandenbrink avatar Nov 23 '23 21:11 tijmenvandenbrink

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.

Gadgetoid avatar Apr 24 '24 11:04 Gadgetoid

I have the same issue on a rpi5:

(pimoroni)  steve@raspberrypi  ~/enviroplus-python/examples   main  python particulates.py
2025-01-25 15:42:37.382 INFO     particulates.py - Print readings from the PMS5003 particulate sensor.

Press Ctrl+C to exit!


Traceback (most recent call last):
  File "/home/steve/enviroplus-python/examples/particulates.py", line 25, in <module>
    readings = pms5003.read()
               ^^^^^^^^^^^^^^
  File "/home/steve/.virtualenvs/pimoroni/lib/python3.11/site-packages/pms5003/__init__.py", line 136, in read
    raise SerialTimeoutError("PMS5003 Read Timeout: Failed to read start of frame byte")
pms5003.SerialTimeoutError: PMS5003 Read Timeout: Failed to read start of frame byte

I will try and debug more later.

SteveClement avatar Jan 25 '25 14:01 SteveClement