Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b3d3eed
fields.rs: Make request_type function a const fn
ammubhave Aug 25, 2022
17fe36f
Merge pull request #142 from ammubhave/const
a1ien Aug 25, 2022
1402b28
Increase endpoint descriptor's lifetime
mciantyre Oct 7, 2022
bb2fc51
Merge pull request #149 from mciantyre/ep-desc-lifetime
a1ien Oct 23, 2022
d3c6d49
Fix timeout documentation
cujomalainey Oct 29, 2022
df483fa
Merge pull request #151 from cujomalainey/master
a1ien Oct 29, 2022
aba2025
fix: Add missing fields to libusb_bos_descriptor and libusb_bos_dev_c…
alufers Feb 27, 2023
6dd18d5
Update usb-ids dev dependency
a1ien Mar 26, 2023
85a3246
New release of rusb 0.9.2
a1ien Mar 26, 2023
ba8539f
Merge pull request #162 from a1ien/new_release
a1ien Mar 26, 2023
b1175d6
Update checkout@v2 to checkout@v3
a1ien Mar 26, 2023
a709473
Merge pull request #163 from a1ien/update_githubci_checkout
a1ien Mar 26, 2023
6b8361a
Fix changelog urls
a1ien Mar 26, 2023
53b341a
Merge pull request #164 from a1ien/fix_changelog_url
a1ien Mar 26, 2023
7b0703d
Add a function to disable device discovery
losynix Feb 10, 2023
2f3007b
fix: 404 link for languages
elpiel Apr 1, 2023
0419b10
Merge pull request #159 from losynix/disable_device_discovery
a1ien Apr 2, 2023
2cf0949
Merge pull request #165 from elpiel/patch-1
a1ien Apr 2, 2023
d0851e3
Add serde impls for enums
oysteintveit-nordicsemi Jun 20, 2023
c7d08c7
Merge pull request #167 from h7x4/add-serde-impls
a1ien Jun 20, 2023
f9e6d05
Prepare release
oysteintveit-nordicsemi Aug 23, 2023
abeaa1f
Merge pull request #178 from h7x4/bump-to-0.9.3
a1ien Aug 25, 2023
d1fa27c
bump libusb1-sys to 0.6.4 in rusb
a1ien Aug 25, 2023
03d9873
bLength, bDescriptorType and wTotalLength to descriptors
tuna-f1sh Nov 13, 2023
98641f0
Use &self reference for all DeviceHandle methods
surban Nov 13, 2023
c38563e
Merge pull request #185 from tuna-f1sh/master
a1ien Nov 13, 2023
4b1a7aa
Support pkg_config for MSVC.
spritetong Jan 16, 2024
fd51185
Merge pull request #186 from surban/master
a1ien Feb 6, 2024
15c2910
Merge pull request #191 from spritetong/master
a1ien Feb 6, 2024
307a315
Fix package detection and build when cross-compiling from MSVC to GNU
amyspark Aug 26, 2023
7f5023e
Log callback API added
dmitry-zakablukov Feb 28, 2024
5e8e36e
fix: panic when trying to iterate over an interface with zero endpoints
alufers Mar 5, 2024
aa11ec9
Merge pull request #195 from alufers/fix/iterating-over-zero-endpoint…
a1ien Mar 5, 2024
145c12c
Merge pull request #194 from passware/log_callback_api
a1ien Mar 5, 2024
29694b9
Merge pull request #180 from amyspark/fix-msvc-to-mingw-compilation
a1ien Mar 5, 2024
4a69bca
Replace .get_unchecked_mut() with .as_mut_ptr().add() when accessing …
alufers Mar 30, 2024
132128a
Bump libusb to 1.0.27
alufers Apr 3, 2024
03f6f53
Merge pull request #200 from alufers/fix/get-unchecked-mut-panics
a1ien Apr 15, 2024
bf93814
Added libusb_free_pollfds() in the available FFI methods.
kurkpitaine Apr 17, 2024
b99c8ce
Merge pull request #203 from kurkpitaine/free_pollfds
a1ien Apr 27, 2024
01bfb3e
Merge pull request #161 from alufers/feature/add-missing-fields-to-bos
a1ien Apr 27, 2024
cb13e85
Merge pull request #201 from alufers/fix/update-libusb-to-1.0.27
a1ien Apr 27, 2024
adc50a8
Remove unneeded mut
a1ien Apr 27, 2024
0f07c05
Merge pull request #204 from a1ien/small_fix
a1ien Apr 27, 2024
3f58a23
Release rusb 0.9.4 and libusb 0.7.0
a1ien Apr 27, 2024
f4fc94e
Merge pull request #205 from a1ien/rusb-0.9.4_libusb1-sys-0.7
a1ien Apr 27, 2024
8fac5aa
feat: libusb_init_context and associated structs
dgramop Jul 21, 2024
705eadd
fix: no udev when building for android on linux
dgramop Jul 21, 2024
8f8c3c6
Merge pull request #209 from MerchGuardian/libusb_init_context
a1ien Jul 24, 2024
cd95bb7
Merge pull request #210 from MerchGuardian/android_udev_fix
a1ien Sep 15, 2024
bfac2ec
Added new constructor for languages + tests
JaminMartin Jan 31, 2025
a9e3c6c
Merge pull request #216 from JaminMartin/lang_constructor
a1ien Feb 3, 2025
c7b6280
First try rusb-async
a1ien Sep 4, 2022
122fffc
Mark rusb-async::{Error, Result} as public
bobozaur Apr 28, 2025
bbe4602
Merge branch 'rusb-async' into rusb-async
bobozaur Apr 29, 2025
2b15592
Make TransferPool::new() infallible
bobozaur May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Rust

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

env:
CARGO_TERM_COLOR: always
Expand All @@ -13,18 +13,18 @@ jobs:
check-code:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Install
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libusb-1.0-0-dev
- name: Install
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libusb-1.0-0-dev

- name: Run check and format
run: |
cargo check --all-targets --examples
cargo fmt --check
- name: Run check and format
run: |
cargo check --all-targets --examples
cargo fmt --check

build:
needs: [check-code]
Expand All @@ -34,12 +34,12 @@ jobs:
matrix:
include:
- os: ubuntu-latest
apt: 'libusb-1.0-0-dev'
apt: "libusb-1.0-0-dev"
experimental: false
features: ""

- os: ubuntu-latest
apt: 'libudev-dev'
apt: "libudev-dev"
experimental: false
features: ""

Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
features: ""

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true

Expand Down
48 changes: 47 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
# Changes

## unreleased
## 0.9.4

* bLength, bDescriptorType and wTotalLength to descriptors [#185]
* Use &self reference for all DeviceHandle methods [#186]
* fix: panic when trying to iterate over an interface with zero endpoints [#195]
* Log callback API added [#194]
* Bump libusb1-sys 0.7.0 [#205]

[#185]: https://github.com/a1ien/rusb/pull/185
[#186]: https://github.com/a1ien/rusb/pull/186
[#195]: https://github.com/a1ien/rusb/pull/195
[#194]: https://github.com/a1ien/rusb/pull/194
[#205]: https://github.com/a1ien/rusb/pull/205

## 0.9.3
* impl serde::{Serialize, Deserialize} for public enums [#167]
* Update deprecated doc link about language identifiers [#165]
* Fix changelog URLs for 0.9.2 [#164]


[#167]: https://github.com/a1ien/rusb/pull/167
[#165]: https://github.com/a1ien/rusb/pull/165
[#164]: https://github.com/a1ien/rusb/pull/164

## 0.9.2
* Random corrections around the code [#127]
* examples: list_devices: Add vendor and product name [#128]
* examples: read_devices: Improve usage [#125]
* context: create rusb `Context` from existing `libusb_context` [#135]
* `new` now uses `from_raw` [#135]
* Fix stack use after scope in tests [#138]
* Fix United Kingdom misspelling in languages docs [#137]
* fields.rs: Make request_type function a const fn [#142]
* Increase endpoint descriptor's lifetime [#149]
* Fix timeout documentation [#151]

[#127]: https://github.com/a1ien/rusb/pull/127
[#128]: https://github.com/a1ien/rusb/pull/128
[#125]: https://github.com/a1ien/rusb/pull/125
[#135]: https://github.com/a1ien/rusb/pull/135
[#138]: https://github.com/a1ien/rusb/pull/135
[#137]: https://github.com/a1ien/rusb/pull/137
[#142]: https://github.com/a1ien/rusb/pull/142
[#149]: https://github.com/a1ien/rusb/pull/149
[#151]: https://github.com/a1ien/rusb/pull/151

## 0.9.1
* impl Ord and PartialOrd for Version [#116]

[#116]: https://github.com/a1ien/rusb/pull/116
Expand Down
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rusb"
version = "0.9.1"
version = "0.9.4"
authors = ["David Cuddeback <[email protected]>", "Ilya Averyanov <[email protected]>"]
description = "Rust library for accessing USB devices."
license = "MIT"
Expand All @@ -21,9 +21,10 @@ vendored = [ "libusb1-sys/vendored" ]
members = [ "libusb1-sys", "rusb-async" ]

[dependencies]
libusb1-sys = { path = "libusb1-sys", version = "0.6.0" }
libusb1-sys = { path = "libusb1-sys", version = "0.7" }
libc = "0.2"
serde = { version = "1.0", features = ["derive"], optional = true }

[dev-dependencies]
regex = "1"
usb-ids = "0.2.2"
usb-ids = "1.2023.0"
18 changes: 18 additions & 0 deletions examples/list_devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ fn print_device<T: UsbContext>(device_desc: &DeviceDescriptor, handle: &mut Opti
};

println!("Device Descriptor:");
println!(" bLength {:3}", device_desc.length());
println!(" bDescriptorType {:3}", device_desc.descriptor_type());
println!(
" bcdUSB {:2}.{}{}",
device_desc.usb_version().major(),
Expand Down Expand Up @@ -147,6 +149,12 @@ fn print_device<T: UsbContext>(device_desc: &DeviceDescriptor, handle: &mut Opti

fn print_config<T: UsbContext>(config_desc: &ConfigDescriptor, handle: &mut Option<UsbDevice<T>>) {
println!(" Config Descriptor:");
println!(" bLength {:3}", config_desc.length());
println!(
" bDescriptorType {:3}",
config_desc.descriptor_type()
);
println!(" wTotalLength {:#06x}", config_desc.total_length());
println!(
" bNumInterfaces {:3}",
config_desc.num_interfaces()
Expand Down Expand Up @@ -177,6 +185,11 @@ fn print_interface<T: UsbContext>(
handle: &mut Option<UsbDevice<T>>,
) {
println!(" Interface Descriptor:");
println!(" bLength {:3}", interface_desc.length());
println!(
" bDescriptorType {:3}",
interface_desc.descriptor_type()
);
println!(
" bInterfaceNumber {:3}",
interface_desc.interface_number()
Expand Down Expand Up @@ -219,6 +232,11 @@ fn print_interface<T: UsbContext>(

fn print_endpoint(endpoint_desc: &EndpointDescriptor) {
println!(" Endpoint Descriptor:");
println!(" bLength {:3}", endpoint_desc.length());
println!(
" bDescriptorType {:3}",
endpoint_desc.descriptor_type()
);
println!(
" bEndpointAddress {:#04x} EP {} {:?}",
endpoint_desc.address(),
Expand Down
37 changes: 36 additions & 1 deletion libusb1-sys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
# Changes

## unreleased
## 0.7.0

* fix: Add missing fields to libusb_bos_descriptor and libusb_bos_dev_capability_descriptor [#161]
* Bump libusb to 1.0.27 [#201]
* Remove unneeded mut [#204]

[#161]: https://github.com/a1ien/rusb/pull/161
[#201]: https://github.com/a1ien/rusb/pull/201
[#204]: https://github.com/a1ien/rusb/pull/204

## 0.6.5
* Support pkg_config for MSVC. [#191]
* Fix package detection and build when cross-compiling from MSVC to GNU [#180]
* libusb_set_iso_packet_lengths panics on debug builds in newest nightly (2024-03-27) [#199]
* Added libusb_free_pollfds() in the available FFI methods. [#203]

[#191]: https://github.com/a1ien/rusb/pull/191
[#180]: https://github.com/a1ien/rusb/pull/180
[#199]: https://github.com/a1ien/rusb/pull/199
[#203]: https://github.com/a1ien/rusb/pull/203

## 0.6.3-0.6.4
* Patch for macOS Big Sur and newer allowing to link statically [#133]
* Add libudev include paths as specified by pkg-config [#140]

[#133]: https://github.com/a1ien/rusb/pull/133
[#140]: https://github.com/a1ien/rusb/pull/140


## 0.6.2
* Rename compiled library when vendored libusb is used [#130]

[#130]: https://github.com/a1ien/rusb/pull/130

## 0.6.1
* Add LIBUSB_OPTION_NO_DEVICE_DISCOVERY constant
* Bump vendored libusb version from 1.0.24 to 1.0.25 [#119]

[#119]: https://github.com/a1ien/rusb/pull/119
Expand Down
4 changes: 2 additions & 2 deletions libusb1-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "libusb1-sys"
version = "0.6.4"
version = "0.7.0"
authors = ["David Cuddeback <[email protected]>",
"Ilya Averyanov <[email protected]>"]
description = "FFI bindings for libusb."
Expand Down Expand Up @@ -39,7 +39,7 @@ vendored = []
[dependencies]
libc = "0.2"

[target.'cfg(target_env = "msvc")'.build-dependencies]
[target.'cfg(target_os = "windows")'.build-dependencies]
vcpkg = "0.2"

[build-dependencies]
Expand Down
51 changes: 28 additions & 23 deletions libusb1-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, fs, path::PathBuf};

static VERSION: &str = "1.0.24";
static VERSION: &str = "1.0.27";

fn link(name: &str, bundled: bool) {
use std::env::var;
Expand All @@ -19,17 +19,6 @@ pub fn link_framework(name: &str) {
println!("cargo:rustc-link-lib=framework={}", name);
}

#[cfg(target_env = "msvc")]
fn find_libusb_pkg(_statik: bool) -> bool {
match vcpkg::Config::new().find_package("libusb") {
Ok(_) => true,
Err(e) => {
println!("Can't find libusb pkg: {:?}", e);
false
}
}
}

fn get_macos_major_version() -> Option<usize> {
if !cfg!(target_os = "macos") {
return None;
Expand All @@ -45,8 +34,21 @@ fn get_macos_major_version() -> Option<usize> {
Some(major)
}

#[cfg(not(target_env = "msvc"))]
fn find_libusb_pkg(statik: bool) -> bool {
if std::env::var("CARGO_CFG_TARGET_ENV") == Ok("msvc".into()) {
#[cfg(target_os = "windows")]
return match vcpkg::Config::new().find_package("libusb") {
Ok(_) => true,
Err(e) => {
if pkg_config::probe_library("libusb-1.0").is_ok() {
true
} else {
println!("Can't find libusb pkg: {:?}", e);
false
}
}
};
}
// https://github.com/rust-lang/rust/issues/96943
let needs_rustc_issue_96943_workaround: bool = get_macos_major_version()
.map(|major| major >= 11)
Expand Down Expand Up @@ -156,23 +158,26 @@ fn make_source() {
Some("__attribute__((visibility(\"default\")))"),
);

if let Ok(lib) = pkg_config::probe_library("libudev") {
base_config.define("USE_UDEV", Some("1"));
base_config.define("HAVE_LIBUDEV", Some("1"));
base_config.file(libusb_source.join("libusb/os/linux_udev.c"));
for path in lib.include_paths {
base_config.include(path.to_str().unwrap());
}
};
if std::env::var("CARGO_CFG_TARGET_OS") != Ok("android".into()) {
if let Ok(lib) = pkg_config::probe_library("libudev") {
base_config.define("USE_UDEV", Some("1"));
base_config.define("HAVE_LIBUDEV", Some("1"));
base_config.file(libusb_source.join("libusb/os/linux_udev.c"));
for path in lib.include_paths {
base_config.include(path.to_str().unwrap());
}
};
}

println!("Including posix!");
base_config.file(libusb_source.join("libusb/os/events_posix.c"));
base_config.file(libusb_source.join("libusb/os/threads_posix.c"));
}

if std::env::var("CARGO_CFG_TARGET_OS") == Ok("windows".into()) {
#[cfg(target_env = "msvc")]
base_config.flag("/source-charset:utf-8");
if std::env::var("CARGO_CFG_TARGET_ENV") == Ok("msvc".into()) {
base_config.flag("/source-charset:utf-8");
}

base_config.warnings(false);
base_config.define("OS_WINDOWS", Some("1"));
Expand Down
2 changes: 1 addition & 1 deletion libusb1-sys/libusb
Submodule libusb updated 197 files
Loading