Skip to main content

GigeDevice

Struct GigeDevice 

Source
pub struct GigeDevice { /* private fields */ }
Expand description

GVCP device handle.

Implementations§

Source§

impl GigeDevice

Source

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.

Source

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.

Source

pub fn control_timeout(&self) -> Duration

Return the acknowledgement timeout per control transaction attempt.

Source

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.

Source

pub fn inflight_keepalive_period(&self) -> Option<Duration>

The in-flight heartbeat period, None while they are off.

Source

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.

Source

pub fn memory_access_only(&self) -> bool

Whether single-register access currently goes out as READMEM/WRITEMEM.

Source

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.

Source

pub fn exclusive_access(&self) -> bool

Whether Self::claim_control asks for exclusive access.

Source

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.

Source

pub async fn release_control(&mut self) -> Result<(), GigeError>

Release control channel privilege.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn remote_addr(&self) -> SocketAddr

Return the remote GVCP socket address associated with this device.

Source

pub fn local_addr(&self) -> Result<SocketAddr>

The local address and port commands leave from: what the device knows this application by.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn set_message_destination( &mut self, ip: Ipv4Addr, port: u16, ) -> Result<(), GigeError>

Configure the message channel destination address/port.

Source

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.

Source

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.

Source

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.

Source

pub async fn stream_do_not_fragment( &mut self, channel: u32, ) -> Result<bool, GigeError>

Whether GevSCPSPacketSize holds the do-not-fragment flag (bit 30).

Source

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.

Source

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.

Source

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.

Source

pub async fn gvcp_capability(&mut self) -> Result<GvcpCapability, GigeError>

Read GVCP Capability (0x0934): which optional commands the device implements.

Source

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.

Source

pub async fn stream_channel_count(&mut self) -> Result<u32, GigeError>

Read GevNumberOfStreamChannels (0x0904).

Source

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.

Source

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).

Source

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).

Source

pub async fn write_persistent_ip( &mut self, ip: Ipv4Addr, subnet: Ipv4Addr, gateway: Ipv4Addr, ) -> Result<(), GigeError>

Write the persistent IP configuration to the device.

Source

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.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more