This project is a simple program that allows communication between two UART ports on a Linux system using the libserialport library.
To build the project, follow these steps:
-
Make sure you have the required libraries installed. You can install them by running the following command:
sudo apt-get update sudo apt-get install libserialport-dev
-
Compile the project using the
gcc
compiler. Run the following command:gcc -Wall -Wextra -pedantic -std=c11 main.c -o 2UART_ver1.0
This project requires the following libraries:
- libserialport-dev
Please make sure you have these libraries installed before building the project.
-
Connect the UART devices to the respective COM ports on your Linux system.
-
Run the program using the following command:
./2UART_ver1.0
-
The program will prompt you to enter the COM port numbers for Thread No. 1 and Thread No. 2. Enter the numbers as per your configuration (1-99).
-
The program will open the specified COM ports, configure them with a baud rate of 115200, and create a system message queue.
-
The program will create two threads, each responsible for handling one UART port.
-
Once the threads are running, the program will start listening for packets on Thread No. 1 (COM port specified by the user).
-
To send a packet, type the packet data and press Enter. The program will validate the packet and send it to Thread No. 2 (COM port specified by the user).
-
The received packet will be displayed on the terminal.
-
You can repeat the process to send and receive packets between the two UART ports.
Here's an example usage of the program:
- Enter the COM port number for Thread No. 1: 1
- Enter the COM port number for Thread No. 2: 2
- Start sending packets from Thread No. 1 by typing the packet data and pressing Enter.
- Observe the received packets on Thread No. 2 displayed on the terminal.
This project is licensed under the MIT License. Feel free to modify and distribute it as per the terms of the license.