uasyncio for unix port
-
- Posts: 1
- Joined: Thu Jun 04, 2020 12:28 am
uasyncio for unix port
Apologies if this is answered elsewhere - couldn't find anything.
I'd like to test programs to be run on MCUs by first running them on the UNIX port. This sometimes breaks down, e.g. in the case of uasyncio:
It's present on the esp32 platform, but not on unix (and neither is the asyncio library).
so 1. Is there a decent way to use asyncio on the unix micropython port right now ?
2. if not, would it be good to add it (or asyncio) ? If so, is there a tutorial on how to port packages that I can follow and contribute (not promising, but having a tutorial makes it more likely I can do it)
3) Am I holding it wrong (e.g., should I test against regular python on unix/mac instead) ?
I'd like to test programs to be run on MCUs by first running them on the UNIX port. This sometimes breaks down, e.g. in the case of uasyncio:
It's present on the esp32 platform, but not on unix (and neither is the asyncio library).
so 1. Is there a decent way to use asyncio on the unix micropython port right now ?
2. if not, would it be good to add it (or asyncio) ? If so, is there a tutorial on how to port packages that I can follow and contribute (not promising, but having a tutorial makes it more likely I can do it)
3) Am I holding it wrong (e.g., should I test against regular python on unix/mac instead) ?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: uasyncio for unix port
It is possible to install uasyncio on Unix using upip. However that will install uasyncio V2, whereas firmware daily builds have uasyncio V3 pre-installed. V3 is at an advanced stage of development. I believe that Unix support is intended but not yet deployed.
You will find a lot of information on uasyncio here including a V3 tutorial and a porting guide,
In summary many applications can be tested under V2 and will run under V3 but certain features (e.g. task cancellation) have changed for compatibility with CPython asyncio.
There is no realistic prospect of running the actual asyncio library on a microcontroller. Your other option is of course to test under CPython 3.8+ and asyncio but as uasyncio V3 is a subset there is a good deal of scope for error. My approach is to develop on a Pyboard.
You will find a lot of information on uasyncio here including a V3 tutorial and a porting guide,
In summary many applications can be tested under V2 and will run under V3 but certain features (e.g. task cancellation) have changed for compatibility with CPython asyncio.
There is no realistic prospect of running the actual asyncio library on a microcontroller. Your other option is of course to test under CPython 3.8+ and asyncio but as uasyncio V3 is a subset there is a good deal of scope for error. My approach is to develop on a Pyboard.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: uasyncio for unix port
you can just copy the extmod/uasyncio directory into the module directory of the unix port. It worked last time I checked.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: uasyncio for unix port
Thanks for that. On a very quick test that does seem to work, with no need to recompile.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 7
- Joined: Mon Oct 26, 2020 6:26 pm
Re: uasyncio for unix port
where is this "unix/modules" location you are referring to?
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: uasyncio for unix port
~/.micropython/lib
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
-
- Posts: 7
- Joined: Mon Oct 26, 2020 6:26 pm
Re: uasyncio for unix port
Hi,
Thanks!
It is now there but I don't know how - was it from "import upip", import upip, upip.install('micropython-uasyncio')?
Now how do I get uasyncio to be in the build? I want to add it to STM32 build and any subsequent builds of micropython.
Thanks very much!
Thanks!
It is now there but I don't know how - was it from "import upip", import upip, upip.install('micropython-uasyncio')?
Now how do I get uasyncio to be in the build? I want to add it to STM32 build and any subsequent builds of micropython.
Thanks very much!
-
- Posts: 7
- Joined: Mon Oct 26, 2020 6:26 pm
Re: uasyncio for unix port
Hi,
Where is " into the module directory of the unix port?"
Will that give me a clue as to where I should put the uasyncio code to be included in a build for a STM32 device?
Thanks much!
Where is " into the module directory of the unix port?"
Will that give me a clue as to where I should put the uasyncio code to be included in a build for a STM32 device?
Thanks much!
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: uasyncio for unix port
This has nothing to do with the STM32 build. This thread is only about the unix port. You can check about the STM build in a different thread (or start a new one if you can't find one). It's probably handled by board definitions.
For the unix port (sadly) you still have to use the dev build to have uasyncio included automatically. You have to use "make VARIANT=dev" in ~/micropython/ports/unix and then use ./micropython-dev
For the unix port (sadly) you still have to use the dev build to have uasyncio included automatically. You have to use "make VARIANT=dev" in ~/micropython/ports/unix and then use ./micropython-dev
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode