Skip to main content

GigeRegisterIo

Struct GigeRegisterIo 

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

Blocking adapter turning an asynchronous GigeDevice into a RegisterIo implementation.

The adapter waits on GVCP register transactions from synchronous code, whatever the caller runs on: a plain thread waits on the transport’s runtime directly; inside a multi-thread runtime the wait goes through [tokio::task::block_in_place] so the executor keeps making progress; on a current-thread runtime’s own thread it moves to a short-lived thread, since nothing may block that runtime in place.

connect_gige gives a camera opened from a current-thread runtime a runtime of its own, as blocking::connect does for a program with none. A camera built with GigeRegisterIo::new over a current-thread runtime’s handle can be used from that runtime’s blocking pool, but not from its own thread, which the socket needs free.

An access of exactly one aligned 32-bit register goes out as READREG/WRITEREG, anything else as READMEM/WRITEMEM; see GigeDevice::read_register_or_mem for the fallback a device that refuses the register commands gets.

§Control channel keepalive

Constructing the adapter spawns a background task that keeps the device’s control channel alive; see GigeRegisterIo::new. Holding a GigeRegisterIo is therefore enough to keep control privilege — no caller has to run a heartbeat of its own. While register I/O holds the device mutex, the GVCP receive loop sends its own probes on the same socket. Long ACK waits therefore do not starve the idle task’s keepalive; ordinary requests remain serialized.

Implementations§

Source§

impl GigeRegisterIo

Source

pub fn open_stream( &self, options: StreamOptions, ) -> Result<FrameStream, GenicamError>

Open a GVSP stream from this transport’s camera, ready for acquisition: the recipe Camera::open_stream runs, for a caller without a node map — a GenTL producer, which the GenTL standard (§2.1.2) asks not to run GenApi itself.

Claims control (again, if it was released) before anything is written, binds the socket, points the stream channel at it — or at a multicast group — negotiates the packet size, reads whether the camera supports resend, and starts the receive engine. Without StreamOptions::payload_size each frame is sized from its leader. StreamOptions::monitor needs the camera’s node map; here it is refused.

Source§

impl GigeRegisterIo

Source

pub fn new(handle: Handle, device: GigeDevice) -> Self

Create a new adapter using the provided runtime handle and a device that holds control privilege (GigeDevice::claim_control).

This also spawns the control-channel keepalive on handle. A GigE Vision device revokes control privilege if it receives no GVCP command within GevHeartbeatTimeout (3 000 ms on both viva-fake-gige and the aravis fake camera, arvfakecamera.c:1082), and GVSP image traffic does not count — so a camera can sit at an interactive prompt, or stream frames for a minute, and then refuse the next write with ACCESS_DENIED.

Nothing in an application’s normal flow refreshes that timer, which is why three consumers of this crate had each grown their own copy of the loop — and why the Python bindings, which had none, hit the failure.

The keepalive stops when the adapter is dropped, and control privilege is released then (CCP ← 0), so the next application — or the next run of this one — can claim it at once instead of waiting out the heartbeat timeout. Privilege lost meanwhile is reported through control_state. Dropping the adapter cancels and drains any in-flight keepalive I/O. The runtime must remain alive until the adapter has been dropped. On a current-thread runtime the async task is aborted, since blocking on its completion would prevent that same runtime from making progress.

Source

pub fn monitor(handle: Handle, device: GigeDevice) -> Self

A read-only adapter: no keepalive, no in-flight probes, and every write refused before it reaches the wire. For a camera another application controls; see Access::Monitor.

Source

pub fn control_state(&self) -> ControlState

Where this session stands with control privilege.

Source

pub fn watch_control(&self) -> Receiver<ControlState>

Changes of control_state as they happen: losing privilege is reported here, not only logged.

Source

pub fn refresh_control_state(&self) -> Result<ControlState, GenicamError>

Check an owned control session now, using only reads of the control channel and, where supported, the primary application’s address.

A revoked privilege or ACCESS_DENIED while reading that channel marks the session ControlState::Lost, notifies Self::watch_control, and stops its keepalive. Dropping it then sends no control release to another application’s camera. A network failure is returned with its cause and does not by itself establish lost ownership.

This never claims control. A monitor, released session or already-lost session is returned unchanged, without I/O. On cameras that do not name their primary application, a successful controlled CCP read cannot distinguish the current holder from another controller (TC-38).

Source

pub fn reclaim_control(&self) -> Result<(), GenicamError>

Ask for control privilege again — after it was lost or released, or to turn a monitor into a controller — and keep it alive.

Fails, and changes nothing, while another application holds it.

Source

pub fn release_control(&self) -> Result<(), GenicamError>

Give control privilege up now (CCP ← 0) and stop the keepalive, reporting whether the camera acknowledged. Dropping the adapter does the same, best effort. A release the camera does not take leaves the session as it was, keepalive running.

A monitor holds nothing and writes nothing, so for one this does nothing.

Source

pub fn lock_device(&self) -> Result<MutexGuard<'_, GigeDevice>, GenicamError>

Lock the underlying GigeDevice for direct async operations.

This is intended for callers that need the raw device (e.g. stream channel configuration) while the Camera wrapper holds the transport.

Trait Implementations§

Source§

impl Drop for GigeRegisterIo

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl RegisterIo for GigeRegisterIo

Source§

fn read(&self, addr: u64, len: usize) -> Result<Vec<u8>, GenApiError>

Read len bytes starting at addr.
Source§

fn write(&self, addr: u64, data: &[u8]) -> Result<(), GenApiError>

Write data starting at addr.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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