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 fn set_control_timeout(&mut self, timeout: Duration)
pub fn set_control_timeout(&mut self, timeout: Duration)
Set the acknowledgement timeout per control transaction attempt.
Applies to register/memory access, control privilege and packet resend. PENDING_ACK may extend this wait, but never shorten it. Automatic retries retain their existing limit. Zero requests an immediate timeout.
Sourcepub fn control_timeout(&self) -> Duration
pub fn control_timeout(&self) -> Duration
Return the acknowledgement timeout per control transaction attempt.
Sourcepub fn set_inflight_keepalive_period(&mut self, period: Option<Duration>)
pub fn set_inflight_keepalive_period(&mut self, period: Option<Duration>)
Configure control-channel probes while a transaction waits for its ACK.
After this much silence on the socket, send an idempotent CCP read using the same source port and a separate request ID. Probe replies are drained without extending the original transaction’s deadline. Use a period comfortably shorter than the device’s heartbeat timeout.
None or a zero period disables the probes (the default). This handles
in-flight requests only; an idle connection still needs a keepalive.
Sourcepub fn inflight_keepalive_period(&self) -> Option<Duration>
pub fn inflight_keepalive_period(&self) -> Option<Duration>
The in-flight heartbeat period, None while they are off.
Sourcepub fn use_memory_access(&mut self)
pub fn use_memory_access(&mut self)
Send every single-register access as READMEM/WRITEMEM from now on.
What FORCE_READMEM_ENV does at open, for a caller that knows its
device better than the environment does. There is no way back within
the session, as there is none from the automatic fallback.
Sourcepub fn memory_access_only(&self) -> bool
pub fn memory_access_only(&self) -> bool
Whether single-register access currently goes out as READMEM/WRITEMEM.
Sourcepub fn set_exclusive_access(&mut self, exclusive: bool)
pub fn set_exclusive_access(&mut self, exclusive: bool)
Ask for exclusive access (CCP 0x1, bit 31 in GigE Vision’s
numbering: no other application may even read) instead of control
access (0x2) whenever this session claims control, the first claim
and every later one alike.
Sourcepub fn exclusive_access(&self) -> bool
pub fn exclusive_access(&self) -> bool
Whether Self::claim_control asks for exclusive access.
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.
Asks for control access (CCP 0x2), or exclusive access (0x1) once
Self::set_exclusive_access says so. That bit alone is what the
GigE Vision bit definitions call exclusive access; no camera has yet
confirmed it, and aravis never writes it.
Sourcepub async fn release_control(&mut self) -> Result<(), GigeError>
pub async fn release_control(&mut self) -> Result<(), GigeError>
Release control channel privilege.
Sourcepub fn try_send_release(&mut self) -> Result<()>
pub fn try_send_release(&mut self) -> Result<()>
Send the release of control privilege (CCP ← 0) without waiting for its acknowledgement, and without a runtime to wait on.
For a caller that cannot block — a Drop on a current-thread runtime’s
own thread. Best effort: a lost datagram leaves the device to time the
privilege out. Prefer Self::release_control.
Sent as WRITEMEM once the session uses memory access
(Self::memory_access_only), as every other register write is: a
device that refuses WRITEREG would refuse the release too. Both
commands carry the same eight bytes, the address and then the value.
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.
CCP alone cannot tell this application from another that took control
after an expired heartbeat: both read as controlled. Where GVCP
Capability says the device names its primary application (bit
0x0800_0000), its IP and port are compared with this socket’s too
(backlog TC-38).
Sourcepub async fn holds_control(&mut self) -> Result<bool, GigeError>
pub async fn holds_control(&mut self) -> Result<bool, GigeError>
Whether this application holds control privilege, asked after the
device refused one of its writes with ACCESS_DENIED, which a
register may also answer for reasons of its own.
Self::ping_control_channel first. Where the device does not name
its primary application, CCP reads as controlled whoever holds it,
so the answer comes from claiming again (CCP ← this session’s
privilege): a device takes the claim from the application that holds
control and refuses it to any other with ACCESS_DENIED. An Allied
Vision Manta G-125B, which does not name its primary application,
did both (backlog TC-38). The claim changes nothing for the holder,
and nothing for another application, whose control the device keeps.
Sourcepub fn remote_addr(&self) -> SocketAddr
pub fn remote_addr(&self) -> SocketAddr
Return the remote GVCP socket address associated with this device.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
The local address and port commands leave from: what the device knows this application by.
Sourcepub async fn read_register_or_mem(
&mut self,
addr: u64,
len: usize,
) -> Result<Vec<u8>, GigeError>
pub async fn read_register_or_mem( &mut self, addr: u64, len: usize, ) -> Result<Vec<u8>, GigeError>
Read len bytes at addr, as READREG when that is exactly one
register and READMEM otherwise.
The READREG value is returned big-endian, which is byte-for-byte what READMEM returns for the same word: GVCP carries both in network order, and interpreting the bytes is GenApi’s job, not the transport’s.
A device that answers READREG with NOT_IMPLEMENTED, or does not
answer it at all, is switched to READMEM for the rest of the session
and this access is retried there, so the caller still gets its value.
Any other refusal — ACCESS_DENIED, BAD_ALIGNMENT — is the device’s
real answer about this register and is returned as it is.
Sourcepub async fn write_register_or_mem(
&mut self,
addr: u64,
data: &[u8],
) -> Result<(), GigeError>
pub async fn write_register_or_mem( &mut self, addr: u64, data: &[u8], ) -> Result<(), GigeError>
Write data at addr, as WRITEREG when that is exactly one register
and WRITEMEM otherwise.
Falls back to WRITEMEM exactly as Self::read_register_or_mem falls
back to READMEM. After a WRITEREG that got no reply the write is sent
again as WRITEMEM; a device that did execute the first one but lost
the acknowledgement sees it twice, which is the same exposure the
command retry loop already has.
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 register with READREG, unconditionally.
Uses GVCP READREG format: 4-byte register address. The acknowledgement carries the 4-byte register value.
No fallback: prefer Self::read_register_or_mem, which picks the
command and honours a device that does not implement this one.
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 register with WRITEREG, unconditionally.
Uses GVCP WRITEREG format: 4-byte register address + 4-byte value. The acknowledgement carries a 4-byte data index placeholder.
No fallback: prefer Self::write_register_or_mem.
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).
GVCP carries whole 32-bit words at 32-bit aligned addresses, as
READMEM does (#35). A write that starts or ends inside a word — a
one-byte register, a two-byte one at an odd half-word — goes out as
the words around it, the bytes it does not cover read from the device
first, so neighbouring registers keep their values (TC-32). aravis
pads such a write with whatever its buffer held
(arv_gvcp_packet_new_write_memory_cmd). If the read is refused, the
write goes out as given, for the device to judge.
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 stream_destination(
&mut self,
channel: u32,
) -> Result<(Ipv4Addr, u16), GigeError>
pub async fn stream_destination( &mut self, channel: u32, ) -> Result<(Ipv4Addr, u16), GigeError>
Read where stream channel channel sends: GevSCDA and the port in
the low half of GevSCPHostPort. A multicast group here is how a
camera streams to several hosts at once.
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.
The flags the register holds are kept: an Allied Vision Manta G-125B
stores do-not-fragment and reads it back (0x400005DC), and a write
of the size alone cleared it. A register that cannot be read first is
written with the size alone.
Sourcepub async fn stream_do_not_fragment(
&mut self,
channel: u32,
) -> Result<bool, GigeError>
pub async fn stream_do_not_fragment( &mut self, channel: u32, ) -> Result<bool, GigeError>
Whether GevSCPSPacketSize holds the do-not-fragment flag (bit 30).
Sourcepub async fn set_stream_do_not_fragment(
&mut self,
channel: u32,
on: bool,
) -> Result<(), GigeError>
pub async fn set_stream_do_not_fragment( &mut self, channel: u32, on: bool, ) -> Result<(), GigeError>
Set or clear GevSCPSPacketSize’s do-not-fragment flag, keeping the
size: how the packet-size probe, whose test packets set it, gives it
back as it found it.
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 register read 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 gvcp_capability(&mut self) -> Result<GvcpCapability, GigeError>
pub async fn gvcp_capability(&mut self) -> Result<GvcpCapability, GigeError>
Read GVCP Capability (0x0934): which optional commands the device
implements.
Sourcepub async fn enable_pending_ack(&mut self) -> Result<bool, GigeError>
pub async fn enable_pending_ack(&mut self) -> Result<bool, GigeError>
Switch PENDING_ACK on, if GVCP Capability says the device has it:
set its enable bit (0x2) in GVCP Configuration (0x0954), keeping
the others. Returns whether it is on.
A device sends PENDING_ACK only once enabled. Without it, a command
that takes longer than the acknowledgement timeout — a flash write, a
mode change — is retried as though lost, and may run twice. A write,
so it needs control privilege.
Sourcepub async fn stream_channel_count(&mut self) -> Result<u32, GigeError>
pub async fn stream_channel_count(&mut self) -> Result<u32, GigeError>
Read GevNumberOfStreamChannels (0x0904).
Sourcepub async fn timestamp_tick_frequency(&mut self) -> Result<u64, GigeError>
pub async fn timestamp_tick_frequency(&mut self) -> Result<u64, GigeError>
Read the timestamp tick frequency in hertz (0x093C high, 0x0940
low): the unit of device timestamps and of GevSCPD. A device without
a timestamp clock reports 0.
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>
Write GevSCPD, the delay between stream packets, in timestamp ticks
(see GigeDevice::timestamp_tick_frequency).
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.