kdb119: Intellicon & NT960 ISA Serial I/O and tcflush() Under QNX 4.xx

Title: Intellicon & NT960 ISA Serial I/O and tcflush() Under QNX 4.xx
Keywords: tcflush Intellicon NT960 QNX4 ctiflush
Date: April 8, 1997
KDB: KDB-119
Revision: 0.01
Author: Support
Distribution: External

The standard tcflush() routine does not properly work on Intellicon and NT960 boards. The problem lies with he QNX OS itself. QNX does not properly take into account the fact that I/O devices could contain buffered data. In the case of tcflush(), a call to this would only clear the buffers of Dev on the QNX side and not the ones on our Intellicon or NT960 card.

To alleviate this, we have added support for a new IO Control call (added in version 4.20p of Dev.cti and version 4.21h of Dev.nt960). This call allows us to implement our own version of the tcflush() routine. Our version is called ctiflush() and it has the exact same arguments as tcflush().

Below is the ctiflush() routine:

/********************************************************************** 
**  File:       	ctiflush.h 
**  Author:     	Allan Smith 
**			Connect Tech Inc. 
**   
**  Description:    	QNX 4.xx Intellicon ctiflush() Header file 
**   
**  Revision history:        
**  Original:   	Jan 19/96   
**   
***********************************************************************/ 
 
#ifndef _CTIFLUSH_H 
#define	_CTIFLUSH_H 
 
#define	CTIFLUSH_IN	0x300d		/* CTIFLUSH input ioctl*/ 
#define	CTIFLUSH_OUT	0x300e		/* CTIFLUSH output ioctl */ 
 
int	ctiflush( int fildes, int queue_selector ); 
 
#endif	/* _CTIFLUSH_H */ 
/*end ctiflush.h*/ 
 
 
/******************************************************************** 
**	File:		ctiflush.c 
**	Author:		CTI Enginneering 
**			Connect Tech Inc. 
** 
**	Original:	Jan 19/96 
**	Revision History: 
** 
** 
********************************************************************* 
** 
**	Description: 
**	This program acts as replacement for the QNX 4.xx function called 
**	tcflush.  Being that the standard call does not properly support 
**	buffered IO, a replacement had to be created. 
** 
**	The syntax of ctiflush is identical to Watcom's tcflush function: 
** 
**	#include	 
**	int	ctiflush( int fildes, int queue_selector ); 
** 
**	Return Values: 
**	EBADF	The argument fildes is invalid. 
**	EINVAL	The argument queue_selector is invalid. 
**	ENOSYS	The resource manager associated with fildes does not 
**			support this call. 
**	ENOTTY	The argument fildes does not refer to a terminal device. 
** 
********************************************************************/ 
#include	 
#include	 
#include	 
#include	 
#include	 
#include	"ctiflush.h" 
 
int	ctiflush( int fildes, int queue_selector ){ 
	struct _dev_info_entry	info; 
 
	/* dev_info call needed rather than just a Sendfd() since 
	 * need to send the unit number to Dev.cti also 	*/		                          
	if( dev_info( fildes, &info ) != 0 ) 
		return( EBADF ); 
	 
	/* if funtion to be performed is not one of these three then 
	 * return error */ 
	if( queue_selector != TCIFLUSH && queue_selector != TCOFLUSH && 
	    queue_selector != TCIOFLUSH ) 
		return( EINVAL ); 
/* Flush Input*/	 
	if( queue_selector == TCIFLUSH || queue_selector == TCIOFLUSH ){ 
		if( qnx_ioctl( fildes, CTIFLUSH_IN, (void *)0, 0, (void *)0, 0 ) == -1 ) 
			return( ENOSYS ); 
	}	 
/* Flush output */ 
	if( queue_selector == TCOFLUSH || queue_selector == TCIOFLUSH ){ 
		if( qnx_ioctl( fildes, CTIFLUSH_OUT, (void *)0, 0, (void *)0, 0 ) == -1 ) 
			return( ENOSYS ); 
	} 
	/* now perform a standard tcflush() to clear Dev's chars */ 
	return( tcflush( fildes, queue_selector ) ); 
}  /*end ctiflush.c*/ 

End of KDB-119

Go to Top