simple_host/
simple_host.rs1use upc::{
4 host::{connect, find_interface},
5 Class,
6};
7
8#[tokio::main(flavor = "current_thread")]
9async fn main() -> std::io::Result<()> {
10 let class = Class::vendor_specific(0x01, 0);
11
12 let dev_info = nusb::list_devices()
14 .await?
15 .find(|d| d.vendor_id() == 0x1209 && d.product_id() == 0x0001)
16 .expect("device not found");
17 let iface = find_interface(&dev_info, class)?;
18 let dev = dev_info.open().await?;
19
20 let (tx, mut rx) = connect(dev, iface, b"hello").await?;
22 tx.send(b"ping"[..].into()).await?;
23 let reply = rx.recv().await?;
24 println!("received: {:?}", reply);
25 Ok(())
26}