Giter Club home page Giter Club logo

libftd2xx's Introduction

crates.io docs.rs CI

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.

[dependencies.libftd2xx]
version = "0.32.4"
# statically link the vendor library, defaults to dynamic if not set
# this will make things "just work" on Linux and Windows
features = ["static"]

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);

This crate is just a wrapper around the FTD2XX driver; I2C, SPI, and GPIO examples using the embedded-hal traits can be found in ftdi-embedded-hal.

udev rules

To access the FTDI USB device as a regular user on Linux you need to update the udev rules.

Create a file called /etc/udev/rules.d/99-ftdi.rules with:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE="0666"

Then, reload the rules:

sudo udevadm control --reload-rules
sudo udevadm trigger

Linking

By default this crate with use dynamic linking for the vendor library. Use the static feature flag to enable static linking.

Dynamic Linking on Linux

The shared object libftd2xx.so must exist on your system. See FTDI Drivers Installation Guide for Linux for instructions.

Dynamic Linking on Windows

The FTD2XX DLL must exist on your system PATH. The easiest way to install this is with the vendor provided setup executable.

Static Linking on Linux or Windows

No special considerations are needed, the static library is distributed with permission from FTDI in the libftd2xx-ffi crate.

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.

libftd2xx's People

Contributors

newam avatar cirrusneptune avatar geomatsi avatar dependabot[bot] avatar davidlattimore avatar icxolu avatar kovirobi avatar srwalter avatar he2she avatar tolgadot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.