From 5cdb27b8b64efe42e25b33d11ec2a624acedf1f6 Mon Sep 17 00:00:00 2001 From: Federico Lolli <federico.lolli@skywarder.eu> Date: Tue, 20 Feb 2024 12:30:00 +0100 Subject: [PATCH] update docs --- README.md | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index b3b0bb0..2a33049 100644 --- a/README.md +++ b/README.md @@ -28,34 +28,35 @@ mv target/release/libserial_bridge.dylib serialbridge.<EXT> ## Usage +All string arguments should be char arrays (e.g. `'main'` instead of `"main"`). + serialbridge can be used in matlab in the following way: -- `serialbridge("Open", string_serialPort, uint_baudrate)`: - - **"Open"**: specifies we want to open the serial port - - string_serialPort: is the serial port we want to open (eg: "COM6") - - uint_baudrate: is the baudrate of the port (eg: 256000) -- `serialbridge("Write", string_serialPort, singleArray_Data)`: - - **"Write"**: specifies that we want to write to the serial port - - singleArray_Data: is the array of singles we want to write on serial (eg: [1 2 3 4.5 5.4]) -- `singleArray_Data = serialbridge("Read", string_serialPort, uint_nData)`; - - **"Read"**: specifies that we want to read from the serial port - - uint_nData: How many floats to read from serial (eg: 1) - - singleArray_Data: array of floats read from the serial (eg: actuatorData) -- `serialbridge("Close", string_serialPort)`: - - **"Close"**: specifies we want to close the serial port +- `serialbridge('Open', '<PORT_ID>', '<PORT_PATH>', 115200)`: + - `'Open'`: specifies we want to open the serial port + - `<PORT_ID>`: is the name of the serial port (e.g. `'main'`, `'payload'`, etc.) + - `<PORT_PATH>`: is the serial port we want to open (e.g. `'COM6'`) + - `115200`: is the baudrate of the port +- `serialbridge('Write', '<PORT_ID>', single([0, 1, 2]))`: + - `'Write'`: specifies that we want to write to the serial port + - `<PORT_ID>`: is the name of the serial port (e.g. `'main'`, `'payload'`, etc.) + - `[0, 1.2, 2.3]`: is the array of singles we want to write on serial. +- `data = serialbridge('Read', '<PORT_ID>', 10)`; + - `'Read'`: specifies that we want to read from the serial port + - `<PORT_ID>`: is the name of the serial port (e.g. `'main'`, `'payload'`, etc.) + - `10`: How many floats to read from serial + - `data`: array of floats read from the serial (e.g. actuatorData) +- `serialbridge('Close', '<PORT_ID>')`: + - `'Close'`: specifies we want to close the serial port + - `<PORT_ID>`: is the name of the serial port (e.g. `'main'`, `'payload'`, etc.) **Example** in Matlab: ```matlab -serialbridge("Open", "dev/COM6", 256000); % Opens the serial port -serialbridge("Write", "dev/COM6", [1 2 3 4]); % Sends the array "[1 2 3 4]" to the serial device -data = serialbridge("Read", "dev/COM6", 2); % Receives 2 floats and stores them in the variable "data" -serialbridge("Close", "dev/COM6"); % Closes the serial port +serialbridge('Open', 'main', '/dev/ttyACM0', 115200); % Opens the serial port +serialbridge('Write', 'main', single([1 2 3 4])); % Sends the array "[1 2 3 4]" to the serial device +data = serialbridge('Read', 'main', 2); % Receives 2 floats and stores them in the variable "data" +serialbridge('Close', 'main'); % Closes the serial port ``` -Procedure in order to use the **MatlabTransceiver** module: https://git.skywarder.eu/scs/hermes/r2a-obsw/-/blob/Serial4Simulations-dev/src/tests/hardware_in_the_loop/README.md - -***WARNING***: -* It's possible to open just ONE serial port with this module - ## Dev Tho have rustanalyzer working properly, you need to add a `config.toml` in the `.cargo` directory at the root of this repository with the following content: -- GitLab