Module capsules::console [] [src]

Provides userspace with access to a serial interface.

Setup

You need a device that provides the hil::uart::UART trait.

let console = static_init!(
    Console<usart::USART>,
    Console::new(&usart::USART0,
                 115200,
                 &mut console::WRITE_BUF,
                 kernel::Grant::create()));
hil::uart::UART::set_client(&usart::USART0, console);

Usage

Currently, only writing buffers to the serial device is implemented.

The user must perform three steps in order to write a buffer:

// (Optional) Set a callback to be invoked when the buffer has been written
subscribe(CONSOLE_DRIVER_NUM, 1, my_callback);
// Share the buffer from userspace with the driver
allow(CONSOLE_DRIVER_NUM, buffer, buffer_len_in_bytes);
// Initiate the transaction
command(CONSOLE_DRIVER_NUM, 1, len_to_write_in_bytes)

When the buffer has been written successfully, the buffer is released from the driver. Successive writes must call allow each time a buffer is to be written.

Reexports

use core::cell::Cell;
use core::cmp;
use kernel::AppId;
use kernel::AppSlice;
use kernel::Callback;
use kernel::Driver;
use kernel::Grant;
use kernel::ReturnCode;
use kernel::Shared;
use kernel::common::take_cell::TakeCell;
use kernel::hil::uart;
use kernel::hil::uart::Client;
use kernel::hil::uart::UART;
use kernel::process::Error;

Structs

App
Console

Constants

DRIVER_NUM

Syscall driver number.

Statics

WRITE_BUF