pub struct SerialPort { /* private fields */ }
Expand description

A serial port and its various data and control registers.

TODO: use PortReadOnly and PortWriteOnly to set permissions for each register.

Implementations

Creates and returns a new serial port structure, and initializes that port using standard configuration parameters.

The configuration parameters used in this function are:

  • A baud rate of 38400.
  • “8N1” mode: data word length of 8 bits, with no parity and one stop bit.
  • FIFO buffer enabled with a threshold of 14 bytes.
  • Interrupts enabled for receiving bytes only (not transmitting).
Arguments

Note: if you are experiencing problems with serial port behavior, try enabling the loopback test part of this function to see if that passes.

Enable or disable interrupts on this serial port for various events.

Write the given string to the serial port, blocking until data can be transmitted.

Special characters

Because this function writes strings, it will transmit a carriage return '\r' after transmitting a line feed (new line) '\n' to ensure a proper new line.

Write the given byte to the serial port, blocking until data can be transmitted.

This writes the byte directly with no special cases, e.g., new lines.

Write the given bytes to the serial port, blocking until data can be transmitted.

This writes the bytes directly with no special cases, e.g., new lines.

Read one byte from the serial port, blocking until data is available.

Reads multiple bytes from the serial port into the given buffer, non-blocking.

The buffer will be filled with as many bytes as are available in the serial port. Once data is no longer available to be read, the read operation will stop.

If no data is immediately available on the serial port, this will read nothing and return 0.

Returns the number of bytes read into the given buffer.

Returns true if the serial port is ready to transmit a byte.

Returns true if the serial port has data available to read.

Trait Implementations

Executes the destructor for this type. Read more

Writes a string slice into this writer, returning whether the write succeeded. Read more

Writes a char into this writer, returning whether the write succeeded. Read more

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.