scott@melpar.UUCP (Rob Scott) (06/05/90)
My IBM 286 XENIX application, which is making "write" calls to /dev/tty00 has a little problem... Background: -I'm using an IBM Serial Parallel Adapter and the vanilla tty driver. -I have initialized the driver for ~CLOCAL (to use modem control). -I'm catching SIGHUP(generated upon loss of CD). -I'm using CTS tied to DSR (pins 5 & 6 RS232) along with CD (pin 8) as my externally controlled lines. CTS and DSR are toggled externally by the contolling device (which is not a modem). CD is toggled upon loss of external device. My code is structured like this: while ( not done reading in 512 byte chunks...) { signal( SIGHUP, hangup_alarm); alarm( timeout, timeout_alarm); while ( (n = write( ... )) != num_bytes_read) { reset alarms; check for KILL messages; sleep(for_awhile); } } Pretty basic stuff. Right out of "Advanced UNIX Programming". The bottom line is - I want to use CTS/DSR as flow control lines. This seems to work except in the following cases: If CTS/DSR is OFF before I attempt write to the port ( CD is ON ) it writes anyway! The external line must be toggled once in order for the driver to respond. The other case is where CD is set to OFF, then CTS/DSR is set to OFF, then CD is reasserted. Upon reasserting CD even with CTS/DSR still OFF the write is carried out once again. What must I do to properly monitor the state of the CTS/DSR lines prior to actually writing data?? I tried preceeding my writes with an initializing write call writing a null character write(port,'',1) but that has little if any effect. Any suggestions on what I might be missing would be appreciated !!