issue special control requests to a driver
#include <sys/types.h> #include <sys/qioctl.h> int qnx_ioctl( int fildes, unsigned request, const void *sbuf, unsigned sbytes, void *rbuf, unsigned rbytes ); int qnx_ioctlmx( int fildes, unsigned request, int sparts, int rparts, const struct _mxfer_entry *sx, const struct _mxfer_entry *rx );
The qnx_ioctl() function issues special control requests to the driver associated with the open file descriptor fildes. Depending on the request type, there may be additional data required (pointed to by sbuf) or data returned (pointed to by rbuf). The size of the data sent in the request or returned (indicated by sbytes and rbytes, respectively) and the format of that data may be both request-specific and driver-specific.
For drivers supplied by QNX Software Systems Ltd., the details are documented only in the header file <sys/qioctl.h>. For other drivers, refer to the driver source or documentation.
The qnx_ioctlmx() function is similar to qnx_ioctl(), but it takes a table of pointers to buffers, rather than a single buffer, for the data sent and returned. The number of elements in the tables, sparts and rparts, must not exceed _QNX_MXTAB_LEN (defined in <limits.h>).
Avoid stuffing each _mxfer_entry directly. Instead use the _setmx() macro to stuff each entry. This makes your code portable across 16- and 32-bit platforms. |
A nonnegative integer value, the meaning of which depends on the request type. If an error occurs, this function returns -1, and sets errno to indicate the error.
Other errors may be returned as needed by the specific driver.
This fragment checks to see if an attached parallel printer is online:
long io_st[2] = {0L, 0L}, io_ret = 0; if ( (fd = open(device, O_RDONLY) ) != -1 ) { qnx_ioctl( fd, QCTL_DEV_CTL, io_st, 8, &io_ret, 4 ); /* compare bit 4: online */ if( io_ret & (1 << 4) ) /* compare bit 5: paper empty */ if( io_ret & (1 << 5) ) strcpy( status, "Parallel: out of paper"); else strcpy( status, "Parallel: on line"); else strcpy( status, "Parallel: off line"); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |