Struct mio_serial::SerialPort [] [src]

pub struct SerialPort { /* fields omitted */ }

A mio compatable serial port for *nix

Methods

impl SerialPort
[src]

Construct a new SerialPort

Opens the a serial port at the location provided by path with the following default settings:

  • 9600,8N1 (9600 Baud, 8-bit data, no parity, 1 stop bit)
  • Receiver enabled in "Cannonical mode"
  • Non-blocking
  • No flow control (software OR hardware)
  • Ignores hardware control lines

Errors

SerialPort construction can fail for a few reasons:

  • An invalid path is provided
  • The path does not represent a serial port device
  • We are unable to configure the serial port ANY of the default settings. (Unlikely... but IS possible)

Retrieve the termios structure for the serial port.

Set low-level serial port settings

The action parameter must be one of the following:

  • termios::TCSANOW Update immediately
  • termios::TCSADRAIN Finish reading buffered data before updating.
  • termios::TCSAFLUSH Finish writing buffered data before updating.

Errors

Will return ErrorKind::InvalidInput if action is not one of the three constants defined above.

Enable or disable blocking reads and writes.

Panics

Will panic if the underlying fcntl system call returns a value other than 0 or -1

Get the current blocking mode for the serial port

Panics

Will panic if the underlying fcntl system call returns a value other than 0 or -1

Try writing some data.

Similar to the standard io::Write implementation, but errors due to blocking IO are translated into Ok(None) results.

Returns

  • Ok(Some(size)) on successful writes
  • Ok(None) if calling write would block.
  • Err(e) for all other IO errors

Try reading some data.

Similar to the standard io::Read implementation, but errors due to blocking IO are translated into Ok(None) results.

Returns

  • Ok(Some(size)) on successful reads
  • Ok(None) if calling read would block.
  • Err(e) for all other IO errors

Set the serial baudrate

Valid baudrates are:

  • 0
  • 50
  • 75
  • 110
  • 134
  • 150
  • 200
  • 300
  • 600
  • 1200
  • 1800
  • 2400
  • 4800
  • 9600
  • 19200
  • 38400

Errors

Returns an io::ErrorKind::InvalidInput for baud rates no in the list above.

Get the serial baudrate

Valid baudrates are:

  • 0
  • 50
  • 75
  • 110
  • 134
  • 150
  • 200
  • 300
  • 600
  • 1200
  • 1800
  • 2400
  • 4800
  • 9600
  • 19200
  • 38400

Errors

Returns an io::ErrorKind::InvalidInput for baud rates no in the list above.

Enable or disable raw mode

In raw mode, input is available character by character, echoing is disabled, and all special processing of terminal input and output characters is disabled.

Return if raw mode is enabled or not.

Trait Implementations

impl Drop for SerialPort
[src]

A method called when the value goes out of scope. Read more

impl AsRawFd for SerialPort
[src]

Extracts the raw file descriptor. Read more

impl Read for SerialPort
[src]

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a "by reference" adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Unstable (io)

: the semantics of a partial read/write of where errors happen is currently unclear and may change

Transforms this Read instance to an Iterator over chars. Read more

Creates an adaptor which will chain this stream with another. Read more

Creates an adaptor which will read at most limit bytes from it. Read more

impl Write for SerialPort
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Attempts to write an entire buffer into this write. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more

impl Evented for SerialPort
[src]