How To Test A Serial Port - Eurotech ReliaGATE 10-12-6 Series User Manual

Iot edge gateway ti am335x, lte cat 1
Table of Contents

Advertisement

12 How to manage interfaces in Linux
Example: Configuring COM 1 in RS-485 mode
ser_port_name has to be /dev/ttyO3
struct serial_rs485 rs485conf;
unsigned int rs_mode_mask=(SER_HIZ_ENABLED|SER_RS485_ENABLED|SER_RS485_
INVERT|SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND);
unsigned int set_flags=(SER_RS485_INVERT|SER_RS485_ENABLED|SER_RS485_RTS_ON_
SEND);
unsigned int set_flags_mask=rs_mode_mask;
int fd;
fd=open(ser_port_name,O_RDWR);
if (fd==-1)
{
/* process the error */
...
}
/* get serial port configuration */
if (ioctl (fd, TIOCGRS485, & rs485conf) < 0)
{
/* process the error */
...
}
rs485conf.flags&=~ set_flags_mask;
set_flags&=set_flags_mask;
rs485conf.flags|= set_flags;
/*set delays */
rs485conf.delay_rts_after_send=<delay after send in ms>;
rs485conf.delay_rts_before_send=<delay before send in ms>;
/* apply changes */
if (ioctl (fd, TIOCSRS485, & rs485conf) < 0)
{
/* process the error */
...
}
close(fd);
12.9.4

How to test a serial port

To test the serial port, use the microcom utility:
#connect ttyO3 with a baud rate of 9600
microcom /dev/ttyO3 –s 9600
The microcom utility:
Allows you to transmit / receive data to / from the serial port
l
Does not include a local echo (you cannot see the data sent).
l
84 / 118
ReliaGATE 10-12 User manual Rev. 2-1

Advertisement

Table of Contents
loading

This manual is also suitable for:

Regate-10-12-65gRegate-10-12-66gRegate-10-12-67gDynagate 10-12-6 series

Table of Contents