Skip to main content

ControlChannel

Struct ControlChannel 

Source
pub struct ControlChannel<T: UsbTransfer> { /* private fields */ }
Expand description

GenCP control channel over a USB3 Vision bulk endpoint pair.

Sends READMEM and WRITEMEM commands and receives their acknowledges, splitting a large access across the device’s maximum transfer sizes.

Implementations§

Source§

impl<T: UsbTransfer> ControlChannel<T>

Source

pub fn new( transport: Arc<T>, ep_in: u8, ep_out: u8, max_cmd_transfer: u32, max_ack_transfer: u32, ) -> Self

Create a new control channel.

max_cmd_transfer and max_ack_transfer cap the largest single bulk transfer each way; the SBRM has the device’s values, which set_max_transfer applies once read.

Source

pub fn set_max_transfer(&mut self, max_cmd_transfer: u32, max_ack_transfer: u32)

Use the device’s transfer limits from now on, keeping the request id sequence: a device answers a repeated id with its previous acknowledge (GenCP §3.1), so the sequence must not restart mid-session.

Source

pub fn set_timeout(&mut self, timeout: Duration)

Override the control transaction timeout.

Source

pub fn timeout(&self) -> Duration

The control transaction timeout.

Source

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

Access the underlying transport (e.g. to share with a stream).

Source

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

Read len bytes starting at addr, split across the device’s maximum acknowledge transfer size.

Source

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

Write data starting at addr, split across the device’s maximum command transfer size. The bytes go to the device as given: register contents are in the device’s own byte order, not the protocol’s.

Auto Trait Implementations§

§

impl<T> Freeze for ControlChannel<T>

§

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

§

impl<T> Send for ControlChannel<T>

§

impl<T> Sync for ControlChannel<T>

§

impl<T> Unpin for ControlChannel<T>

§

impl<T> UnsafeUnpin for ControlChannel<T>

§

impl<T> UnwindSafe for ControlChannel<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