hid
hidapi
cargo install hidapi
hid

hidapi

Rust bindings for the hidapi C library

by Roland Ruckerbauer

1.4.1 (see all)License:MIT
cargo install hidapi
Readme

hidapi Version License: MIT Documentation Chat

This crate provides a rust abstraction over the features of the C library hidapi. Based off of hidapi-rs by Osspial.

Usage

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

Example

extern crate hidapi;


let api = hidapi::HidApi::new().unwrap();
// Print out information about all connected devices
for device in api.device_list() {
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);

// 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.

GitHub Stars

66

LAST COMMIT

8mos ago

MAINTAINERS

2

CONTRIBUTORS

20

OPEN ISSUES

7

OPEN PRs

0
VersionTagPublished
1.4.1
3mos ago
1.3.4
4mos ago
1.3.3
5mos ago
1.3.2
6mos ago
No alternatives found
No tutorials found
Add a tutorial