pub struct SerialTransport { /* private fields */ }Expand description
Serial port transport for USB CDC ACM and Bluetooth SPP connections.
Port naming by platform:
- Linux:
/dev/ttyACM*(USB),/dev/rfcomm*(BT) - macOS:
/dev/cu.usbmodem*(USB),/dev/cu.TH-D75(BT) - Windows:
COM*for both
Implementations§
Source§impl SerialTransport
impl SerialTransport
Sourcepub const DEFAULT_BAUD: u32 = 115_200
pub const DEFAULT_BAUD: u32 = 115_200
Default baud rate for USB CDC ACM.
Sourcepub fn is_bluetooth_port(path: &str) -> bool
pub fn is_bluetooth_port(path: &str) -> bool
Returns true if the port path looks like a Bluetooth SPP device.
Sourcepub fn open(path: &str, baud: u32) -> Result<Self, TransportError>
pub fn open(path: &str, baud: u32) -> Result<Self, TransportError>
Open a serial port by path.
Bluetooth SPP ports are auto-detected by name and configured with 9600 baud and RTS/CTS flow control. USB ports use the provided baud rate with no flow control.
§Errors
Returns TransportError::Open if the port cannot be opened.
Sourcepub fn discover_usb() -> Result<Vec<SerialPortInfo>, TransportError>
pub fn discover_usb() -> Result<Vec<SerialPortInfo>, TransportError>
Discover TH-D75 radios connected via USB.
Filters available serial ports by VID:PID 2166:9023.
§Errors
Returns TransportError::Open if port enumeration fails.
Sourcepub fn discover_bluetooth() -> Result<Vec<SerialPortInfo>, TransportError>
pub fn discover_bluetooth() -> Result<Vec<SerialPortInfo>, TransportError>
Discover TH-D75 radios available via Bluetooth SPP.
Looks for serial ports matching known BT naming patterns.
§Errors
Returns TransportError::Open if port enumeration fails.
Trait Implementations§
Source§impl Debug for SerialTransport
impl Debug for SerialTransport
Source§impl Transport for SerialTransport
impl Transport for SerialTransport
Source§fn set_baud_rate(&mut self, baud: u32) -> Result<(), TransportError>
fn set_baud_rate(&mut self, baud: u32) -> Result<(), TransportError>
Change the transport baud rate. Read more
Source§async fn write(&mut self, data: &[u8]) -> Result<(), TransportError>
async fn write(&mut self, data: &[u8]) -> Result<(), TransportError>
Send raw bytes to the radio.
Auto Trait Implementations§
impl Freeze for SerialTransport
impl !RefUnwindSafe for SerialTransport
impl Send for SerialTransport
impl Sync for SerialTransport
impl Unpin for SerialTransport
impl !UnwindSafe for SerialTransport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more