uasyncio in MicroPython

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
bitrat
Posts: 41
Joined: Fri Jul 26, 2019 4:13 am

uasyncio in MicroPython

Post by bitrat » Sun Jul 28, 2019 9:57 pm

Hi,

I've inherited a project based on ESP32 and MicroPython.

Some components already in production use threads, but are scheduled for a rewrite.

The component I'm working on now has been prototyped using MicroPython (not Pycopy) and uasyncio/picoweb.

I won't be keeping the web server but do need a TCP server, as well as other I/O.

According to https://pypi.org/project/micropython-uasyncio/ uasyncio "is intended to be used with" Pycopy. How stable is it on MicroPython trunk? And what are the differences with and future plans for Pycopy? Is it pure luck that the uasync/picoweb code is working now on MicroPython trunk, or can I avoid the unsupported features?

My other question is about the dual core ESP32. As I understand it, by default (on arduino style SBC's at least), one core is dedicated to radio services and one to the interpreter. Do MicroPython threads on ESP32 ever provide processing on both cores? Ie, do threads provide any performance advantage to compensate for the extra memory use, etc?

I would prefer coroutines to threads. I've used C Protothreads in the past (albeit where threading was not an option) and I think they are a great option for concurrency on uC's.

Thanks!

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio in MicroPython

Post by pythoncoder » Mon Jul 29, 2019 12:27 pm

Official MicroPython supports uasyncio V2.0. More recent versions of uasyncio require Pycopy. Firmware for some devices has uasyncio pre-installed. Otherwise if you run official MicroPython V1.11 or later, you can install uasyncio V2.0 on web connected devices with

Code: Select all

import upip
upip.install('micropython-uasyncio')
Source for the official library (including uasyncio V2.0) is here.

Re Picoweb I haven't tested the very latest version but I have had no problems running it with official firmware. I'd expect the latest version to work.

There is an unofficial fork of uasyncio compatible with the official firmware which fixes some of the issues with V2.0 here.
Peter Hinch
Index to my micropython libraries.

bitrat
Posts: 41
Joined: Fri Jul 26, 2019 4:13 am

Re: uasyncio in MicroPython

Post by bitrat » Sun Sep 01, 2019 2:51 am

Thanks :-)

Post Reply