Controlling serial port RTS pin from 'C' program
Using Slackware 9 running on a 586 Compaq laptop.
I'm using /dev/ttyS0 to communicate with a micro-controller. Opening it with O_RDWR | O_NOCTTY then using tcgetattr and so forth per the serial_programming HOWTO works fine, up to a point...
I can send and receive bytes all day using a direct serial cable, however I have a half duplex radio link that I need to switch directions using the RTS line. Said another way, I need to assert RTS to low under program control before I send bytes (to turn on the radio transmitter).
I've tried:
int flags;
ioctl(fd, TIOCMGET, &flags);
flags &= ~ 0x004 // because TIOMC_RTS is undefined in my system
ioctl(fd, TIOMSET, &flags);
and also:
ioctl(fd, TIOMBIC, 0X004);
Neither seem to affect the RTS pin at all and sometimes hang the system.
Any ideas?
|