Skip to content

Commit 25a10f6

Browse files
authored
Merge pull request #160 from genkiinstruments/usb-gadget-winusb
Update usb-gadget dependency + add WinUSB compatibility and IADs
2 parents b121537 + acf16d8 commit 25a10f6

4 files changed

Lines changed: 17 additions & 29 deletions

File tree

example/server-usb-gadget/Cargo.lock

Lines changed: 7 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/server-usb-gadget/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
postcard-rpc = { version = "0.12", features = [ "usb-gadget", "tokio", "use-std"] }
88

99
tokio = { version = "1.32", features = ["rt", "sync"] }
10-
usb-gadget = { version = "0.7", features = ["tokio"] }
10+
usb-gadget = { version = "1.1", features = ["tokio"] }
1111
static_cell = "2.1.1"
1212

1313
workbook-icd = { path = "../workbook-icd" }

source/postcard-rpc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ optional = true
177177

178178
[target.'cfg(target_os = "linux")'.dependencies.usb-gadget]
179179
package = "usb-gadget"
180-
version = "0.7"
180+
version = "1.1"
181181
optional = true
182182

183183
[target.'cfg(target_os = "linux")'.dependencies.bytes]

source/postcard-rpc/src/server/impls/usb_gadget.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub mod dispatch_impl {
4444

4545
pub use crate::server::impls::tokio_shared::tokio_spawn as spawn_fn;
4646

47-
use usb_gadget::function::custom::Custom;
47+
use usb_gadget::function::custom::{Association, Custom, OsExtCompat};
4848
use usb_gadget::{Gadget, RegGadget};
4949

5050
use crate::server::impls::usb_gadget::{UsbGadgetWireRx, UsbGadgetWireTx};
@@ -80,9 +80,15 @@ pub mod dispatch_impl {
8080
let (ep_tx, ep_tx_dir) = EndpointDirection::device_to_host();
8181
let (ep_rx, ep_rx_dir) = EndpointDirection::host_to_device();
8282

83+
let class = Class::vendor_specific(0x00, 0x00);
84+
let iname = "postcard-rpc";
8385
let (mut custom, handle) = Custom::builder()
8486
.with_interface(
85-
Interface::new(Class::vendor_specific(0, 0), "postcard-rpc")
87+
Interface::new(class, iname)
88+
.with_os_ext_compat(OsExtCompat::winusb())
89+
// NOTE: IADs are currently broken on upstream usb-gadget - but we want this
90+
// https://github.com/surban/usb-gadget/issues/25
91+
.with_association(&Association::new(class, iname))
8692
.with_endpoint(Endpoint::bulk(ep_tx_dir))
8793
.with_endpoint(Endpoint::bulk(ep_rx_dir)),
8894
)

0 commit comments

Comments
 (0)