Sending and Reading Test Sample [comtest]

Appearance

 

Overview

This is a sample program for sending and reading data via serial communication.

To run this sample program, two serial communication ports are required.
Connect the two serial communication ports with a cross cable.

Sample specification

※This is the initial value of the sample program.

Program name

./comsend

Baud rate

38400bps

Data length

8

Stop bit

1

Parity

None

To run the sample program, you must compile the source code.
For instructions on how to compile the source code, please refer to the "How to compile C language samples" section in Sample Programs topic.

 

Step to Use

1. Specify two serial port names for serial transmission and reception after the program starts.
  

Example : Serial port name when using a serial communication port on the PC body and COM-1(USB)H
              /dev/ttyS0
              /dev/ttyUSB0

Example : Serial port name when using only one COM-2(PCI)H and connecting it to CN1 and CN2 on the device via cable
              /dev/ttyCom0
              /dev/ttyCom1

2. If you specify two serial port names, it will wait for you to enter the string to send.
    

3. After inputting the string data to be sent using the keyboard, press the Enter key to confirm the string.

    Once the string data is confirmed, it will be sent from one of the serial communication ports, and the string received by the other serial communication port will be displayed on the screen.
    If serial communication is successful, "Transmit result is Right , OK!" will be displayed.

    Next, serial communication is performed in the reverse direction using the same string, and the received string is displayed on the screen.
    If serial communication is successful, "Transmit result is Right , OK!" will be displayed on the screen again.

Example : Serial port name when using only one COM-2(PCI)H and connecting it to CN1 and CN2 on the device via cable
              /dev/ttyCom0
              /dev/ttyCom1

4. The sample program terminates when serial communication in both directions is completed.