Serial port handling: Difference between revisions

From Rsewiki
Line 1: Line 1:
Back to [[Basebot]]
Back to [[Basebot]]


== Windows (and Linux) ==
== Basebot data ==


==== Arduino IDE ====
Basebot data needs to be saved into a file to make it usable for MATLAB.


I couldn't find a way to save the serial monitor data to a disk file.
A log is available after a basebot run.
E.g. by typing ''start'' in the monitor area or by pressing the ''start' button on the robot itself.


So find another app that allows communication in the serial line and save the output to a disk file (or allow copy-paste to do the same).
The logfile will be sent when the mission is complete, or alternatively by sending the command ''log'' to the robot.


==== Visual Studio Code ====
== Arduino IDE ==


From the menu: View -> Command Palette ->
I couldn't find a way to save the serial monitor data to a disk file.
Type PlatformIO: New Terminal


(next time, this command will be first in line)
So find another app that allows communication in the serial line and save the output to a disk file (or allow copy-paste to do the same).
 
In this terminal type


pio device monitor > aaa.txt
== Visual Studio Code ==


It will try to open the communication and save it to the ''aaa.txt'' file.
In the monitor area the log data is shown (e.g. after typing ''log''), like:


Try pressing the ''start'' button on the robot (wheels up).
[[file: VS-Code-data-from-monitor.png | 500px]]
Then press ctrl-C to stop the monitoring and inspect the file.


[[file:MS_Visual_studio_code_device_monitor.png | 500px]]
The data received in the monitor area will be saved to a ''logs'' directory on the ''basebot'' directory.


(the same for both Windows and Linux)
[[file: VS-Code-data-from-monitor-file.png | 500px]]


The file aaa.txt could contain something like:
The saved file could look like this:


  --- Terminal on /dev/ttyACM1 | 9600 8-N-1
  --- Terminal on /dev/ttyACM1 | 9600 8-N-1

Revision as of 17:14, 30 August 2025

Back to Basebot

Basebot data

Basebot data needs to be saved into a file to make it usable for MATLAB.

A log is available after a basebot run. E.g. by typing start in the monitor area or by pressing the start' button on the robot itself.

The logfile will be sent when the mission is complete, or alternatively by sending the command log to the robot.

Arduino IDE

I couldn't find a way to save the serial monitor data to a disk file.

So find another app that allows communication in the serial line and save the output to a disk file (or allow copy-paste to do the same).

Visual Studio Code

In the monitor area the log data is shown (e.g. after typing log), like:

The data received in the monitor area will be saved to a logs directory on the basebot directory.

The saved file could look like this:

--- Terminal on /dev/ttyACM1 | 9600 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, hexlify,  log2file, no control, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
0.67 2.00 0.26 -0.26 0 0 0 0 1 0 0 0 1 0 2.13 2.43
1.17 2.00 0.26 -0.26 0 0 0 0 1 0 0 0 1 0 2.13 2.43
1.67 2.00 0.26 -0.26 0 0 0 0 1 0 0 0 1 0 2.13 2.43
2.17 2.00 0.26 -0.26 0 0 0 0 1 0 0 0 1 0 2.13 2.43
2.67 2.00 0.26 -0.26 0 0 0 0 1 0 0 0 1 0 2.13 2.43
...
1998.67 0.00 -0.36 -0.34 0 0 0 0 1 0 0 0 1 0 2.85 3.23
1999.17 0.00 -0.36 -0.34 0 0 0 0 1 0 0 0 1 0 2.85 3.23
1999.67 0.00 -0.36 -0.34 0 0 0 0 1 0 0 0 1 0 2.85 3.23
2000.17 0.00 -0.36 -0.34 0 0 0 0 1 0 0 0 1 0 2.85 3.23
2000.67 0.00 -0.36 -0.34 0 0 0 0 1 0 0 0 1 0 2.85 3.23
2001.17 0.00 -0.36 -0.34 0 0 0 0 1 0 0 0 1 0 2.85 3.23
% Set Sample time 500 usec. Measured Sample time 499.99 usec.

The numeric content depends on the code (the first column is here time in ms). The lead-in text must be removed before loading into Matlab.

Linux

In Linux, the serial device is called /dev/ttyACM0 (typically), and to copy the robot output to a file is:

$ cat /dev/ttyACM0 > aaa.txt

And use ctrl-C to stop.

You can, in another terminal, send commands to the robot, i.e.:

$ echo "start" > /dev/ttyACM0

This is the same as pressing the start button.

Apple

I don't know