RTEMS Logo

RTEMS 4.9.2 On-Line Library


Console Driver Changing Serial Line Parameters

PREV UP next Bookshelf BSP and Device Driver Development Guide

8.4.9: Changing Serial Line Parameters

The console_control is invoked when the line parameters for a particular serial device are to be changed. This entry point corresponds to the device driver io_control entry point.

The application writer is able to control the serial line configuration with Termios calls (such as the ioctl command, see the Termios documentation for more details). If the driver is to support dynamic configuration, then it must have the console_control piece of code. Basically ioctl commands call console_control with the serial line configuration in a Termios defined data structure.

rtems_device_driver console_control(
    rtems_device_major_number major,
    rtems_device_minor_number minor,
    void *arg
)
{
    return rtems_termios_ioctl(arg);
}

The driver is responsible for reinitializing the device with the correct settings. For this purpuse Termios calls the my_driver_set_attributes function.

static int my_driver_set_attributes(
    int minor,
    const struct termios *t
)
{
    my_driver_entry *e = &my_driver_table [minor];

    /*
     * There is no need to check the minor number since it is derived
     * from a file descriptor.  The upper layer takes care that it is
     * in a valid range.
     */

    /*
     * Inspect the termios data structure and configure the device
     * appropriately.  The driver should only be concerned with the
     * parts of the structure that specify hardware setting for the
     * communications channel such as baud, character size, etc.
     */

    return 0;
}


PREV UP next Bookshelf BSP and Device Driver Development Guide

Copyright © 1988-2008 OAR Corporation