kdb060: Using TCDRAIN and CTI_TCDRAIN Under QNX 4

Title: Using TCDRAIN and CTI_TCDRAIN Under QNX 4
Keywords: TCDRAIN, CTI_TCDRAIN, QNX4
KDB: KDB-060
Revision: 0.00
Author: Support
Distribution: External

tcdrain() function as supplied by Watcom/QSSL does not work with Intellicon or NT960 drivers.

The reason for this is that the Watcom/QSSL function expects the UART device to have a transmit FIFO of one byte. Therefore, when the buffer between Dev and Dev.ser/Dev.cti/Dev.nt960 is empty, tcdrain() assumes this means that all bytes have been transmitted.

With Intellicon and NT960, there can be several kilobytes of data on the card waiting to be transmitted yet tcdrain() would indicate they have been transmitted.

To avoid this, CTI has introduced cti_tcdrain() that operates like tcdrain() with the exception that cti_tcdrain() does not return until there is no buffered data on the Intellicon or NT960 left to transmit.

The proper use of cti_tcdrain() is in conjunction with tcdrain(), thereby ensuring that the operating system’s buffers are empty and the card’s buffers are empty.

An example follows:

	int	fd;
	fd = open( "/dev/nt1", O_RDWR );
	write( fd, "ATH" );
	tcdrain( fd );
	cti_tcdrain( fd );

When tcdrain returns, Dev’s buffers have been emptied to the card. When cti_tcdrain() returns, all data buffered on the card has been transmitted.

End of KDB-060

Go to Top