DynaGATE 10-12 User manual Rev. 0-14
Example: Configuring a serial port in RS-232 mode
ser_port_name can be either /dev/ttyO3 or /dev/ttyO4.
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=0;
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 delay but not used in rs232 mode */
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);
11 How to access interfaces under Linux
71 / 94
Need help?
Do you have a question about the DynaGate 10-12 Series and is the answer not in the manual?