pub struct UsbDevice<'a> { /* private fields */ }Expand description
The device this driver was started for, reached through its host.
Implementations§
Source§impl<'a> UsbDevice<'a>
impl<'a> UsbDevice<'a>
Sourcepub fn granted(ctx: &'a ServiceContext) -> Option<UsbDevice<'a>>
pub fn granted(ctx: &'a ServiceContext) -> Option<UsbDevice<'a>>
The host this driver was given as its peer, or None when it was given none - it was not started for a
USB device. A host spawned after this driver is named but not yet wired, so one this driver may REACQUIRE by
name is taken next. The kernel mints a capability by name only for a peer this driver was spawned with (or for
a holder of ACQUIRE_ANY), so this reaches no host the driver was not given, and widens nothing.
Sourcepub fn place(&self) -> Option<Place>
pub fn place(&self) -> Option<Place>
Where the host says the device is, or None from a host that does not say, or did not answer.
Sourcepub fn control_in(
&self,
setup: [u8; 8],
out: &mut [u8],
) -> Result<usize, UsbError>
pub fn control_in( &self, setup: [u8; 8], out: &mut [u8], ) -> Result<usize, UsbError>
One control transfer IN on the default endpoint: setup is the 8-byte setup packet as USB defines it, and
what the device returned is copied into out. How many bytes it returned.
Sourcepub fn control_out(&self, setup: [u8; 8], data: &[u8]) -> Result<(), UsbError>
pub fn control_out(&self, setup: [u8; 8], data: &[u8]) -> Result<(), UsbError>
One control transfer OUT on the default endpoint, with data as its data stage (at most
wire::CONTROL_MAX bytes; the setup packet’s length field is the caller’s to set to match).
Sourcepub fn control_out_once(
&self,
setup: [u8; 8],
data: &[u8],
) -> Result<(), UsbError>
pub fn control_out_once( &self, setup: [u8; 8], data: &[u8], ) -> Result<(), UsbError>
control_out, attempted exactly once: the host does not retry it. For a write whose effect a second attempt
would repeat - a device that acts on the first copy and NAKs the rest (wire::OP_CONTROL_ONCE).
Sourcepub fn replug(&self) -> Result<(), UsbError>
pub fn replug(&self) -> Result<(), UsbError>
Ask the host to reset the device’s port and bind it afresh, as unplugging it would (wire::OP_REPLUG): for a
device that has stopped answering. On Ok the host reports the device gone and then bound again, so this
driver is stopped and a fresh one started. Failed is a host that has reset it as often as it may;
BadRequest one that cannot reset a port (xhci, ehci).
Sourcepub fn bulk_out(&self, out: u8, data: &[u8]) -> Result<(), UsbError>
pub fn bulk_out(&self, out: u8, data: &[u8]) -> Result<(), UsbError>
One bulk OUT transfer to the device’s outth bulk OUT endpoint, counted in the order its configuration
descriptor lists them, from 0. At most wire::BULK_OUT_MAX bytes.
Sourcepub fn bulk_in(&self, out: &mut [u8]) -> Result<usize, UsbError>
pub fn bulk_in(&self, out: &mut [u8]) -> Result<usize, UsbError>
The bulk IN transfer the host holds from the device, copied into out: how many bytes, 0 when it holds
none. The host keeps one IN armed and arms it again as each is collected, so the first call is what starts
receiving; it sends wire::NOTE_BULK_IN when one is held, for a driver that waits rather than asks (xhci,
dwc2). ehci holds nothing and sends no notice: each call waits up to 20 ms for the device and returns what
came, so a driver there asks again rather than waiting to be told.