This README refers to the **serialbridge** module used for the Hardware In the Loop (HIL) simulation.
## How to Build
The following steps will generate a `mex` file that can be used in MATLAB.
### With Just
Just takes care of setting the correct extension.
```bash
just build-env <MATLAB_PATH>
```
Where `<MATLAB_PATH>` is the path to the MATLAB installation directory. This can be found by running `matlabroot` in the MATLAB command window as follows:
-**"Close"**: specifies we want to close the serial port
**Example** in Matlab:
```
serialbridge("Open", "COM6", 256000); % Opens the serial port
serialbridge("Write", [1 2 3 4]); % Sends the array "[1 2 3 4]" to the serial device
data = serialbridge("Read", 2); % Receives 2 floats and stores them in the variable "data"
serialbridge("Close"); % 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:
```toml
[env]
MATLAB_LIB_DIR=<MATLAB_PATH>
```
To get the `<MATLAB_PATH>` you can follow the instructions in the "How to Build" section.