Name: hidapi-rs
Owner: Parity Technologies
Description: Rust bindings for the hidapi C library
Forked from: Osspial/hidapi-rs
Created: 2017-02-07 15:31:14.0
Updated: 2018-04-19 10:06:18.0
Pushed: 2018-04-19 10:06:17.0
Size: 64
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.