Struct libftd2xx::Ftdi

source ·
pub struct Ftdi { /* private fields */ }
Expand description

Generic FTDI device.

This structure can be used for all FTDI devices. A device-specific structure is only necessary to access the EEPROM traits for that device.

Implementations§

source§

impl Ftdi

source

pub fn new() -> Result<Ftdi, FtStatus>

Open the first device on the system.

This is equivalent to calling with_index with an index of 0.

This function cannot be used to open a specific device. Ordering of devices on a system is not guaranteed to remain constant. Calling this function multiple times may result in a different device each time when there is more than one device connected to the system. Use with_serial_number to open a specific device.

§Example
use libftd2xx::Ftdi;

Ftdi::new()?;
source

pub fn with_index(index: i32) -> Result<Ftdi, FtStatus>

Open the device by an arbitrary index and initialize the handle.

This function can open multiple devices, but it cannot be used to open a specific device. Ordering of devices on a system is not guaranteed to remain constant. Calling this function multiple times with the same index may result in a different device each time when there is more than one device connected to the system. Use with_serial_number to open a specific device.

§Example
use libftd2xx::Ftdi;

Ftdi::with_index(0)?;
source

pub fn with_serial_number(serial_number: &str) -> Result<Ftdi, FtStatus>

Open the device by its serial number and initialize the handle.

§Example
use libftd2xx::Ftdi;

Ftdi::with_serial_number("FT59UO4C")?;
source

pub fn with_description(description: &str) -> Result<Ftdi, FtStatus>

Open the device by its device description.

§Example
use libftd2xx::Ftdi;

Ftdi::with_description("Hello")?;

Trait Implementations§

source§

impl Debug for Ftdi

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Ftdi

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl FtdiCommon for Ftdi

source§

const DEVICE_TYPE: DeviceType = DeviceType::Unknown

FTDI device type.
source§

fn handle(&mut self) -> FT_HANDLE

Get the FTDI device handle.
source§

fn device_type(&mut self) -> Result<DeviceType, FtStatus>

Identify device type. Read more
source§

fn device_info(&mut self) -> Result<DeviceInfo, FtStatus>

Get device information for an open device. Read more
source§

fn driver_version(&mut self) -> Result<Version, FtStatus>

Returns the D2XX driver version number. Read more
source§

fn reset(&mut self) -> Result<(), FtStatus>

This function sends a reset command to the device. Read more
source§

fn set_usb_parameters(&mut self, in_transfer_size: u32) -> Result<(), FtStatus>

Set the USB request transfer size. Read more
source§

fn set_chars( &mut self, event_char: u8, event_enable: bool, error_char: u8, error_enable: bool ) -> Result<(), FtStatus>

This function sets the special characters for the device. Read more
source§

fn set_timeouts( &mut self, read_timeout: Duration, write_timeout: Duration ) -> Result<(), FtStatus>

This function sets the read and write timeouts for the device. Read more
source§

fn set_deadman_timeout(&mut self, timeout: Duration) -> Result<(), FtStatus>

This method allows the maximum time in milliseconds that a USB request can remain outstandingto be set. Read more
source§

fn set_latency_timer(&mut self, timer: Duration) -> Result<(), FtStatus>

Set the latency timer value. Read more
source§

fn latency_timer(&mut self) -> Result<Duration, FtStatus>

Get the current value of the latency timer. Read more
source§

fn set_flow_control_none(&mut self) -> Result<(), FtStatus>

This function disables flow control for the device. Read more
source§

fn set_flow_control_rts_cts(&mut self) -> Result<(), FtStatus>

This function sets RTS/CTS flow control for the device. Read more
source§

fn set_flow_control_dtr_dsr(&mut self) -> Result<(), FtStatus>

This function sets DTS/DSR flow control for the device. Read more
source§

fn set_flow_control_xon_xoff( &mut self, xon: u8, xoff: u8 ) -> Result<(), FtStatus>

This function sets XON/XOFF flow control for the device. Read more
source§

fn set_baud_rate(&mut self, baud_rate: u32) -> Result<(), FtStatus>

Set the baud rate for the device. Read more
source§

fn set_data_characteristics( &mut self, bits_per_word: BitsPerWord, stop_bits: StopBits, parity: Parity ) -> Result<(), FtStatus>

Set the data characteristics for the device. Read more
source§

fn set_dtr(&mut self) -> Result<(), FtStatus>

Set the Data Terminal Ready (DTR) control signal. Read more
source§

fn clear_dtr(&mut self) -> Result<(), FtStatus>

Clear the Data Terminal Ready (DTR) control signal. Read more
source§

fn set_rts(&mut self) -> Result<(), FtStatus>

Set the Request to Send (RTS) control signal. Read more
source§

fn clear_rts(&mut self) -> Result<(), FtStatus>

Clear the Request to Send (RTS) control signal. Read more
source§

fn set_bit_mode(&mut self, mask: u8, mode: BitMode) -> Result<(), FtStatus>

Enables different chip modes. Read more
source§

fn bit_mode(&mut self) -> Result<u8, FtStatus>

Get the instantaneous value of the data bus. Read more
source§

fn set_break_on(&mut self) -> Result<(), FtStatus>

Sets the BREAK condition for the device. Read more
source§

fn set_break_off(&mut self) -> Result<(), FtStatus>

Resets the BREAK condition for the device. Read more
source§

fn queue_status(&mut self) -> Result<usize, FtStatus>

Gets the number of bytes in the receive queue. Read more
source§

fn status(&mut self) -> Result<DeviceStatus, FtStatus>

Gets the device status including number of characters in the receive queue, number of characters in the transmit queue, and the current event status. Read more
source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, FtStatus>

Read data from the device, returning the number of bytes read. Read more
source§

fn read_all(&mut self, buf: &mut [u8]) -> Result<(), TimeoutError>

Read data from the device. Read more
source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), TimeoutError>

Write data to the device. Read more
source§

fn write(&mut self, buf: &[u8]) -> Result<usize, FtStatus>

Write data to the device, returning how many bytes were written. Read more
source§

fn purge_tx(&mut self) -> Result<(), FtStatus>

This function purges the transmit buffers in the device. Read more
source§

fn purge_rx(&mut self) -> Result<(), FtStatus>

This function purges the receive buffers in the device. Read more
source§

fn purge_all(&mut self) -> Result<(), FtStatus>

This function purges the transmit and receive buffers in the device. Read more
source§

fn close(&mut self) -> Result<(), FtStatus>

Close an open device. Read more
source§

fn com_port_number(&mut self) -> Result<Option<u32>, FtStatus>

Available on Windows only.
Get the COM port associated with a device. Read more
source§

fn reset_port(&mut self) -> Result<(), FtStatus>

Available on Windows only.
Send a reset command to the port. Read more
source§

fn cycle_port(&mut self) -> Result<(), FtStatus>

Available on Windows only.
Send a cycle command to the USB port. Read more
source§

fn modem_status(&mut self) -> Result<ModemStatus, FtStatus>

Gets the modem status and line status from the device. Read more
source§

fn eeprom_word_read(&mut self, offset: u32) -> Result<u16, FtStatus>

Read a value from an EEPROM location. Read more
source§

fn eeprom_word_write(&mut self, offset: u32, value: u16) -> Result<(), FtStatus>

Writes a value to an EEPROM location. Read more
source§

fn eeprom_erase(&mut self) -> Result<(), FtStatus>

Erases the entire contents of the EEPROM, including the user area. Read more
source§

fn eeprom_user_size(&mut self) -> Result<usize, FtStatus>

Get the available size of the EEPROM user area in bytes. Read more
source§

fn eeprom_user_read(&mut self, buf: &mut [u8]) -> Result<usize, FtStatus>

Read the contents of the EEPROM user area. Read more
source§

fn eeprom_user_write(&mut self, buf: &[u8]) -> Result<(), FtStatus>

Write to the EEPROM user area. Read more
source§

impl TryFrom<Ftdi> for Ft2232h

§

type Error = DeviceTypeError

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

fn try_from(ft: Ftdi) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Ftdi> for Ft232h

§

type Error = DeviceTypeError

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

fn try_from(ft: Ftdi) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Ftdi> for Ft232r

§

type Error = DeviceTypeError

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

fn try_from(ft: Ftdi) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Ftdi> for Ft4232h

§

type Error = DeviceTypeError

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

fn try_from(ft: Ftdi) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Send for Ftdi

source§

impl Sync for Ftdi

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.