# uart_server

The uart server is intended for work with serial ports (COM-ports): UART (RS232), RS485 via RS485-USB and etc. interface converters

## Contents

- **Setup**
- **Using**
- work with uart_server in CLI mode
- work with uart_server in TCP mode
- **Output uart_server data files description**
- **Contacts**

## Setup
1. Install Rust compiler (if you don't have).
Installation on Linux:
```
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
```

Installation on Windows:  
Go to address https://www.rust-lang.org/tools/install and follow instructions  
For more detailed information you can go to: https://doc.rust-lang.ru/book/ch01-01-installation.html

**Instruction for setup uart_server project**

2. Clone the repo to your computer:

```
git clone http://heagit.cosmos.ru/gamkov/uart_server.git
```

3. Enter the repo and compile it:
```
cd <PATH_TO_UART_SERVER>
cargo build --release
```

After running this commands you will get an execution file (uart_server) in the following directory:  
\<PATH_TO_UART_SERVER\>/target/release/

## Using
### work with uart_server in CLI mode
1. See current available serial ports (Ubuntu):
```
sudo setserial -g /dev/ttyUSB*
```
2. for access to operation with hardware run program with sudo (specify available serial port): 
```
sudo ./uart_server -m cli -p /dev/ttyUSB1
```
3. In cli mode type 'help' in order to get information about programs command system

### work with uart_server in TCP mode
1. See current available serial ports (Ubuntu):
```
sudo setserial -g /dev/ttyUSB*
```
2. for access to operation with hardware run program with sudo (specify available serial port and desired IP-address, port for uart-server): 
```
sudo ./uart_server -m tcp:127.0.0.1:10000 -p /dev/ttyUSB1
```
## Output uart_server data files description
log files are located in directory: 
\<PATH_TO_UART_SERVER\>/log/

**description:**  
cmd_\<data\>\_\<user_name_file\>.log - file with output data to serial port   
data_\<data\>\_\<user_name_file\>.log - file with input data from serial port  
cmd_data_\<data\>\_\<user_name_file\>.log - file with output and input data to and from serial port  

where	\<data\> - file generation date,  
		\<user_name_file\> - user filename addition (for more information type help in CLI mode)  

**File data log fromat:**  
data represented in csv-format (with \';\' separation)  
*column 1:* timestamp in format: YYYY.mm.dd HH:MM:SS.zzz (for example: 2025.03.26 16:00:01.158)   
*column 2 for cmd and cmd_data log files:* data that was sent to the serial port  
*column 2 for data log file:* data that was received from serial port  
*column 3 for cmd_data log file:* data that was received from serial port  
*column 3 for cmd and data log files:* no data available  

## Contatcs
For questions about the program, please contact Danila Gamkov, mail: danila_gamkov@cosmos.ru
