[−][src]Struct usbd_bulk_only_transport::BulkOnlyTransport
USB Bulk Only Transport protocol
So far only tested with the SCSI transparent command set - see Scsi
Functionality overview
- Reading CBWs
- Initiating a data transfer with the length and direction from the CBW
- Sending USB packets to the underlaying driver when there is data in the buffer
- Terminating the data transfer when enough data is processed or early termination is requested
- Adding ZLP when necessary
- Sending CSW with correct data residue
- Responding to class specific control requests (bulk only reset and get max lun)
Unimplemented/Untested:
- 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 - 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]
alloc: &UsbBusAllocator<B>,
max_packet_size: u16,
subclass: InterfaceSubclass,
max_lun: u8
) -> BulkOnlyTransport<B>
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]
&mut self,
len: usize,
take_available: bool
) -> Result<&[u8], Error>
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]
fn get_configuration_descriptors(
&self,
writer: &mut DescriptorWriter
) -> UsbResult<()>
[src]
&self,
writer: &mut DescriptorWriter
) -> UsbResult<()>
fn reset(&mut self)
[src]
fn control_in(&mut self, xfer: ControlIn<B>)
[src]
fn control_out(&mut self, xfer: ControlOut<B>)
[src]
fn poll(&mut self)
[src]
fn get_bos_descriptors(&self, writer: &mut BosWriter) -> Result<(), UsbError>
[src]
fn get_string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
[src]
fn endpoint_setup(&mut self, addr: EndpointAddress)
[src]
fn endpoint_out(&mut self, addr: EndpointAddress)
[src]
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,