opentitanlib::util::usb

Struct UsbBackend

Source
pub struct UsbBackend { /* private fields */ }
Expand description

The UsbBackend provides low-level USB access to debugging devices.

Implementations§

Source§

impl UsbBackend

Source

pub fn scan( usb_vid: u16, usb_pid: u16, usb_serial: Option<&str>, ) -> Result<Vec<(Device<GlobalContext>, String)>>

Scan the USB bus for a device matching VID/PID, and optionally also matching a serial number.

Source

pub fn new(usb_vid: u16, usb_pid: u16, usb_serial: Option<&str>) -> Result<Self>

Create a new UsbBackend.

Source

pub fn get_vendor_id(&self) -> u16

Source

pub fn get_product_id(&self) -> u16

Source

pub fn get_serial_number(&self) -> &str

Gets the usb serial number of the device.

Source

pub fn set_active_configuration(&mut self, config: u8) -> Result<()>

Source

pub fn claim_interface(&mut self, iface: u8) -> Result<()>

Source

pub fn release_interface(&mut self, iface: u8) -> Result<()>

Source

pub fn kernel_driver_active(&self, iface: u8) -> Result<bool>

Source

pub fn detach_kernel_driver(&mut self, iface: u8) -> Result<()>

Source

pub fn attach_kernel_driver(&mut self, iface: u8) -> Result<()>

Source

pub fn active_config_descriptor(&self) -> Result<ConfigDescriptor>

Source

pub fn bus_number(&self) -> u8

Source

pub fn port_numbers(&self) -> Result<Vec<u8>>

Source

pub fn read_string_descriptor_ascii(&self, idx: u8) -> Result<String>

Source

pub fn write_control( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &[u8], ) -> Result<usize>

Issue a USB control request with optional host-to-device data.

Source

pub fn read_control( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &mut [u8], ) -> Result<usize>

Issue a USB control request with optional device-to-host data.

Source

pub fn read_bulk(&self, endpoint: u8, data: &mut [u8]) -> Result<usize>

Read bulk data bytes to given USB endpoint.

Source

pub fn read_bulk_timeout( &self, endpoint: u8, data: &mut [u8], timeout: Duration, ) -> Result<usize>

Read bulk data bytes to given USB endpoint.

Source

pub fn write_bulk(&self, endpoint: u8, data: &[u8]) -> Result<usize>

Write bulk data bytes to given USB endpoint.

Auto Trait Implementations§

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.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V