Real Time serial connection (Write data to the board from 3rd party software

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
meldiwin
Posts: 7
Joined: Sat Jul 28, 2018 10:46 pm

Real Time serial connection (Write data to the board from 3rd party software

Post by meldiwin » Mon Jul 30, 2018 4:29 pm

Hello,

I am using micropython board pyb v1 and I am supposed to use it with another software SOFA framework for sending data to the board from SOFA, however, I found that rshell disconnects and sometimes doesnot work, I would be grateful if there is solution?.


Thanks,

Marwa

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

Re: Real Time serial connection (Write data to the board from 3rd party software

Post by dhylands » Mon Jul 30, 2018 5:32 pm

Note: that only one piece of software should have the serial port open at a time.

If rshell (or any other terminal program for that matter) has the serial port open and another program opens the serial port at the same time then some of the characters sent from the pyboard will go to rshell and some of the characters will go to the other program.

meldiwin
Posts: 7
Joined: Sat Jul 28, 2018 10:46 pm

Re: Real Time serial connection (Write data to the board from 3rd party software

Post by meldiwin » Mon Jul 30, 2018 7:38 pm

Thanks for your reply! I understand this, but the problem how to define pyb board in python directly, I am using Pyserial, so how Pyb defined directly from my software which some part of it python code.

File "serialPortController.py", line 1, in <module>
from pyb import Pin
ImportError: No module named pyb

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

Re: Real Time serial connection (Write data to the board from 3rd party software

Post by dhylands » Mon Jul 30, 2018 9:05 pm

The pyb module is only available on the pyboard, not on the host side.

meldiwin
Posts: 7
Joined: Sat Jul 28, 2018 10:46 pm

Re: Real Time serial connection (Write data to the board from 3rd party software

Post by meldiwin » Fri Aug 03, 2018 4:58 pm

For the moment, I can connect my third party software with micropython, however, I wasnot able to power even a lead because I have to write

pyb.LED(1).on()

I dont know how micropython board v1 can be communicated with other software, any solutions?

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

Re: Real Time serial connection (Write data to the board from 3rd party software

Post by dhylands » Fri Aug 03, 2018 5:19 pm

I wrote some software called json-ipc which sends json packets back and forth. You can find it here:
https://github.com/dhylands/json-ipc

You could have the host send a command to turn the LED on and the pyboard would execute the pyb.LED(1).on(). The pyb.LED(1).on() needs to executre from the python running on the pyboard and not the python running on the host.

meldiwin
Posts: 7
Joined: Sat Jul 28, 2018 10:46 pm

Re: Real Time serial connection (Write data to the board from 3rd party software

Post by meldiwin » Sun Aug 05, 2018 6:43 pm

Thanks for your reply!. Now it seems that micro python doesnot have the same flexibility as arduino boards, as I need to run this on the python host as it is integrated with other parts of software. I would like to use micropython board, but this could be a dilemma as I cannot send commands from host directly.

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: Real Time serial connection (Write data to the board from 3rd party software

Post by SpotlightKid » Sun Aug 05, 2018 11:56 pm

An Arduino board also can not directly execute "commands" from another host or any other computer, unless you program it with a firmware (sketch), which allows you to do just that, for example one based on the Firmata protcol. The one commonly used is called StandardFirmata.

Post Reply