Workers-Framework: A simpler way to MultiTask in MicroPython

Автор: literator от 20-12-2022, 03:49, Коментариев: 0

Категория: КНИГИ » ПРОГРАММИРОВАНИЕ

Workers-Framework: A simpler way to MultiTask in MicroPythonНазвание: Workers-Framework: A simpler way to MultiTask in MicroPython
Автор: Sharil Tumin
Издательство: Leanpub
Год: 2022-12-04
Страниц: 257
Язык: английский
Формат: pdf (true)
Размер: 10.2 MB

Multitasking with Micropython. Cooperative Scheduling.

In your hands is a book titled, Workers-Framework: A simpler way to MultiTask in MicroPython. I discovered an easier way to multitask on microcontrollers by using the high-level language MicroPython. Yes, really. The concept is to run all of the tasks defned in a program on multiple workers at the same time. It’s less complicated than using _thread or asyncio.

The Worker module is so simple that calling it a framework seems a little pretentious. A framework, on the other hand, is a set of data and program structure in which tasks are performed and successfully completed. A framework typically compels developers to solve specific problems in a specific way. A framework, in a sense, creates a mindset for the programming problems at hand and how to solve them.

If you’re curious, keep reading. I assure you that it will be worthwhile. Multitasking is the process of performing multiple tasks at the same time while sharing a single resource, in this case, the CPU. Microprocessor edge programming is inherently event-driven, IO-bound multitasking. It is more difcult because of limited computing resources. So you’ve learned about MicroPython1. That’s fantastic. I’m glad. I assumed you were familiar with MicroPython programming and its various ports and libraries.

As you may be aware, MicroPython is not the same as regular Python on a PC. You cannot simply import Python libraries, such as import threading, and expect them to work. If you’re expecting that, you’ll be sorely disappointed. In this regard, MicroPython is inferior to Python. In MicroPython, however, you can import machine but not in regular Python. If you work with microcontrollers, MicroPython is unquestionably the best high-level programming environment available. MicroPython, without a doubt, outperforms Python in the realm of microcontrollers. On a Linux machine, MicroPython runs faster than regular Python. MicroPython was built from the ground up, from the Python language specifcatiosn, to run in a resource-constrained environment (CPU, RAM, ROM). There is no operating system in between MicroPython code and hardware GPIO, RTC, and peripherals. The OS is the MicroPython firmware.

Standard best practices for writing Pythonic code may not be the best way to write MicroPython programs due to resource constraints. There are some unusual codes here, such as short variable names (a single character), variable name reuse, compact expressions, breaking normal Python code conventions, and what are normally called “poor programming techniques”. Please accept my apologies. I anticipate that readers of this book will know what is best for them and will stick to their preferred programming styles. In my opinion, a good program is one that works, and 100 lines of code is far too long. By the way, I use vim to code all of my programs; no auto-completion and no auto-correction.

You are free to use whatever works best for you and in whatever style you prefer. Don’t be afraid to break some rules in order to learn. After all, I believe programming is an art form, and we have the freedom to practice it as artists.

This book is about writing concurrent tasks in MicroPython. Things happened all the time in the real world. Ready or not, they keep on coming. Writing programs for microcontrollers expose us to real concurrency of events. This is what make it fun. Learning to control concurrency and be able to reason it all out using simple principles is the main goal of this book. I’ve learn to do just that and I would like to share it with you.

Скачать Workers-Framework: A simpler way to MultiTask in MicroPython








Нашел ошибку? Есть жалоба? Жми!
Пожаловаться администрации
Уважаемый посетитель, Вы зашли на сайт как незарегистрированный пользователь.
Мы рекомендуем Вам зарегистрироваться либо войти на сайт под своим именем.
Информация
Посетители, находящиеся в группе Гости, не могут оставлять комментарии к данной публикации.