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
impl GigeRegisterIo
Sourcepub fn open_stream(
&self,
options: StreamOptions,
) -> Result<FrameStream, GenicamError>
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
impl GigeRegisterIo
Sourcepub fn new(handle: Handle, device: GigeDevice) -> Self
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.
Sourcepub fn monitor(handle: Handle, device: GigeDevice) -> Self
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.
Sourcepub fn control_state(&self) -> ControlState
pub fn control_state(&self) -> ControlState
Where this session stands with control privilege.
Sourcepub fn watch_control(&self) -> Receiver<ControlState>
pub fn watch_control(&self) -> Receiver<ControlState>
Changes of control_state as they happen: losing
privilege is reported here, not only logged.
Sourcepub fn refresh_control_state(&self) -> Result<ControlState, GenicamError>
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).
Sourcepub fn reclaim_control(&self) -> Result<(), GenicamError>
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.
Sourcepub fn release_control(&self) -> Result<(), GenicamError>
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.
Sourcepub fn lock_device(&self) -> Result<MutexGuard<'_, GigeDevice>, GenicamError>
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.