read data directly from the video buffer of a console
#include <sys/console.h> int console_read( struct _console_ctrl *cc, int console, unsigned byte_offset, unsigned char *buf, int n, int *row, *column, *type );
The console_read() function reads data directly from the video buffer of the indicated console.
The argument cc is a pointer to a control structure that was returned by a previous call to console_open(). The argument console has a value of 1 to represent the device named /dev/con1, a value of 2 for /dev/con2, and so on. A value of 0 for console indicates the default console (that is, the one used by console_open()). A value of -1 for console indicates the currently visible console.
n device-dependent bytes are read from the console's video buffer (starting at byte_offset), and are stored in buf.
The values pointed to by row, column, and type indicate the current cursor position and type. Any of these arguments may be NULL, in which case, the corresponding variable is not set.
Cursor coordinates start at (0,0) in the upper left corner of the screen. Cursor types are defined in <sys/console.h>.
#include <sys/console.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> int main( void ) { struct _console_ctrl *cc; int fd; int row, col, type; char c, attr, *buf; /* Open up a channel to the console driver */ fd = open( "/dev/con1", O_RDWR ); cc = console_open( fd, O_RDWR ); close( fd ); /* Read the entire 80x25 (IBM compatible) screen that is currently being displayed */ buf = calloc( 80*25, 2 ); console_read( cc, 0, 0, buf, 80*25*2, &row, &col, &type); /* Read the single character at the (row, col) position of the screen */ console_read( cc, 0, 2*( col + 80*row ), &c, 1, NULL, NULL, NULL ); /* Read the attribute of the single character at the ( row, col ) position of the screen */ console_read( cc, 0, 2*( col + 80*row )+1, &attr, 1, NULL, NULL, NULL ); /* Close the channel */ console_close( cc ); return (EXIT_SUCCESS); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
console_active(), console_arm(), console_close(), console_ctrl(), console_font(), console_info(), console_open(), console_protocol(), console_size(), console_state(), console_write(), errno