asyncio CircuitPython support for RP2040 or Metro M7?

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dcuccia
 
Posts: 28
Joined: Fri Jan 25, 2013 9:13 pm

asyncio CircuitPython support for RP2040 or Metro M7?

Post by dcuccia »

Hi,

I'm struggling to get some sample code working with asyncio in CircuitPython for either my QT Py RP2040 or Metro M7. I've tried CP 7.3.3 and 8.1.0. My hope is to establish robust serial data communication with an outside device over UART or Serial.

After adding the asyncio library to the board, the call

Code: Select all

import asyncio
will crash with the following message:
code.py output:
Traceback (most recent call last):
File "code.py", line 1, in <module>
File "asyncio/__init__.py", line 14, in <module>
File "asyncio/core.py", line 18, in <module>
ImportError: no module named 'adafruit_ticks'
If I look at the requirements folder, the library adafruit_ticks seems to depend on Blinka. But I'm trying to run on-device with CircuitPython, and I am confused. Do I need to install Blinka on the micro? (Thought that was for the PC.) The closest thing I can find for help so far is this tutorial on how to run CircuitPython libraries on MicroPython.

This tutorial seems to imply that asyncio should work out of the box on CircuitPython. What am I doing wrong or incompletely?

Thanks!
David

User avatar
danhalbert
 
Posts: 4688
Joined: Tue Aug 08, 2017 12:37 pm

Re: asyncio CircuitPython support for RP2040 or Metro M7?

Post by danhalbert »

Just copy the adafruit_ticks library to the lib directory in addition. You can get it from the library bundle. If you use circup (https://learn.adafruit.com/keep-your-ci ... ith-circup), it should install adafruit_ticks automatically as a prerequisite when you install asyncio.

See https://learn.adafruit.com/cooperative- ... ry-3106577, which mentions the adafruit_ticks prerequisite.

requirements.txt includes requirements for running under blinka. You can ignore the blinka requirement, but the other requirements are needed.

User avatar
dcuccia
 
Posts: 28
Joined: Fri Jan 25, 2013 9:13 pm

Re: asyncio CircuitPython support for RP2040 or Metro M7?

Post by dcuccia »

danhalbert wrote: Thu Jun 08, 2023 9:44 am If you use circup...it should install adafruit_ticks automatically as a prerequisite when you install asyncio.
requirements.txt includes requirements for running under blinka.
This worked, thank you! My .zip may have not fully extracted, because I'd had trouble finding adafruit_ticks.mpy. circup is fantastic - it's great to see productivity tools like package management come to CircuitPython!
danhalbert wrote: Thu Jun 08, 2023 9:44 am You can ignore the blinka requirement, but the other requirements are needed.
Ah I see - this was tripping me up.

All set, thanks again!

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”