Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.
/ hidapi-rs Public archive
forked from ruabmbua/hidapi-rs

Rust bindings for the hidapi C library

License

Notifications You must be signed in to change notification settings

paritytech/hidapi-rs

This branch is 15 commits ahead of, 366 commits behind ruabmbua/hidapi-rs:main.

Folders and files

NameName
Last commit message
Last commit date
Jul 12, 2018
Aug 22, 2016
Feb 8, 2017
Jul 27, 2015
Jul 10, 2018
Apr 17, 2018
Jan 12, 2018
Aug 26, 2016
Aug 28, 2016
Apr 17, 2018

Repository files navigation

hidapi Build Status Version License: LGPL v3 Documentation

This crate provides a rust abstraction over the features of the C library hidapi by signal11. Based off of hidapi_rust by ruabmbua.

Usage

This crate is on crates.io and can be used by adding hidapi to the dependencies in your project's Cargo.toml.

[dependencies]
hidapi = "0.3"

Example

extern crate hidapi;

let api = hidapi::HidApi::new().unwrap();
// Print out information about all connected devices
for device in &api.devices() {
    println!("{:#?}", device);
}

// Connect to device using its VID and PID
let (VID, PID) = (0x0123, 0x3456);
let device = api.open(VID, PID).unwrap();

// Read data from device
let mut buf = [0u8; 8];
let res = device.read(&mut buf[..]).unwrap();
println!("Read: {:?}", &buf[..res]);

// Write data to device
let buf = [0u8, 1, 2, 3, 4];
let res = device.write(&buf).unwrap();
println!("Wrote: {:?} byte(s)", res);

Documentation

Available at docs.rs.

About

Rust bindings for the hidapi C library

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%