[][src]Struct usbd_bulk_only_transport::BulkOnlyTransport

pub struct BulkOnlyTransport<'a, B: UsbBus> { /* fields omitted */ }

USB Bulk Only Transport protocol

So far only tested with the SCSI transparent command set - see Scsi

Glossary

Functionality overview

  1. Reading CBWs
  2. Initiating a data transfer with the length and direction from the CBW
  3. Sending USB packets to the underlaying driver when there is data in the buffer
  4. Terminating the data transfer when enough data is processed or early termination is requested
  5. Adding ZLP when necessary
  6. Sending CSW with correct data residue
  7. Responding to class specific control requests (bulk only reset and get max lun)

Unimplemented/Untested:

  1. More than 1 LUN - the SCSI implementation used for testing uses LUN 0 and responds to requests for any other LUN with CommandError. This class will respond to get max lun correctly for any valid value of max_lun but I haven't implemented anything that uses more than 1 LUN
  2. Bulk only mass storage reset that takes any length of time - the spec (Section 3.1 USB Bulk Only Transport Spec) allows for the reset request to kick off the reset and have the host wait/poll until the reset is done. This is likely for devices where the reset might take a long (relative to poll rate) time. This isn't implemented here.

Methods

impl<'_, B: UsbBus> BulkOnlyTransport<'_, B>[src]

pub const BUFFER_BYTES: usize[src]

pub fn new(
    alloc: &UsbBusAllocator<B>,
    max_packet_size: u16,
    subclass: InterfaceSubclass,
    max_lun: u8
) -> BulkOnlyTransport<B>
[src]

pub fn read(&mut self) -> Result<(), Error>[src]

pub fn write(&mut self) -> Result<(), Error>[src]

pub fn get_current_command(&self) -> Option<&CommandBlockWrapper>[src]

pub fn data_residue(&self) -> Option<u32>[src]

pub fn transfer_state(&self) -> TransferState[src]

pub fn take_buffer_space(&mut self, len: usize) -> Result<&mut [u8], Error>[src]

Gets a mutable slice of the buffer of the specified length panics if len requested is > the max size of the buffer returns WouldBlock if there isn't currently space in the buffer Advances the buffer pointer so don't call it unless you actually need to put data in the buffer.

pub fn take_buffered_data(
    &mut self,
    len: usize,
    take_available: bool
) -> Result<&[u8], Error>
[src]

Returns a slice containing data from the buffer if there is len bytes available panics if len requested is > the max size of the buffer take_available modifies behaviour to return whatever is available, even if that is [u8; 0] returns WouldBlock if there isn't enough data available

pub fn send_command_ok(&mut self) -> Result<(), Error>[src]

pub fn send_command_error(&mut self) -> Result<(), Error>[src]

Trait Implementations

impl<'_, B: UsbBus> UsbClass<B> for BulkOnlyTransport<'_, B>[src]

Auto Trait Implementations

impl<'a, B> Send for BulkOnlyTransport<'a, B>

impl<'a, B> Sync for BulkOnlyTransport<'a, B>

impl<'a, B> Unpin for BulkOnlyTransport<'a, B>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.