MicroPython – Python for Microcontrollers
81–90 of 106 posts
Re: MicroPython – Python for Microcontrollers
#82Earlier quoted context omitted.
> why do you say setup and loop are the worst imaginable way to write embedded software? Because there's neither abstraction nor ways to combine things. Say you have a device that needs to do two things, and you look up some examples of how to do each thing. Each example is going to have its own loop() function--but how do you combine them? There's no notion of tasks or threads. There's no abstraction for device driv…
You don't have to use `setup` and `loop` tough. We use Arduino as a library in C++ using PlatformIO as tooling. Best of both worlds. The thing you are hating on is pretty much this file: https://github.com/arduino/ArduinoCore-avr/blob/master/cores... Arduino is C++ with some boilerplate and a library.
Re: MicroPython – Python for Microcontrollers
#83I would still like to use micropython, but I need to figure out how to write certain pieces like the display lib in C.
Re: MicroPython – Python for Microcontrollers
#84A language with meaningful whitespace and indentation does not make a good language for UART or other serial interaction. At the point you can use a higher level interaction, why stop at Python? Go full codeless checkboxes on webpages. If the alleged problem that micropython solves is complexity of actually coding microcontrollers, why settle for Python, which can only ever wrap/call native functionality that is hidd…
Whenever I see someone complaining about Python's use of whitespace as syntax, I think to myself "This person poorly formats their code".
If you're properly formatting code, there's no reason to complain about it. You might occasionally copy/paste code from where that doesn't properly encode the whitespace, in which case yeah it might get messed up, but that's rare in my experience.
Re: MicroPython – Python for Microcontrollers
#85I did a lot of product development using Micropython over the past year or so. There are certain things it is very good at - one is rapid prototyping. For instance it’s a lot easier and faster and less verbose to quickly get some http server communication going on the ESP32 in Micropython rather than the C equivalent. The downsides are somewhat dramatic though - it’s, of course, a lot slower and hungrier for memory t…
Re: MicroPython – Python for Microcontrollers
#86A possible alternative to MicroPython is Nim - it's a strongly typed language with Python-like syntax that compiles down to C. Since it compiles to C, it can use existing C libraries without much fuss (just wrap signatures as needed), plus there's no need for a "micro" version of the language. Several members of the community have been working on improving the embedded ecosystem: although I haven't played around with…
I think with current parts the only way would be to focus on RISC-V, but who knows. They might have better luck talking to vendors.
Re: MicroPython – Python for Microcontrollers
#87Earlier quoted context omitted.
You don't have to use `setup` and `loop` tough. We use Arduino as a library in C++ using PlatformIO as tooling. Best of both worlds. The thing you are hating on is pretty much this file: https://github.com/arduino/ArduinoCore-avr/blob/master/cores... Arduino is C++ with some boilerplate and a library.
But these `setup`, `loop` and `delay`, as well as the terrible "IDE" are central to the "simple" user experience of Arduino and are, imo, false friends. Teaching people busy loops and blocking behavior from day 1 is counterproductive because you'll have to unteach them later and jump through hoops to avoid them. Arduino libs are strongly optimized for "easy", not efficiency and flexibility.
Using Arduino will not magically rot your brain and make you unable to ever learn other things. It will however get you started quickly and therefore give you an in. I started using Arduino in a student job, then used Micropython, did my masters thesis on using Micropython on cubesats and now I run a team of 15 hardware engineers.
All of this happened because I got started with easy beginner tools. There was no one to teach me the "real" way. The people preaching the real way and railing against simple beginner stuff usually don't write tutorials, build easy to use devboards or write easy to use libraries.
Re: MicroPython – Python for Microcontrollers
#88Earlier quoted context omitted.
The company I work for uses MicroPython commercially to build medical devices. It hasn't fallen apart for us. Indeed, it's helped deliver high-quality solutions quickly...
Can you guarantee you never run out of ram? Or do you just restart regularly? (I typically am to scared to even use malloc on a microcontroller...)
Re: MicroPython – Python for Microcontrollers
#89Earlier quoted context omitted.
The company I work for uses MicroPython commercially to build medical devices. It hasn't fallen apart for us. Indeed, it's helped deliver high-quality solutions quickly...
That's worrying. I can't think of a less appropriate application for something as fragile as Python.
Re: MicroPython – Python for Microcontrollers
#90Earlier quoted context omitted.
The MicroPython interpreter is very robust and well tested. We test our devices extensively. You need to pay attention to gc performance, memory use and fragmentation but this isn't our first rodeo! Systems are typically fragile because of poor system design not language choice. I've worked on many C and C++ systems and there's nothing inherently more robust about them. Some would argue that the various ways you can…
> Some would argue that the various ways you can trip over UB makes them more fragile That is definitely a factor! But I probably wouldn't pick C++ for a medical device now anyway - I would go with Ada or Rust. > Systems are typically fragile because of poor system design not language choice. Poor system design and language choice are both factors. You can work around language choice with a shit load of testing, but…