timeq and uasyncio.* on WiPy 2.0 (or 3.0?)



  • Hello all,

    I'm interested in making use of uasyncio.* in micropython-lib. One of it's most obvious uses would be to consume from mqtt.simple's call to check for new messages. In general I'd like to get away from the concept of using Timer.Alarm's to poll for certain things on my WiPy.

    The very first dependency I ran across that looked incompatible with the WiPy 2.0 and the default ESP32 build was timeq. It's needed by uasyncio.core from micropython-lib.

    From what I can tell in the C source it seems to not be enabled for the ESP32 variant of micropython. Is there some legitimate reason for this or is it arbitrary?

    P.S. I have a WiPy 3.0 on the way if that for any reason would make this more attainable (hardware floating point support?).

    Thanks for any info you can provide!
    Keith



  • @rkeiii Version 1.15.0b1 now contains the utimeq module and a slightly changed utime module, which matches the needs of the uasyncio lib. The only change needed to the lib is swapping the arguments of the single utime.ticks_diff() in usanycio.core.py.



  • @rkeiii Pycom has a section in it's github repository, https://github.com/pycom/pycom-libraries/lib, where a few examples of code for pycom products are located. That could be the right spot.



  • @on4aa This may not apply to your situation but I figured I'd mention it. In my case I only needed the uasyncio.queues which only depended on uasyncio.core for a trivial sleep function. So I just copied/pasted the sleep function from uasyncio.queues from micropython-lib and I was off and running.

    I would also be interested in working on truly porting uasyncio over to the ESP32 boards.

    P.S. Are you aware of anything like micropython-lib specifically for PyCom products ie pycom-micropython-lib (or esp32-micropython-lib?)? I have various pieces of the Pyboard based micropython-lib hacked to work on esp32 and it would be nice to have a place to submit ported code because I can only assume other people are repeating the same exercise.



  • Me too!!! Today I have also been wasting my time with an attempt to get the extremely useful «standard» MicroPython module uasyncio to work on a LoPy.

    Like the other poster, I also got stuck on utimeq not being available in the standard library of the «Pycom» MicroPython variant. (This unfortunate situation reminds me of the many BASIC dialects of times gone by!)

    I am trying to design a medical device around the LoPy. Having out-of-the-box access to an event loop mechanism like the one offered by uasyncio is an absolute must for any serious OEM undertaking.

    Related posts:



  • @rkeiii The file esp32/mpconfigport.h contains the options enabled for that specific port. The list of all possible options that may be supported is in py/mpconfig.h.
    Simply copying a c file into the esp32/mods subdirectory does not change anything. At least, you have to add that file to the list of source file in esp32/Makefile. But taking a file from another port typically does not work. Once you understood the way the C functions work, you may add functionality.
    In this thread thread you find links and help, that either helps to understand existing modules or to build one ones. https://forum.micropython.org/viewtopic.php?f=16&t=2861&p=19206#p19206
    It may not 100% fit to the pycom branch, but the basic principles are the same.



  • @robert-hh Thanks for correcting my misinformation about the WiPy 2.0 lacking hardware floating point support. I'm not sure where I got that idea from but it was leading some confusion for me.

    With regard to trying to build various C components ie timeq. I see a file in this repo at /esp32/mpconfigport.h (please keep in mind I know virtually zero about C programming). This file looks like it could be used to attempt to build various bits of C code dumped in ie the /ext-mods directory. Is this correct? Is there any documentation or forum posts or anything that detail how to go about attempting to build some of the C code from the PyBoard Micropython repo?

    I tried simply copying a C file from the Pyboard micropython repo into the /extmod directory (is there documentation anywhere about the project structure and what exactly is in each of the directories in this project?) and doing a normal build but I didn't see the compiler mention actually compiling it so I figured I'm missing, well, something.



  • @rkeiii Hello, at matters of software, WiPy2 and WiPy 3 do not differ. Both are based on the esp32. The only difference is in available memory. WiPy 2 has floating point support, which you easily tell. It was Wipy 1 which did not support floating point numbers, and the documentation still contains a lot of WiPy 1 wording.

    The asyncio lib was written for the micropython.org branch of the language, and unfortunately they differ. By and by the intention is expressed to harmonize these branches again, but as times goes by and each branch develops, this gets more and more unlikely.


 

Pycom on Twitter