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>
impl<R: Runtime> SerialPort<R>
Sourcepub fn available_ports(
&self,
) -> Result<HashMap<String, HashMap<String, String>>, Error>
pub fn available_ports( &self, ) -> Result<HashMap<String, HashMap<String, String>>, Error>
Lists all available serial ports
Sourcepub fn available_ports_direct(
&self,
) -> Result<HashMap<String, HashMap<String, String>>, Error>
pub fn available_ports_direct( &self, ) -> Result<HashMap<String, HashMap<String, String>>, Error>
Lists all available serial ports using direct system commands
Sourcepub fn managed_ports(&self) -> Result<Vec<String>, Error>
pub fn managed_ports(&self) -> Result<Vec<String>, Error>
Lists all managed serial ports (ports that are currently open and managed by the application).
Sourcepub 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>
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
Sourcepub fn write(&self, path: String, data: String) -> Result<usize, Error>
pub fn write(&self, path: String, data: String) -> Result<usize, Error>
Writes data to the serial port
Sourcepub fn write_binary(&self, path: String, data: Vec<u8>) -> Result<usize, Error>
pub fn write_binary(&self, path: String, data: Vec<u8>) -> Result<usize, Error>
Writes binary data to the serial port
Sourcepub fn read(
&self,
path: String,
timeout: Option<u64>,
size: Option<usize>,
) -> Result<String, Error>
pub fn read( &self, path: String, timeout: Option<u64>, size: Option<usize>, ) -> Result<String, Error>
Reads data from the serial port
Sourcepub fn read_binary(
&self,
path: String,
timeout: Option<u64>,
size: Option<usize>,
) -> Result<Vec<u8>, Error>
pub fn read_binary( &self, path: String, timeout: Option<u64>, size: Option<usize>, ) -> Result<Vec<u8>, Error>
Reads data from the serial port
Sourcepub fn start_listening(
&self,
path: String,
timeout: Option<u64>,
size: Option<usize>,
) -> Result<(), Error>
pub fn start_listening( &self, path: String, timeout: Option<u64>, size: Option<usize>, ) -> Result<(), Error>
Starts listening for data on the serial port
Sourcepub fn stop_listening(&self, path: String) -> Result<(), Error>
pub fn stop_listening(&self, path: String) -> Result<(), Error>
Stops listening for data on the serial port
Sourcepub fn set_baud_rate(&self, path: String, baud_rate: u32) -> Result<(), Error>
pub fn set_baud_rate(&self, path: String, baud_rate: u32) -> Result<(), Error>
Sets the baud rate for the serial port
Sourcepub fn set_data_bits(
&self,
path: String,
data_bits: DataBits,
) -> Result<(), Error>
pub fn set_data_bits( &self, path: String, data_bits: DataBits, ) -> Result<(), Error>
Sets the data bits for the serial port
Sourcepub fn set_flow_control(
&self,
path: String,
flow_control: FlowControl,
) -> Result<(), Error>
pub fn set_flow_control( &self, path: String, flow_control: FlowControl, ) -> Result<(), Error>
Sets the flow control for the serial port
Sourcepub fn set_parity(&self, path: String, parity: Parity) -> Result<(), Error>
pub fn set_parity(&self, path: String, parity: Parity) -> Result<(), Error>
Sets the parity for the serial port
Sourcepub fn set_stop_bits(
&self,
path: String,
stop_bits: StopBits,
) -> Result<(), Error>
pub fn set_stop_bits( &self, path: String, stop_bits: StopBits, ) -> Result<(), Error>
Sets the stop bits for the serial port
Sourcepub fn set_timeout(&self, path: String, timeout: Duration) -> Result<(), Error>
pub fn set_timeout(&self, path: String, timeout: Duration) -> Result<(), Error>
Sets the timeout for the serial port
Sourcepub fn write_request_to_send(
&self,
path: String,
level: bool,
) -> Result<(), Error>
pub fn write_request_to_send( &self, path: String, level: bool, ) -> Result<(), Error>
Sets the RTS (Request To Send) signal
Sourcepub fn write_data_terminal_ready(
&self,
path: String,
level: bool,
) -> Result<(), Error>
pub fn write_data_terminal_ready( &self, path: String, level: bool, ) -> Result<(), Error>
Sets the DTR (Data Terminal Ready) signal
pub fn cancel_read(&self, path: String) -> Result<(), Error>
Sourcepub fn read_clear_to_send(&self, path: String) -> Result<bool, Error>
pub fn read_clear_to_send(&self, path: String) -> Result<bool, Error>
Reads the CTS (Clear To Send) signal state
Sourcepub fn read_data_set_ready(&self, path: String) -> Result<bool, Error>
pub fn read_data_set_ready(&self, path: String) -> Result<bool, Error>
Reads the DSR (Data Set Ready) signal state
Sourcepub fn read_ring_indicator(&self, path: String) -> Result<bool, Error>
pub fn read_ring_indicator(&self, path: String) -> Result<bool, Error>
Reads the RI (Ring Indicator) signal state
Sourcepub fn read_carrier_detect(&self, path: String) -> Result<bool, Error>
pub fn read_carrier_detect(&self, path: String) -> Result<bool, Error>
Reads the CD (Carrier Detect) signal state
Sourcepub fn bytes_to_read(&self, path: String) -> Result<u32, Error>
pub fn bytes_to_read(&self, path: String) -> Result<u32, Error>
Gets the number of bytes available to read
Sourcepub fn bytes_to_write(&self, path: String) -> Result<u32, Error>
pub fn bytes_to_write(&self, path: String) -> Result<u32, Error>
Gets the number of bytes waiting to be written
Sourcepub fn clear_buffer(
&self,
path: String,
buffer_type: ClearBuffer,
) -> Result<(), Error>
pub fn clear_buffer( &self, path: String, buffer_type: ClearBuffer, ) -> Result<(), Error>
Clears the specified buffer