Skip to content

Commit

Permalink
Merge pull request #18 from h7x4/modify-devicelist-during-execution
Browse files Browse the repository at this point in the history
Add support for modifying devicelist during execution
  • Loading branch information
jiegec authored Aug 23, 2023
2 parents 7f63809 + 6ed0293 commit 0f844e1
Show file tree
Hide file tree
Showing 6 changed files with 353 additions and 92 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "A library to run USB/IP server"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1.22.0", features = ["rt", "net", "io-util"] }
tokio = { version = "1.22.0", features = ["rt", "net", "io-util", "sync"] }
log = "0.4.17"
num-traits = "0.2.15"
num-derive = "0.3.3"
Expand Down
18 changes: 10 additions & 8 deletions examples/cdc_acm_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ async fn main() {
let handler =
Arc::new(Mutex::new(Box::new(usbip::cdc::UsbCdcAcmHandler::new())
as Box<dyn usbip::UsbInterfaceHandler + Send>));
let server = usbip::UsbIpServer::new_simulated(vec![usbip::UsbDevice::new(0).with_interface(
usbip::ClassCode::CDC as u8,
usbip::cdc::CDC_ACM_SUBCLASS,
0x00,
"Test CDC ACM",
usbip::cdc::UsbCdcAcmHandler::endpoints(),
handler.clone(),
)]);
let server = Arc::new(usbip::UsbIpServer::new_simulated(vec![
usbip::UsbDevice::new(0).with_interface(
usbip::ClassCode::CDC as u8,
usbip::cdc::CDC_ACM_SUBCLASS,
0x00,
"Test CDC ACM",
usbip::cdc::UsbCdcAcmHandler::endpoints(),
handler.clone(),
),
]));
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 3240);
tokio::spawn(usbip::server(addr, server));

Expand Down
28 changes: 15 additions & 13 deletions examples/hid_keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ async fn main() {
Box::new(usbip::hid::UsbHidKeyboardHandler::new_keyboard())
as Box<dyn usbip::UsbInterfaceHandler + Send>,
));
let server = usbip::UsbIpServer::new_simulated(vec![usbip::UsbDevice::new(0).with_interface(
usbip::ClassCode::HID as u8,
0x00,
0x00,
"Test HID",
vec![usbip::UsbEndpoint {
address: 0x81, // IN
attributes: 0x03, // Interrupt
max_packet_size: 0x08, // 8 bytes
interval: 10,
}],
handler.clone(),
)]);
let server = Arc::new(usbip::UsbIpServer::new_simulated(vec![
usbip::UsbDevice::new(0).with_interface(
usbip::ClassCode::HID as u8,
0x00,
0x00,
"Test HID",
vec![usbip::UsbEndpoint {
address: 0x81, // IN
attributes: 0x03, // Interrupt
max_packet_size: 0x08, // 8 bytes
interval: 10,
}],
handler.clone(),
),
]));
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 3240);
tokio::spawn(usbip::server(addr, server));

Expand Down
3 changes: 2 additions & 1 deletion examples/host.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use env_logger;
use std::net::*;
use std::sync::Arc;
use std::time::Duration;
use usbip;

#[tokio::main]
async fn main() {
env_logger::init();
let server = usbip::UsbIpServer::new_from_host();
let server = Arc::new(usbip::UsbIpServer::new_from_host());
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 3240);
tokio::spawn(usbip::server(addr, server));

Expand Down
Loading

0 comments on commit 0f844e1

Please sign in to comment.