led blink task => await asyncio.sleep(1)
battery task => await asyncio.sleep(2)
system task 1 => await asyncio.sleep(1)
system task 2 => await asyncio.sleep(1)
can bus task => can.any(), can.recv()
light sensor task => await asyncio.sleep(2)
webserver task => asyncio.start_server()
touch screen poll task => await asyncio.sleep(0.05)
These tasks are all in the form of:
Code: Select all
async def task(self):
while(True)
...
await asyncio.sleep(x secs)
and they are created using uasyncio.create_task(self.task()) in a function called start().
Further i have two CAN devices connected to the pyboard which each of them sends a heartbeat message every 200 msec. I have checked with a Kvaser that they send the heartbeat.
When only the can bus task is enabled, the received CAN heartbeats are around 200 msec but when i enable all tasks (especially the touch screen poll task) it seems micropython gets very busy and the time between CAN heartbeats go up to 400/500 and sometimes even 800 msecs.
How can i speed up tasks or even prioritise some tasks? Is it possible to have an insight in the performance of micropython as the async tasks are concerned? Or do i have to implement the CAN task in a different way?