I tried a classical pms "main" wich contain the pmeregister.callback() command that is on your github'srepository:
Code: Select all
import machine
# import pms5003
import uasyncio as asyncio
#from . import pms5003
from pms.pms5003 import PMS5003
import pms.pms5003
_DEFAULT_MS = 20
class Lock:
def __init__(self):
self._locked = False
async def __aenter__(self):
while True:
if self._locked:
await asyncio.sleep_ms(_DEFAULT_MS)
else:
self._locked = True
break
async def __aexit__(self, *args):
self._locked = False
await asyncio.sleep_ms(_DEFAULT_MS)
def locked(self):
return self._locked
def release(self):
self._locked = False
lock = Lock()
uart = machine.UART(4, baudrate=9600)
pm = PMS5003(uart, lock)
pm.registerCallback(pm.print)
loop=asyncio.get_event_loop()
loop.run_forever()
And it works fine! Everything. That's perfect.
So, for sum up, I have had just to change the flush command in the module and import the module like in my example, and pms5003 works on pyboard too.
I will try your other file and post if necessary.
All the best.