pub struct U3vDevice<T: UsbTransfer> { /* private fields */ }Expand description
High-level handle for a USB3 Vision device.
Wraps a ControlChannel and parsed bootstrap registers. The generic
T parameter allows production use with NusbTransfer (the usb
feature) and testing with MockUsbTransfer.
Implementations§
Source§impl<T: UsbTransfer> U3vDevice<T>
impl<T: UsbTransfer> U3vDevice<T>
Sourcepub fn open(
transport: Arc<T>,
ep_in: u8,
ep_out: u8,
stream_ep: Option<u8>,
event_ep: Option<u8>,
) -> Result<Self, U3vError>
pub fn open( transport: Arc<T>, ep_in: u8, ep_out: u8, stream_ep: Option<u8>, event_ep: Option<u8>, ) -> Result<Self, U3vError>
Open a U3V device given a shared USB transport and endpoint addresses.
Reads the ABRM and SBRM bootstrap registers, then uses the device’s response time and transfer limits on the same control channel.
Sourcepub fn transport(&self) -> Arc<T> ⓘ
pub fn transport(&self) -> Arc<T> ⓘ
Access the shared transport handle (e.g. to create additional streams).
Sourcepub fn current_speed(&self) -> Option<UsbSpeed>
pub fn current_speed(&self) -> Option<UsbSpeed>
The bus speed the device runs at: as the host’s USB stack reports it, or else as the SBRM’s current speed register says.
Sourcepub fn timestamp(&mut self) -> Result<Option<u64>, U3vError>
pub fn timestamp(&mut self) -> Result<Option<u64>, U3vError>
The device time, in ns: latched, then read from the GenCP timestamp
registers (GenCP 1.3.1 §5.4.16-17); None when the device has none
(Device Capability bit 3). The clock a stream’s leaders and events
are stamped with.
Sourcepub fn read_mem(&mut self, addr: u64, len: usize) -> Result<Vec<u8>, U3vError>
pub fn read_mem(&mut self, addr: u64, len: usize) -> Result<Vec<u8>, U3vError>
Read len bytes from device memory at addr.
Sourcepub fn write_mem(&mut self, addr: u64, data: &[u8]) -> Result<(), U3vError>
pub fn write_mem(&mut self, addr: u64, data: &[u8]) -> Result<(), U3vError>
Write data to device memory at addr.
Sourcepub fn read_sirm(&mut self) -> Result<Sirm, U3vError>
pub fn read_sirm(&mut self) -> Result<Sirm, U3vError>
Read the device’s half of the SIRM (Streaming Interface Register Map).
Sourcepub fn fetch_xml(&mut self) -> Result<String, U3vError>
pub fn fetch_xml(&mut self) -> Result<String, U3vError>
Fetch the GenICam XML descriptor from the device’s manifest table.
A ZIP-compressed file — by the manifest’s file format, or by its
PK\x03\x04 signature — is decompressed. Returns the XML as a UTF-8
string.
Sourcepub fn stream_ep(&self) -> Option<u8>
pub fn stream_ep(&self) -> Option<u8>
The bulk IN endpoint for streaming data, if the device has one.
Sourcepub fn open_stream(&mut self, payload_hint: u64) -> Result<U3vStream, U3vError>where
T: 'static,
pub fn open_stream(&mut self, payload_hint: u64) -> Result<U3vStream, U3vError>where
T: 'static,
open_stream_with the default transfer
settings and payload_hint.
Sourcepub fn open_stream_with(
&mut self,
options: &U3vStreamOptions,
) -> Result<U3vStream, U3vError>where
T: 'static,
pub fn open_stream_with(
&mut self,
options: &U3vStreamOptions,
) -> Result<U3vStream, U3vError>where
T: 'static,
Configure the SIRM, reset the stream endpoint and enable streaming,
returning a U3vStream that reads with the configured transfer
layout.
The payload size is the SIRM’s Required Payload Size: the device’s
own figure for this stream channel. The options’ hint — from the
PayloadSize feature, say — is used only when the device leaves that
register at 0. Every transfer is a multiple of the SIRM’s alignment
and of the endpoint’s packet size, whichever is larger.
The endpoint is reset — halted and cleared, so the device drops
whatever an earlier stream left on it — after the layout is written
and before StreamEnable is set, as aravis does
(arv_uv_device_reset_stream_endpoint; backlog TC-27 (3)).
Sourcepub fn stop_stream(&mut self) -> Result<(), U3vError>
pub fn stop_stream(&mut self) -> Result<(), U3vError>
Clear StreamEnable: the device stops sending on the stream endpoint.
Sourcepub fn read_eirm(&mut self) -> Result<Eirm, U3vError>
pub fn read_eirm(&mut self) -> Result<Eirm, U3vError>
The device’s event interface registers; an error when it has none (U3VCP Capability bit 1, or an EIRM address of 0).
Sourcepub fn open_events(&mut self) -> Result<U3vEventStream, U3vError>where
T: 'static,
pub fn open_events(&mut self) -> Result<U3vEventStream, U3vError>where
T: 'static,
Set EventEnable and return a U3vEventStream reading the event
endpoint (backlog TC-27 (4)). Which events the device sends is the
XML’s EventSelector / EventNotification to choose.
Sourcepub fn stop_events(&mut self) -> Result<(), U3vError>
pub fn stop_events(&mut self) -> Result<(), U3vError>
Clear EventEnable: the device stops sending events.
Sourcepub fn describe(&mut self) -> Vec<(String, String)>
pub fn describe(&mut self) -> Vec<(String, String)>
The bootstrap registers as read, decoded and raw, for a diagnostic report. One camera has been checked against this (backlog TC-27), so the raw SBRM and SIRM bytes are what settles a disagreement. A register the device refuses is listed as such.
Source§impl U3vDevice<NusbTransfer>
impl U3vDevice<NusbTransfer>
Sourcepub fn open_device(info: &U3vDeviceInfo) -> Result<Self, U3vError>
pub fn open_device(info: &U3vDeviceInfo) -> Result<Self, U3vError>
Open a USB3 Vision device from a U3vDeviceInfo
obtained via discover().