How a pyboard can request the runnig of a program on a computer ?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
Alqx
Posts: 4
Joined: Fri Jan 08, 2021 3:13 pm

How a pyboard can request the runnig of a program on a computer ?

Post by Alqx » Thu Jan 21, 2021 5:41 pm

Hello to the whole micropython community!

I am a student and have a micropyhton project with my classmates.

Our project is to control motors with the Pyboard, however the pyboard needs information (information relating to the time during which a motor must be running). This information are obtained from a Python program on a computer that uses a module called "OpenCV".

Here is our problem:
We would like the pyboard to ask the computer to run a Python program (using the OpenCv module). This program will send information back to the pyboard.
Subsequently, this information will allow the Pyboard to control the motors.

Additional information:
- We use Upycraft to communicate with the pyboard.
- We are beginners in micropython.


Thank you in advance for your reply :)

User avatar
mathieu
Posts: 88
Joined: Fri Nov 10, 2017 9:57 pm

Re: How a pyboard can request the runnig of a program on a computer ?

Post by mathieu » Thu Jan 21, 2021 7:15 pm

This is a very non-specific answer, but you could look at pyb.USB_VCP() and set up some flavor of two-way communication between the host computer and the pyboard.

https://docs.micropython.org/en/latest/ ... B_VCP.html

Alqx
Posts: 4
Joined: Fri Jan 08, 2021 3:13 pm

Re: How a pyboard can request the runnig of a program on a computer ?

Post by Alqx » Fri Jan 22, 2021 3:42 pm

Thank you Mathieu,
We took a good look at what you sent us. We are still beginners, so we did not understand the content of the link😭. If someone could give us more information or even suggest another method (more precise if possible). We are open to all proposals 😀!

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: How a pyboard can request the runnig of a program on a computer ?

Post by dhylands » Fri Jan 22, 2021 6:53 pm

There is no way for Micropython to run anything on the PC.

You can run a program on the PC which listens for requests and have that program on the PC run it on behalf of Micropython.

There are any number of ways for that micropython can communicate with the PC. The USB port basical;y looks like a serial link, so you can use pretty much any serial communications protocol you'd like.

I wrote one that uses JSON to communicate back and forth. See https://github.com/dhylands/json-ipc

The stm_usb_port.py file uses pyb.USB_VCP that a previous post was referring to.

Post Reply