SerialPort

Struct SerialPort 

Source
pub struct SerialPort<R: Runtime>(pub PluginHandle<R>);
Expand description

Access to the serial port APIs for mobile platforms.

Tuple Fields§

§0: PluginHandle<R>

Implementations§

Source§

impl<R: Runtime> SerialPort<R>

Source

pub fn available_ports( &self, ) -> Result<HashMap<String, HashMap<String, String>>, Error>

Lists all available serial ports

Source

pub fn available_ports_direct( &self, ) -> Result<HashMap<String, HashMap<String, String>>, Error>

Lists all available serial ports using direct system commands

Source

pub fn managed_ports(&self) -> Result<Vec<String>, Error>

Lists all managed serial ports (ports that are currently open and managed by the application).

Source

pub fn open( &self, path: String, baud_rate: u32, data_bits: Option<DataBits>, flow_control: Option<FlowControl>, parity: Option<Parity>, stop_bits: Option<StopBits>, timeout: Option<u64>, ) -> Result<(), Error>

Opens a serial port with the specified settings

Source

pub fn close(&self, path: String) -> Result<(), Error>

Closes a serial port

Source

pub fn close_all(&self) -> Result<(), Error>

Closes all open serial ports

Source

pub fn force_close(&self, path: String) -> Result<(), Error>

Force closes a serial port

Source

pub fn write(&self, path: String, data: String) -> Result<usize, Error>

Writes data to the serial port

Source

pub fn write_binary(&self, path: String, data: Vec<u8>) -> Result<usize, Error>

Writes binary data to the serial port

Source

pub fn read( &self, path: String, timeout: Option<u64>, size: Option<usize>, ) -> Result<String, Error>

Reads data from the serial port

Source

pub fn read_binary( &self, path: String, timeout: Option<u64>, size: Option<usize>, ) -> Result<Vec<u8>, Error>

Reads data from the serial port

Source

pub fn start_listening( &self, path: String, timeout: Option<u64>, size: Option<usize>, ) -> Result<(), Error>

Starts listening for data on the serial port

Source

pub fn stop_listening(&self, path: String) -> Result<(), Error>

Stops listening for data on the serial port

Source

pub fn set_baud_rate(&self, path: String, baud_rate: u32) -> Result<(), Error>

Sets the baud rate for the serial port

Source

pub fn set_data_bits( &self, path: String, data_bits: DataBits, ) -> Result<(), Error>

Sets the data bits for the serial port

Source

pub fn set_flow_control( &self, path: String, flow_control: FlowControl, ) -> Result<(), Error>

Sets the flow control for the serial port

Source

pub fn set_parity(&self, path: String, parity: Parity) -> Result<(), Error>

Sets the parity for the serial port

Source

pub fn set_stop_bits( &self, path: String, stop_bits: StopBits, ) -> Result<(), Error>

Sets the stop bits for the serial port

Source

pub fn set_timeout(&self, path: String, timeout: Duration) -> Result<(), Error>

Sets the timeout for the serial port

Source

pub fn write_request_to_send( &self, path: String, level: bool, ) -> Result<(), Error>

Sets the RTS (Request To Send) signal

Source

pub fn write_data_terminal_ready( &self, path: String, level: bool, ) -> Result<(), Error>

Sets the DTR (Data Terminal Ready) signal

Source

pub fn cancel_read(&self, path: String) -> Result<(), Error>

Source

pub fn read_clear_to_send(&self, path: String) -> Result<bool, Error>

Reads the CTS (Clear To Send) signal state

Source

pub fn read_data_set_ready(&self, path: String) -> Result<bool, Error>

Reads the DSR (Data Set Ready) signal state

Source

pub fn read_ring_indicator(&self, path: String) -> Result<bool, Error>

Reads the RI (Ring Indicator) signal state

Source

pub fn read_carrier_detect(&self, path: String) -> Result<bool, Error>

Reads the CD (Carrier Detect) signal state

Source

pub fn bytes_to_read(&self, path: String) -> Result<u32, Error>

Gets the number of bytes available to read

Source

pub fn bytes_to_write(&self, path: String) -> Result<u32, Error>

Gets the number of bytes waiting to be written

Source

pub fn clear_buffer( &self, path: String, buffer_type: ClearBuffer, ) -> Result<(), Error>

Clears the specified buffer

Source

pub fn set_break(&self, path: String) -> Result<(), Error>

Sets the break signal

Source

pub fn clear_break(&self, path: String) -> Result<(), Error>

Clears the break signal

Auto Trait Implementations§

§

impl<R> Freeze for SerialPort<R>

§

impl<R> !RefUnwindSafe for SerialPort<R>

§

impl<R> Send for SerialPort<R>

§

impl<R> Sync for SerialPort<R>

§

impl<R> Unpin for SerialPort<R>

§

impl<R> !UnwindSafe for SerialPort<R>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,