Controlling micropython board from desktop computer

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Controlling micropython board from desktop computer

Post by jimmo » Fri Jul 08, 2022 6:26 am

Marius wrote:
Thu Jul 07, 2022 4:10 pm
I can control the TMC5160 board via the micropython repl. But i want to control it from some python3 code i run on my desktop. With pyserial or whatever. My desktop can be apple, win, ubuntu
Yes, you can do this with pyserial.

Note that MicroPython includes a tool "pyboard.py" that uses pyserial to do exactly this and you can also use it as a library to send commands to a connected MicroPython board.

See recent thread here:
viewtopic.php?f=15&t=12651

Marius
Posts: 21
Joined: Fri Nov 30, 2018 2:08 pm

Re: Controlling micropython board from desktop computer

Post by Marius » Fri Jul 08, 2022 7:48 pm

jimmo wrote:
Fri Jul 08, 2022 6:26 am
Marius wrote:
Thu Jul 07, 2022 4:10 pm
I can control the TMC5160 board via the micropython repl. But i want to control it from some python3 code i run on my desktop. With pyserial or whatever. My desktop can be apple, win, ubuntu
Yes, you can do this with pyserial.

Note that MicroPython includes a tool "pyboard.py" that uses pyserial to do exactly this and you can also use it as a library to send commands to a connected MicroPython board.

See recent thread here:
viewtopic.php?f=15&t=12651
Super cool!

martincho
Posts: 96
Joined: Mon May 16, 2022 9:59 pm

Re: Controlling micropython board from desktop computer

Post by martincho » Mon Jul 11, 2022 7:05 am

One of the things to watch out for with protocols such as MIDI and derivatives is that they have no way to validate communications. If you are not careful a system can very easily fall into a situation known in computer science as "The Two Generals Problem":

https://en.wikipedia.org/wiki/Two_Generals%27_Problem

At a minimum, the receiver must be able to validate a message without anything other than the message itself. This typically moves towards the use of CRC (cyclic redundancy check) along with other validators. While simple checksums are sometimes uses, I would be very careful and would not use them for anything critical.

Put another way: Give me a 100 foot RS-232 cable and I'll show you what pain and misery looks like as you try to figure out why the data is great at the sending end of the cable and complete garbage at the other end. Anyone old enough to know what a tape degausser was? Yeah. I had someone at work ripping their hair out for nearly a week trying to figure out why he could not get reliable communications.

Before you think "that was cruel", six month earlier they wired a variac to my workbench. Had me going for a week as they messed with the voltage going to the equipment I was testing as well as my test instruments.

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Controlling micropython board from desktop computer

Post by scruss » Mon Jul 11, 2022 4:46 pm

BetterAutomations wrote:
Thu Jul 07, 2022 8:11 pm
Firmata would be a great choice. I don’t think the Pi board needs to run uPy, they probably have an image just for that.
You're right: the board wouldn't need to run MicroPython. I'd looked at whether there was an RP2040 implementation of Firmata a couple of weeks ago, and couldn't find one. It's complicated by the fact that there are two separate and slightly incompatible Arduino toolchains for RP2040: the first, unofficial one that's lovingly maintained by one developer, and the later official one based on Mbed but missing some key features. Users are finding it hard to commit to one or the other

Post Reply