DeviceConfig

Struct DeviceConfig 

Source
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

Source

pub fn new(addr: Ipv4Addr) -> DeviceConfig

默认参数,设备地址为 addr。

Trait Implementations§

Source§

impl Clone for DeviceConfig

Source§

fn clone(&self) -> DeviceConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.