pub struct DeviceConfig {
pub addr: Ipv4Addr,
pub ctrl_port: u16,
pub data_port: u16,
pub host_port: u16,
pub set_host: bool,
pub reg_timeout: Duration,
pub reg_retries: u32,
pub recv_buffer: usize,
}Expand description
连接参数。用 DeviceConfig::new 取默认值,再按需修改字段。
Fields§
§addr: Ipv4Addr设备 IP,出厂默认 192.168.1.128。
ctrl_port: u16设备控制端口(寄存器访问),默认 5001。
data_port: u16设备数据端口(数据和心跳的源端口,ACK / NACK 的目的端口),默认 5000。
host_port: u16本机接收数据的 UDP 端口,默认 5000;0 表示由系统分配。
端口被占用时(Windows 上表现为“拒绝访问“)换一个,例如 15500。
set_host: bool打开时把设备的“上位机 IP“和“主机端口“寄存器写成本机地址和 host_port,默认 true。
设为 false 时不改设备配置,本机必须正好是设备里配置的上位机(默认 192.168.1.100:5000)。
设备正在采集时不改(否则正在接收的主机会收不到余下的数据);这时打开的连接可以查询状态,启动则返回
Error::Busy,等运行结束后重新打开即可。
reg_timeout: Duration一次寄存器请求等待应答的时间,默认 200 ms。
reg_retries: u32寄存器请求超时后的重发次数,默认 8。
recv_buffer: usize数据套接字的接收缓冲大小(字节),默认 64 MB。Linux 上受 net.core.rmem_max 限制。
Implementations§
Source§impl DeviceConfig
impl DeviceConfig
Sourcepub fn new(addr: Ipv4Addr) -> DeviceConfig
pub fn new(addr: Ipv4Addr) -> DeviceConfig
默认参数,设备地址为 addr。
Trait Implementations§
Source§impl Clone for DeviceConfig
impl Clone for DeviceConfig
Source§fn clone(&self) -> DeviceConfig
fn clone(&self) -> DeviceConfig
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 moreAuto Trait Implementations§
impl Freeze for DeviceConfig
impl RefUnwindSafe for DeviceConfig
impl Send for DeviceConfig
impl Sync for DeviceConfig
impl Unpin for DeviceConfig
impl UnwindSafe for DeviceConfig
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