Updated code in prep for cross_usb v0.2.0

This commit is contained in:
G2-Games 2024-02-01 18:09:20 -06:00
parent 7b32c43dcc
commit 9784e32f99
2 changed files with 11 additions and 4 deletions

View file

@ -161,7 +161,7 @@ impl NetMD {
.await .await
{ {
Ok(size) => size, Ok(size) => size,
Err(error) => return Err(error), Err(error) => return Err(error.into()),
}; };
let length_bytes = u16::from_le_bytes([poll_result[2], poll_result[3]]); let length_bytes = u16::from_le_bytes([poll_result[2], poll_result[3]]);
@ -215,7 +215,7 @@ impl NetMD {
.await .await
{ {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(error) => Err(error), Err(error) => Err(error.into()),
} }
} }
@ -323,6 +323,6 @@ impl NetMD {
} }
pub async fn write_bulk(&mut self, data: &[u8]) -> Result<usize, Box<dyn Error>> { pub async fn write_bulk(&mut self, data: &[u8]) -> Result<usize, Box<dyn Error>> {
self.usb_interface.bulk_out(BULK_WRITE_ENDPOINT, data).await Ok(self.usb_interface.bulk_out(BULK_WRITE_ENDPOINT, data).await?)
} }
} }

View file

@ -1,9 +1,16 @@
use minidisc_rs::netmd::interface; use minidisc_rs::netmd::interface;
use cross_usb::usb::Device; use cross_usb::usb::Device;
use cross_usb::device_filter;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let device = cross_usb::get_device(0x054c, 0x0186).await.unwrap(); // Can find devices this way
let filter = vec![
device_filter!{vendor_id:0x054c,product_id:0x0186}, // MZ-NH600
device_filter!{vendor_id:0x054c,product_id:0x00c9}, // MZ-NF610
];
let device = cross_usb::get_device_filter(filter).await.expect("No device found matching critera");
dbg!(device.vendor_id().await); dbg!(device.vendor_id().await);