Hello,
I am new to micropython, having just loaded it to my STM32F4 Discovery board yesterday. I have been really enjoying using it though, so kudos to all of the community members that have made it as good as it is today.
My current setup for my project is using the STM32 HAL libraries and FreeRTOS to do everything I need - including PWM, periodically reading sensors, serial communication, and Ethernet connection through a SPI adapter. However, with some new team members coming in, we are hoping to make the system more accessible and easy to learn for them by using a language they already know. Up to this point, I think we can do almost everything in micropython that we are currently doing, but I am concerned with the threading part of it. While I found some resources for threading on other boards, including the _thread and uasyncio modules, as well as zephyr RTOS, I haven't found the way to either include these in my project or use them. Running help('modules') doesn't list either _thread or uasyncio in the collection of available modules, and cd into /ports/zephyr and running 'make BOARD=STM32F4DISC' ran into many makefile errors.
So, what are my options here? Do I need to build or install these libraries? (is there a micropip?) Can I continue to use FreeRTOS for threading in my project? (note: I saw some threads on here for 'embedding' micropython as a FreeRTOS task, but I don't want to do that, I want full a uPython coding experience with threading support)
Thanks for the help!
gw
Threading or RTOS in uPython
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Threading or RTOS in uPython
I recommend uasyncio unless you really need threading. Reasons why, and a general tutorial on its installation and use, may be found in this repository.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Threading or RTOS in uPython
Thanks for the suggestion. What is the difference between uasyncio and threading? Is uasyncio non-preemptive? If that's the case, it will probably work fine for my usage.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Threading or RTOS in uPython
uasyncio is cooperative (non-preemptive). I'd recommend reading about asyncio in python first for a general understanding. But you can of course directly look at the tutorial from pythoncoder.
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: Threading or RTOS in uPython
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.