Name: hidapi-rs
Description: Rust bindings for the hidapi C library
Created: 2016-03-11 22:47:36.0
Updated: 2017-10-13 18:26:11.0
Pushed: 2017-12-31 16:51:32.0
Size: 62
Language: Rust
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This crate provides a rust abstraction over the features of the C library hidapi by signal11. Based off of hidapi_rust by ruabmbua.
This crate is on crates.io and can be
used by adding hidapi
to the dependencies in your project's Cargo.toml
.
endencies]
pi = "0.3"
rn crate hidapi;
api = hidapi::HidApi::new().unwrap();
rint out information about all connected devices
device in &api.devices() {
println!("{:#?}", device);
onnect to device using its VID and PID
(VID, PID) = (0x0123, 0x3456);
device = api.open(VID, PID).unwrap();
ead data from device
mut buf = [0u8; 8];
res = device.read(&mut buf[..]).unwrap();
tln!("Read: {:?}", &buf[..res]);
rite data to device
buf = [0u8, 1, 2, 3, 4];
res = device.write(&buf).unwrap();
tln!("Wrote: {:?} byte(s)", res);
Available at docs.rs.