pub struct SerialConfig {
pub baud_rate: u32,
pub data_bits: DataBits,
pub stop_bits: StopBits,
pub parity: Parity,
pub flow_control: FlowControl,
pub read_timeout: Duration,
pub write_timeout: Duration,
}Expand description
串口配置
Fields§
§baud_rate: u32波特率(默认 9600)
data_bits: DataBits数据位
stop_bits: StopBits停止位
parity: Parity校验位
flow_control: FlowControl流控制
read_timeout: Duration读取超时
write_timeout: Duration写入超时
Implementations§
Source§impl SerialConfig
impl SerialConfig
Sourcepub fn builder() -> SerialConfigBuilder
pub fn builder() -> SerialConfigBuilder
创建构建器
Sourcepub fn with_baud_rate(self, baud_rate: u32) -> Self
pub fn with_baud_rate(self, baud_rate: u32) -> Self
设置波特率
Sourcepub fn with_data_bits(self, data_bits: DataBits) -> Self
pub fn with_data_bits(self, data_bits: DataBits) -> Self
设置数据位
Sourcepub fn with_stop_bits(self, stop_bits: StopBits) -> Self
pub fn with_stop_bits(self, stop_bits: StopBits) -> Self
设置停止位
Sourcepub fn with_parity(self, parity: Parity) -> Self
pub fn with_parity(self, parity: Parity) -> Self
设置校验位
Sourcepub fn with_flow_control(self, flow_control: FlowControl) -> Self
pub fn with_flow_control(self, flow_control: FlowControl) -> Self
设置流控制
Sourcepub fn with_read_timeout_ms(self, ms: u64) -> Self
pub fn with_read_timeout_ms(self, ms: u64) -> Self
设置读取超时(毫秒)
Sourcepub fn with_write_timeout_ms(self, ms: u64) -> Self
pub fn with_write_timeout_ms(self, ms: u64) -> Self
设置写入超时(毫秒)
Sourcepub fn with_timeout_ms(self, ms: u64) -> Self
pub fn with_timeout_ms(self, ms: u64) -> Self
设置统一超时(毫秒)
Sourcepub fn preset_115200_8n1() -> Self
pub fn preset_115200_8n1() -> Self
115200 8N1 配置(常用于调试)
Sourcepub fn preset_9600_8n1() -> Self
pub fn preset_9600_8n1() -> Self
9600 8N1 配置(标准)
Sourcepub fn preset_57600_8n1() -> Self
pub fn preset_57600_8n1() -> Self
57600 8N1 配置
Sourcepub fn preset_38400_8n1() -> Self
pub fn preset_38400_8n1() -> Self
38400 8N1 配置
Sourcepub fn preset_19200_8n1() -> Self
pub fn preset_19200_8n1() -> Self
19200 8N1 配置
Trait Implementations§
Source§impl Clone for SerialConfig
impl Clone for SerialConfig
Source§fn clone(&self) -> SerialConfig
fn clone(&self) -> SerialConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SerialConfig
impl Debug for SerialConfig
Auto Trait Implementations§
impl Freeze for SerialConfig
impl RefUnwindSafe for SerialConfig
impl Send for SerialConfig
impl Sync for SerialConfig
impl Unpin for SerialConfig
impl UnwindSafe for SerialConfig
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