[Previous]
[Contents]
[Next]

console_write()

write data directly to the video buffer of a console

Synopsis:

#include <sys/console.h>
int console_write( struct _console_ctrl *cc,
           int console,
           unsigned byte_offset,
           unsigned char *buf,
           int n, int *row, int *column, 
           int *type );

Description:

The console_write() function writes data directly to 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.

The n device-dependent bytes pointed to by buf are written to the console's video buffer at the given byte_offset.

The values pointed to by row, column, and type indicate the cursor position and type after the call. For each of these arguments that isn't NULL, the write operation attempts to update the corresponding cursor position/type, in addition to writing display data, otherwise, that aspect of the cursor is unchanged.


Note: Display data alone has no effect on the cursor. Cursor coordinates start at (0,0) in the upper left corner of the screen. Cursor types are defined in <sys/console.h>.

Returns:

0
Success
-1
An error occurred. errno is set to indicate the error.

Errors:

EACCES
You don't have write permission for the console.
EINVAL
The control structure is invalid.
ENXIO
The console value is invalid.

Examples:

#include <sys/console.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>

int main( void )
  {
    struct _console_ctrl *cc;
    int fd, row, col, type;
    char *buf;

    /* Open 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 */

    buf = calloc( 80*25, 2 );
    console_read( cc, 0, 0, buf, 80*25*2,
          &row, &col, &type);

    /* Display "Hello!" in white-on-black characters at 
       (row, col) of the screen, leaving the cursor unchanged */

    console_write( cc, 0, 2*( row*80 + col ),
           "H\007e\007l\007l\007o\007!\007",
           2*6, NULL, NULL, NULL );

    /* Restore the entire screen to its original state */

    console_write( cc, 0, 0, buf, 80*25*2, &row, &col, &type);

    /* Close the channel */

    console_close( cc );
    return (EXIT_SUCCESS);
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

console_active(), console_arm(), console_close(), console_ctrl(), console_font(), console_info(), console_open(), console_protocol(), console_read(), console_size(), console_state(), errno


[Previous]
[Contents]
[Next]