Skip to main content

U3vDevice

Struct U3vDevice 

Source
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>

Source

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.

Source

pub fn transport(&self) -> Arc<T> ⓘ

Access the shared transport handle (e.g. to create additional streams).

Source

pub fn abrm(&self) -> &Abrm

Reference to the parsed ABRM.

Source

pub fn sbrm(&self) -> &Sbrm

Reference to the parsed SBRM.

Source

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.

Source

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.

Source

pub fn read_mem(&mut self, addr: u64, len: usize) -> Result<Vec<u8>, U3vError>

Read len bytes from device memory at addr.

Source

pub fn write_mem(&mut self, addr: u64, data: &[u8]) -> Result<(), U3vError>

Write data to device memory at addr.

Source

pub fn read_sirm(&mut self) -> Result<Sirm, U3vError>

Read the device’s half of the SIRM (Streaming Interface Register Map).

Source

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.

Source

pub fn stream_ep(&self) -> Option<u8>

The bulk IN endpoint for streaming data, if the device has one.

Source

pub fn event_ep(&self) -> Option<u8>

The bulk IN endpoint for events, if the device has one.

Source

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.

Source

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

Source

pub fn stop_stream(&mut self) -> Result<(), U3vError>

Clear StreamEnable: the device stops sending on the stream endpoint.

Source

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

Source

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.

Source

pub fn stop_events(&mut self) -> Result<(), U3vError>

Clear EventEnable: the device stops sending events.

Source

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>

Source

pub fn open_device(info: &U3vDeviceInfo) -> Result<Self, U3vError>

Open a USB3 Vision device from a U3vDeviceInfo obtained via discover().

Auto Trait Implementations§

§

impl<T> Freeze for U3vDevice<T>

§

impl<T> RefUnwindSafe for U3vDevice<T>
where T: RefUnwindSafe,

§

impl<T> Send for U3vDevice<T>

§

impl<T> Sync for U3vDevice<T>

§

impl<T> Unpin for U3vDevice<T>

§

impl<T> UnsafeUnpin for U3vDevice<T>

§

impl<T> UnwindSafe for U3vDevice<T>
where T: RefUnwindSafe,

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