[][src]Struct teensyduino::serial::USBSerial

pub struct USBSerial {}

A serial USB connection to a host device. Based off of the Arduino Serial class. Do not create an instance of this, instad use the provided SERIAL static

See Also

Implementations

impl USBSerial[src]

pub fn set_timeout(timeout: u32)[src]

Set the serial read in timeout

pub fn avaliable() -> usize[src]

Get the number of bytes (characters) available for reading from the serial port. This is data that’s already arrived and stored in the serial receive buffer

See Also

pub fn available_for_write() -> usize[src]

Get the number of bytes (characters) available for writing in the serial buffer without blocking the write operation.

See Also

pub fn clear()[src]

Clear the input buffer

pub fn send_now()[src]

Transmit any buffered data as soon as possible. Sometimes referred to as flush().

pub fn peek() -> Option<char>[src]

Returns the next byte (character) of incoming serial data without removing it from the internal serial buffer. That is, successive calls to peek() will return the same character, as will the next call to read().

See Also

pub fn baud() -> u32[src]

Read the baud rate setting from the PC or Mac. Communication is always performed at full USB speed. The baud rate is useful if you intend to make a USB to serial bridge, where you need to know what speed the PC intends the serial communication to use.

pub fn stop_bits() -> u8[src]

Read the stop bits setting from the PC or Mac. USB never uses stop bits.

pub fn parity_type() -> Parity[src]

Read the parity type setting from the PC or Mac. USB uses CRC checking on all bulk mode data packets and automatically retransmits corrupted data, so parity bits are never used.

pub fn num_bits() -> u8[src]

Read the number of bits setting from the PC or Mac. USB always communicates 8 bit bytes.

pub fn dtr() -> bool[src]

Read the DTR signal state. By default, DTR is low when no software has the serial device open, and it goes high when a program opens the port. Some programs override this behavior, but for normal software you can use DTR to know when a program is using the serial port.

pub fn rts() -> bool[src]

Read the RTS signal state. USB includes flow control automatically, so you do not need to read this bit to know if the PC is ready to receive your data. No matter how fast you transmit, USB always manages buffers so all data is delivered reliably. However, you can cause excessive CPU usage by the receiving program is a GUI-based java application like the Arduino serial monitior!

For programs that use RTS to signal some useful information, you can read it with this function.

pub fn read_bytes_timeout(buffer: &mut [u8]) -> usize[src]

Read in the bytes from a serial buffer for the duration of the timeout, or until the buffer is full

pub fn read_bytes(buffer: &mut [u8]) -> usize[src]

Read in the bytes from the serial buffer in one shot without a timeout

pub fn read_str_timeout() -> Result<Option<&'static str>, Utf8Error>[src]

Read in a string from the usb buffer with retrying to fill the buffer all the way (max 256 bytes)

pub fn read_str() -> Result<Option<&'static str>, Utf8Error>[src]

Read in a string from the usb buffer without retrying to fill the buffer all the way (max 256 bytes)

pub fn read() -> Option<char>[src]

Read in one char of data from the serial port

pub fn write_char(c: char) -> bool[src]

Write a single char out onto the serial port, returning if the write was successful or not

pub fn write(string: &str) -> usize[src]

Write a whole string out onto the serial port, returning the amount of bytes successfully written out

Auto Trait Implementations

impl Send for USBSerial

impl Sync for USBSerial

impl Unpin for USBSerial

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.