pub struct GigeDevice { /* private fields */ }Expand description
GVCP device handle.
Implementations§
Source§impl GigeDevice
impl GigeDevice
Sourcepub async fn open(addr: SocketAddr) -> Result<Self, GigeError>
pub async fn open(addr: SocketAddr) -> Result<Self, GigeError>
Connect to a device GVCP endpoint.
The connection is ready for register read/write but does not claim
control privilege. Call Self::claim_control before configuring streaming
or starting acquisition.
Sourcepub async fn claim_control(&mut self) -> Result<(), GigeError>
pub async fn claim_control(&mut self) -> Result<(), GigeError>
Claim control channel privilege (CCP).
Required by the GigE Vision specification before the device accepts stream configuration or acquisition commands.
Sourcepub async fn release_control(&mut self) -> Result<(), GigeError>
pub async fn release_control(&mut self) -> Result<(), GigeError>
Release control channel privilege.
Sourcepub async fn heartbeat_timeout_ms(&mut self) -> Result<u32, GigeError>
pub async fn heartbeat_timeout_ms(&mut self) -> Result<u32, GigeError>
Read GevHeartbeatTimeout (milliseconds).
This is how long the device will keep control privilege granted with no GVCP command from the controlling application.
Sourcepub async fn ping_control_channel(&mut self) -> Result<bool, GigeError>
pub async fn ping_control_channel(&mut self) -> Result<bool, GigeError>
Refresh the device’s heartbeat timer, and report whether this application still holds control privilege.
Any GVCP command resets the timer, so this reads CCP rather than writing
it: a read is idempotent, and its value doubles as the answer to “does
the device still consider us the controller?”. A device that revoked
privilege — because an earlier heartbeat was lost, or because another
application took control — is reported as Ok(false) here instead of
failing the next configuration write with ACCESS_DENIED.
Losing privilege is not a transport failure, so it is not an Err: the
register read succeeded and the answer is simply “no”. Err means the
command itself did not complete.
Sourcepub fn remote_addr(&self) -> SocketAddr
pub fn remote_addr(&self) -> SocketAddr
Return the remote GVCP socket address associated with this device.
Sourcepub async fn read_register(&mut self, addr: u32) -> Result<u32, GigeError>
pub async fn read_register(&mut self, addr: u32) -> Result<u32, GigeError>
Read a single 32-bit bootstrap or device register.
Uses GVCP READREG format: 4-byte register address. The acknowledgement carries the 4-byte register value.
Sourcepub async fn write_register(
&mut self,
addr: u32,
value: u32,
) -> Result<(), GigeError>
pub async fn write_register( &mut self, addr: u32, value: u32, ) -> Result<(), GigeError>
Write a single 32-bit bootstrap or device register.
Uses GVCP WRITEREG format: 4-byte register address + 4-byte value. The acknowledgement carries a 4-byte data index placeholder.
Sourcepub async fn read_mem(
&mut self,
addr: u64,
len: usize,
) -> Result<Vec<u8>, GigeError>
pub async fn read_mem( &mut self, addr: u64, len: usize, ) -> Result<Vec<u8>, GigeError>
Read a block of memory from the remote device with chunking and retries.
Uses GVCP READMEM format: 4-byte address + 2-byte reserved + 2-byte count. The acknowledgement carries: 4-byte address echo + data bytes.
Sourcepub async fn write_mem(
&mut self,
addr: u64,
data: &[u8],
) -> Result<(), GigeError>
pub async fn write_mem( &mut self, addr: u64, data: &[u8], ) -> Result<(), GigeError>
Write a block of memory to the remote device with chunking and retries.
Uses GVCP WRITEMEM format: 4-byte address + data bytes. The acknowledgement carries: 4-byte reserved (index).
Sourcepub async fn set_message_destination(
&mut self,
ip: Ipv4Addr,
port: u16,
) -> Result<(), GigeError>
pub async fn set_message_destination( &mut self, ip: Ipv4Addr, port: u16, ) -> Result<(), GigeError>
Configure the message channel destination address/port.
Sourcepub async fn set_stream_destination(
&mut self,
channel: u32,
ip: Ipv4Addr,
port: u16,
) -> Result<(), GigeError>
pub async fn set_stream_destination( &mut self, channel: u32, ip: Ipv4Addr, port: u16, ) -> Result<(), GigeError>
Configure the GVSP host destination for the provided channel.
Sourcepub async fn set_stream_packet_size(
&mut self,
channel: u32,
packet_size: u32,
) -> Result<(), GigeError>
pub async fn set_stream_packet_size( &mut self, channel: u32, packet_size: u32, ) -> Result<(), GigeError>
Configure the packet size for the stream channel.
Only bits 0-15 of GevSCPSPacketSize hold the size; the high bits are
reserved for the fire-test-packet and do-not-fragment flags. A larger
value is refused rather than truncated, because truncation is silent and
arrives as a stream that never completes a frame — writing 70 000 would
configure 4 464.
Sourcepub async fn request_test_packet(
&mut self,
channel: u32,
packet_size: u32,
) -> Result<(), GigeError>
pub async fn request_test_packet( &mut self, channel: u32, packet_size: u32, ) -> Result<(), GigeError>
Ask the device to emit one GVSP test packet of packet_size bytes.
Writes GevSCPSPacketSize with bit 31 (fire test packet) and bit 30
(do not fragment) set. The size lands in the register as usual; the
flags do not, and a device that echoed them back would report a packet
size of over a billion, so GigeDevice::get_stream_packet_size masks.
This does not wait for the packet — it arrives on the stream channel, which this type does not own. The caller listens.
Sourcepub async fn get_stream_packet_size(
&mut self,
channel: u32,
) -> Result<u32, GigeError>
pub async fn get_stream_packet_size( &mut self, channel: u32, ) -> Result<u32, GigeError>
Read GevSCPSPacketSize back and return the size the device holds.
A device is free to clamp a requested packet size to what it supports, and the request succeeds when it does — nothing on the wire distinguishes “accepted” from “accepted and reduced”. Until the receive path follows the effective value it reassembles at the wrong pitch and no frame ever completes (#112, backlog SR-02).
Deliberately a GVCP READREG rather than a GenApi node read: the write
side bypasses the NodeMap, so a cached GevSCPSPacketSize node can
report the pre-write value and turn this check into a second bug.
Sourcepub async fn set_stream_packet_delay(
&mut self,
channel: u32,
packet_delay: u32,
) -> Result<(), GigeError>
pub async fn set_stream_packet_delay( &mut self, channel: u32, packet_delay: u32, ) -> Result<(), GigeError>
Configure the packet delay (GevSCPD).
Sourcepub async fn negotiate_stream(
&mut self,
channel: u32,
iface: &Iface,
port: u16,
target_mtu: Option<u32>,
) -> Result<StreamParams, GigeError>
pub async fn negotiate_stream( &mut self, channel: u32, iface: &Iface, port: u16, target_mtu: Option<u32>, ) -> Result<StreamParams, GigeError>
Negotiate GVSP parameters with the device given the host interface.
Sourcepub async fn read_persistent_ip(
&mut self,
) -> Result<(Ipv4Addr, Ipv4Addr, Ipv4Addr), GigeError>
pub async fn read_persistent_ip( &mut self, ) -> Result<(Ipv4Addr, Ipv4Addr, Ipv4Addr), GigeError>
Read the persistent IP configuration from the device.
Returns (ip, subnet, gateway).
Sourcepub async fn write_persistent_ip(
&mut self,
ip: Ipv4Addr,
subnet: Ipv4Addr,
gateway: Ipv4Addr,
) -> Result<(), GigeError>
pub async fn write_persistent_ip( &mut self, ip: Ipv4Addr, subnet: Ipv4Addr, gateway: Ipv4Addr, ) -> Result<(), GigeError>
Write the persistent IP configuration to the device.
Sourcepub async fn enable_persistent_ip(&mut self) -> Result<(), GigeError>
pub async fn enable_persistent_ip(&mut self) -> Result<(), GigeError>
Enable persistent IP mode in the device configuration flags.
Sets bit 1 (persistent IP) in the CurrentIPConfiguration register.