[−][src]Crate libftd2xx
Rust safe wrapper for the FTDI D2XX drivers.
This takes the libftd2xx-ffi C bindings crate and extends it with rust safe wrappers.
Usage
Simply add this crate as a dependency in your Cargo.toml
.
On Linux the static library is distributed in the libftd2xx-ffi crate with
permission from FTDI.
[dependencies]
libftd2xx = "~0.22.0"
This is a basic example to get your started. Check the source code or documentation for more examples.
use libftd2xx::{Ftdi, FtdiCommon}; let mut ft = Ftdi::new()?; let info = ft.device_info()?; println!("Device information: {:?}", info);
One-time Linux Setup
To access the FTDI USB device as a regular user you need to update the udev rules.
Create a file called /etc/udev/rules.d/99-ftdi.rules
with:
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6001", GROUP="dialout", MODE="0664"
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6010", GROUP="dialout", MODE="0664"
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6011", GROUP="dialout", MODE="0664"
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6014", GROUP="dialout", MODE="0664"
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6015", GROUP="dialout", MODE="0664"
Then, reload the rules:
sudo udevadm control --reload-rules
sudo udevadm trigger
You will also need to be part of the dialout
group:
sudo adduser "$USER" dialout
One-time Windows Setup
Unlike Linux the Windows vendor driver is dynamically linked. The FTD2XX DLL must exist on your system PATH. The easiest way to install this is with the vendor provided setup executable.
References
Troubleshooting
Unknown Device on Linux
Remove the VCP FTDI driver.
sudo rmmod ftdi_sio
sudo rmmod usbserial
See FTDI Drivers Installation Guide for Linux for more details.
Structs
DeviceInfo | FTDI device information. |
DeviceStatus | FTDI device status. |
Eeprom232h | EEPROM structure for the FT232H. |
Eeprom4232h | EEPROM structure for the FT4232H. |
EepromHeader | FTDI EEPROM header common to all FTDI devices. |
EepromStrings | EEPROM strings structure. |
EepromStringsError | EEPROM strings error. |
EepromValueError | EEPROM value error. |
Ft232h | FT232H device. |
Ft4232h | FT4232H device. |
Ftdi | Generic FTDI device. |
ModemStatus | FTDI modem status. |
MpsseCmdBuilder | FTDI Multi-Protocol Synchronous Serial Engine (MPSSE) command builder. |
MpsseSettings | Initialization settings for the MPSSE. |
Version | D2XX version structure. |
Enums
BitMode | BitModes for the FTDI ports. |
BitsPerWord | Bits per word. |
ByteOrder | FT1248 byte order. |
Cbus232h | FT232H CBUS options. |
Cbus232r | FT232R CBUS options. |
CbusX | FT X Series CBUS options. |
ClockBits | Modes for clocking data bits in and out of the FTDI device. |
ClockBitsIn | Modes for clocking data bits into the FTDI device. |
ClockBitsOut | Modes for clocking bits out of the FTDI device. |
ClockData | Modes for clocking data in and out of the FTDI device. |
ClockDataIn | Modes for clocking data into the FTDI device. |
ClockDataOut | Modes for clocking data out of the FTDI device. |
ClockPolarity | FT1248 clock polarity |
DeviceType | FTDI device types. |
DeviceTypeError | Device type errors. |
DriveCurrent | FTDI pin drive currents. |
DriverType | FTDI driver type. |
FtStatus | These are the C API error codes. |
Parity | Serial parity bits. |
Speed | USB device speed. |
StopBits | Stop bits. |
TimeoutError | FTDI timeout errors. |
Constants
FTDI_VID | FTDI USB vendor id. |
Traits
FtdiCommon | FTD2XX functions common to all devices. |
FtdiEeprom | FTDI device-specific EEPROM trait. |
FtdiMpsse | FTDI Multi-Protocol Synchronous Serial Engine (MPSSE). |
Ftx232hMpsse | This contains MPSSE commands that are only available on the the FT232H, FT2232H, and FT4232H devices. |
Functions
library_version | Returns the version of the underlying C library. |
list_devices | This function returns a device information vector with information about the D2XX devices connected to the system. |
list_devices_fs | Lists FTDI devices using the Linux file system. |
num_devices | Returns the number of FTDI devices connected to the system. |
set_vid_pid | A command to include a custom VID and PID combination within the internal device list table. |
vid_pid | A command to retrieve the current VID and PID combination from within the internal device list table. |