Arduino Forum

Products => Arduino Yún => Topic started by: metalli-guy on Jan 04, 2019, 12:32 am

Title: Problems with Python-Arduino Yún
Post by: metalli-guy on Jan 04, 2019, 12:32 am
So, I have an Arduino code that works properly when using "Console.parseInt" and "Console.println" on the Arduino Serial Monitor.

What I'm having problems is with sending those console commands via python.

So I'm looking for something like pySerial, but for Yún's console.

Anyone got any pointers I can follow? Much appreciated.
Title: Re: Problems with Python-Arduino Yún
Post by: ShapeShifter on Jan 06, 2019, 09:59 pm
I'm sure you could figure out a way for a Python script on the Linux side to talk to the Console port using a network socket connection. But that's not the way I would recommend doing it.

Check out the Process class examples. I think this is the most useful part of the Bridge library. Once a Process class is started, your sketch can read and write from the Process using exactly the same methods that you are using with the Console class. The general idea is that you provide the path to your Python script to the Process object. The Process object will start the script on the Linux side, and automatically manage the connection between them: anything that the Python script prints can be read from the Process object by the sketch, and anything that the sketch writes to the Process object can be read by the Python script. There is no need for a special communications library on the Python side, your script just needs to write to stdout and read from stdin using the same methods that you would use to write to the screen and read from the keyboard.