Reading Sample [comread]

Appearance

 

Overview

This is a sample program that displays data received via serial communication on the screen.

Sample specification

※This is the initial value of the sample program.

Program name

./comread

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 the name of serial port to read data after the program starts.
    

Example : Serial port name when using only one COM-1(USB)H
              /dev/ttyUSB0

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

2. When data is received via serial communication, the received data will be displayed on the screen.
    The received character string will be displayed, and the number of characters received will be displayed on the next line.

Example: Screen display of "Test string" + character code "CR (Carriage Return)" (total 12 characters) received

3. If the received data begins with the character 'z', the sample program will terminate.

Example: Screen display of "z" + character code "CR(Carriage Return)" (total 2 characters) received