pub struct Device { /* private fields */ }
Expand description
A D3XX device.
The Device
struct represents a single D3XX device. It provides methods
for interacting with the device, such as configuring and reading/writing to
the device.
Implementations§
source§impl Device
impl Device
sourcepub fn open(info: &DeviceInfo) -> Result<Device>
pub fn open(info: &DeviceInfo) -> Result<Device>
Open a device using the given device information.
sourcepub fn open_with_serial_number(serial_number: &str) -> Result<Device>
pub fn open_with_serial_number(serial_number: &str) -> Result<Device>
Open a device using the given serial number.
sourcepub unsafe fn from_handle(handle: *mut c_void) -> Device
pub unsafe fn from_handle(handle: *mut c_void) -> Device
Create a device wrapper using a raw handle
sourcepub fn raw_handle(&self) -> *mut c_void
pub fn raw_handle(&self) -> *mut c_void
Get the raw handle to the D3XX device.
sourcepub fn info(&self) -> Result<DeviceInfo>
pub fn info(&self) -> Result<DeviceInfo>
Gets information about the device.
sourcepub fn product_id(&self) -> Result<usize>
pub fn product_id(&self) -> Result<usize>
Get the product ID of the device.
sourcepub fn driver_version(&self) -> Result<Version>
pub fn driver_version(&self) -> Result<Version>
Gets the D3XX kernel driver version.
sourcepub fn index(&self) -> Result<usize>
pub fn index(&self) -> Result<usize>
Get the index of this device in the current device info list.
sourcepub fn write(&self, pipe: Pipe, buf: &[u8]) -> Result<usize>
pub fn write(&self, pipe: Pipe, buf: &[u8]) -> Result<usize>
Writes data to the specified pipe. This method will block until the transfer is complete, or the timeout is reached.
sourcepub fn read(&self, pipe: Pipe, buf: &mut [u8]) -> Result<usize>
pub fn read(&self, pipe: Pipe, buf: &mut [u8]) -> Result<usize>
Reads data from the specified pipe. This method will block until the transfer is complete, or the timeout is reached.
sourcepub fn flush(&self, pipe: Pipe) -> Result<()>
pub fn flush(&self, pipe: Pipe) -> Result<()>
Discards any data cached in an IN pipe.
If pipe
is an OUT pipe, an InvalidParameter
error is returned.
sourcepub fn set_timeout(&self, pipe: Pipe, timeout: Duration) -> Result<()>
pub fn set_timeout(&self, pipe: Pipe, timeout: Duration) -> Result<()>
Configures a timeout for the specified endpoint. Reading and writing will timeout in the event the operation hangs for the given duration.
The new value is only valid as long as the device is open; re-opening the device will reset the timeout to the default of 5 seconds.
sourcepub fn get_timeout(&self, pipe: Pipe) -> Result<Duration>
pub fn get_timeout(&self, pipe: Pipe) -> Result<Duration>
Get the timeout configured for the specified pipe.
sourcepub fn set_stream_size(
&self,
pipe: Pipe,
stream_size: Option<u32>
) -> Result<()>
pub fn set_stream_size( &self, pipe: Pipe, stream_size: Option<u32> ) -> Result<()>
Sets streaming protocol transfer for the specified pipe. This is for applications that read or write a fixed size of data to or from the device.
sourcepub fn abort_transfers(&self, pipe: Pipe) -> Result<()>
pub fn abort_transfers(&self, pipe: Pipe) -> Result<()>
Aborts all pending transfers for the given pipe.
sourcepub fn device_descriptor(&self) -> Result<DeviceDescriptor>
pub fn device_descriptor(&self) -> Result<DeviceDescriptor>
Get the USB device descriptor.
sourcepub fn power_cycle_port(self) -> Result<()>
pub fn power_cycle_port(self) -> Result<()>
Power cycles the device port. This causes the device to be re-enumermated by the host. Consumes the object, meaning the device must be re-opened.