SerialEndpoint

Struct SerialEndpoint 

Source
pub struct SerialEndpoint { /* private fields */ }
Expand description

Endpoint for serial connections

// get all available ports
let all_ports = SerialEndpoint::find_serial_ports();
 
// open connection
let endpoint = SerialEndpoint::from(all_ports, 115200);
endpoint.open().unwrap();
 
// send first message
// and read responses
endoint.write("$I").unwrap();
let response = endpoint.read_new_messages(Duration::from_millis(100));
 
// close connection after 
endpoint.close();

Implementations§

Source§

impl SerialEndpoint

Source

pub fn find_serial_ports() -> Vec<SerialPortInfo>

Returns list of all usb devices

Source

pub fn from(port_name: &str, baud_rate: u32) -> SerialEndpoint

Creates a new serial endpoint configuration

Source

pub fn write_sync(&mut self) -> Result<(), String>

Writes a sync command

Is required for issuing simulator commands

Trait Implementations§

Source§

impl Drop for SerialEndpoint

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Endpoint for SerialEndpoint

Source§

fn open(&mut self) -> Result<(), String>

Opens the serial connection and starts a new thread

Source§

fn close(&mut self) -> Result<(), String>

Closes exisiting serial connection

Source§

fn write(&mut self, message: &str) -> Result<(), String>

Writes the message to the device stream Read more
Source§

fn read_new_messages(&self, timeout: Duration) -> Vec<String>

Returns all received messages since last read call Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.