Threading or RTOS in uPython

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
adam77
Posts: 1
Joined: Fri Apr 05, 2019 11:54 am

Threading or RTOS in uPython

Post by adam77 » Fri Apr 05, 2019 11:58 am

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)
[url=https://solitaire.onl/][color=#333333]https://solitaire.onl/[/color][/url] [url=https://9apps.ooo/][color=#333333]9apps.ooo/[/color][/url] [url=https://bluestacks.vip/][color=#333333]https://bluestacks.vip/[/color][/url]

Thanks for the help!
Last edited by adam77 on Sat Apr 06, 2019 7:29 pm, edited 1 time in total.

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

Re: Threading or RTOS in uPython

Post by pythoncoder » Sat Apr 06, 2019 8:05 am

I recommend using uasyncio unless you have a very good reason for using threading. This repo contains information on uasyncio including installation details and a tutorial on its use (and why it's usually better than threading).

This repo contains alternative ways to install libraries (follow the link).
Peter Hinch

smithclarkson01
Posts: 3
Joined: Mon Sep 09, 2019 5:20 am

Re: Threading or RTOS in uPython

Post by smithclarkson01 » Mon Sep 09, 2019 5:30 am

[quote=pythoncoder post_id=35552 time=1554537911 user_id=265]
I recommend using [b]uasyncio[/b] unless you have a very good reason for using threading. [url=https://github.com/peterhinch/micropython-async.git]This repo[/url] contains information on [b]uasyncio[/b] including installation details and a tutorial on its use (and why it's usually better than threading).

[url=https://github.com/peterhinch/micropython-samples]This repo[/url] contains alternative ways to install libraries (follow the link).
[/quote]


make sense.!

Post Reply