8 releases

0.4.0 Apr 7, 2021
0.3.1 Mar 28, 2021
0.2.5 Mar 27, 2021
0.2.1 Sep 11, 2020

#78 in Hardware support

Download history 4/week @ 2020-12-29 8/week @ 2021-01-05 6/week @ 2021-01-12 8/week @ 2021-01-19 4/week @ 2021-01-26 4/week @ 2021-02-02 7/week @ 2021-02-09 12/week @ 2021-02-16 8/week @ 2021-02-23 6/week @ 2021-03-02 5/week @ 2021-03-09 21/week @ 2021-03-16 70/week @ 2021-03-23 24/week @ 2021-03-30 33/week @ 2021-04-06 20/week @ 2021-04-13

60 downloads per month
Used in 2 crates

MIT license

55KB
1.5K SLoC

Native USB API for Rust

Inspired by the C http://libusb.info driver.

Rust usbapi crate currently only support Linux.

UsbAPI crate does not have any dependencies on libusb C API's and is a clean implementation in Rust using ioctl/mmap calls on Linux using nix low level crate.

You are free to fork or send pull request and make it work on other platforms.

Dependencies

See Cargo.toml I try to use as less as possible.

Supported functions in Linux

  • Enumerate USB peripherals
  • Zero copy using mmap buffers.
  • Sync bulk API's
  • Async bulk and control transmissions
  • Transfers are safe and can't be accessed after passed to kernel
  • Optional all descriptors can be serialized if feature serde is enabled.
  • Optional mio support

TODO

When I started this project I was new in Rust. Some stuff will change.

  • Cleanup traits implementations for easier port to other platforms
  • Use valgrind to cleanup possible leaks in unsafe code (eg mmap etc...
  • Add isochronous support
  • Add interrupt endpoints
  • Use log crate instead of eprintln and println for debug.
  • claim_interface will panic if kernel driver is loaded since unload driver is not implemented cant test so not implemented feel free to send patch if needed.

For those who use any of below platforms, feel free to send a pull request:

  • Support FreeBSD/OpenBSD
  • Support NetBSD
  • Support Haiku
  • Support OSX
  • Support Windows

Dependencies

~1.1–1.6MB
~33K SLoC