reading RTS/DTR?

Hi,
I have code to raise and lower DTR using qnx_ioctl, I was wondering how I
might READ RTS/DTR back.

Another question is, when I do stty -a </dev/ser1, and it says -DTR -RTS, is
that from the driver, or from the port?

TIA,
R B Adler

Previously, R B Adler wrote in qdn.public.qnx4:

Hi,
I have code to raise and lower DTR using qnx_ioctl, I was wondering how I
might READ RTS/DTR back.

Another question is, when I do stty -a </dev/ser1, and it says -DTR -RTS, is
that from the driver, or from the port?

TIA,
R B Adler

Here’s how to do it. Check out /usr/include/sys/qioctl.h for the
definitions of bit/mask and the values returned in the result array.

----------------------- snip --------------------------

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/kernel.h>
#include <sys/qioctl.h>
#include <sys/_devdrvr.h>

main()
{
int fd ;
char data[8] ;
char result[8] ;
long *bits = (long *) &data[0] ;
long *mask = (long *) &data[4] ;

errno = 0 ;
fd = open( “/dev/ser1”, O_RDWR ) ;
if( errno )
{
perror( “\nOpen error”) ;
exit( -1 ) ;
}

memset( data, ‘\0’, sizeof( data ) ) ;

#ifdef NOWAY
/*

  • if you want to set or clear varios bits, do it here
    */

*(mask) = 2 ;
*(bits) = 0 ; // Turn off DTR
#endif

errno = 0 ;
if( qnx_ioctl(fd, // AdMIT file descriptor
QCTL_DEV_CTL,
data, // Data being sent
sizeof(data), // Size of data being sent
result, // Current IO states returned here
sizeof(result)) < 0 ) // Size of response data
{
perror( “\nIoctl error”) ;
return( -1 ) ;
}

printf( “\nDTR is %s”, result[0] & 0x01 ? “SET” : “CLEAR” ) ;
printf( “\nRTS is %s”, result[0] & 0x02 ? “SET” : “CLEAR” ) ;
printf( “\n” ) ;

return( 0 ) ;
}

Previously, R B Adler wrote in qdn.public.qnx4:

Hi,
I have code to raise and lower DTR using qnx_ioctl, I was wondering how I
might READ RTS/DTR back.

Another question is, when I do stty -a </dev/ser1, and it says -DTR -RTS, is
that from the driver, or from the port?

TIA,
R B Adler

I forgot your question. When you do stty -a it sends an ioctl to the
driver. Whether or not it is from the driver or the port depends on
the driver in question. Generally, a driver would read the data from
the hardware, but it doesn’t HAVE to - it could choose to return the
last known state or the last value set.