Osspial/hidapi-rs

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

Homepage:

Size: 62

Language: Rust

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

hidapi Build Status Version License: MIT 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.

endencies]
pi = "0.3"

Example

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

Documentation

Available at docs.rs.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.