mirror of
https://github.com/G2-Games/minidisc-cli.git
synced 2025-04-19 03:32:53 -05:00
Updated cross-usb
to v0.4.0
This commit is contained in:
parent
0a75b6a013
commit
885e7508fd
4 changed files with 11 additions and 10 deletions
|
@ -37,7 +37,7 @@ nofmt = "1.0.0"
|
|||
once_cell = "1.18.0"
|
||||
unicode-normalization = "0.1.22"
|
||||
regex = "1.10"
|
||||
cross_usb = "0.3"
|
||||
cross_usb = "0.4"
|
||||
num-derive = "0.4.2"
|
||||
num-traits = "0.2.14"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -6,8 +6,8 @@ use thiserror::Error;
|
|||
|
||||
// USB stuff
|
||||
use cross_usb::prelude::*;
|
||||
use cross_usb::usb::{ControlIn, ControlOut, ControlType, Recipient, UsbError};
|
||||
use cross_usb::{Descriptor, Interface};
|
||||
use cross_usb::usb::{ControlIn, ControlOut, ControlType, Recipient, Error};
|
||||
use cross_usb::{DeviceInfo, Interface};
|
||||
|
||||
use super::utils::cross_sleep;
|
||||
|
||||
|
@ -114,7 +114,7 @@ pub enum NetMDError {
|
|||
UnknownDevice(DeviceId),
|
||||
|
||||
#[error("usb connection error")]
|
||||
UsbError(#[from] UsbError),
|
||||
UsbError(#[from] Error),
|
||||
}
|
||||
|
||||
/// A low-level USB connection to a NetMD device.
|
||||
|
@ -132,7 +132,7 @@ impl NetMD {
|
|||
const READ_REPLY_RETRY_INTERVAL: u32 = 10;
|
||||
|
||||
/// Creates a new interface to a NetMD device
|
||||
pub async fn new(usb_descriptor: Descriptor) -> Result<Self, NetMDError> {
|
||||
pub async fn new(usb_descriptor: DeviceInfo) -> Result<Self, NetMDError> {
|
||||
let mut model = DeviceId {
|
||||
vendor_id: usb_descriptor.vendor_id().await,
|
||||
product_id: usb_descriptor.product_id().await,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![cfg_attr(debug_assertions, allow(dead_code))]
|
||||
use cross_usb::Descriptor;
|
||||
use cross_usb::DeviceInfo;
|
||||
use num_derive::FromPrimitive;
|
||||
use num_traits::FromPrimitive;
|
||||
use regex::Regex;
|
||||
|
@ -278,7 +278,7 @@ pub struct NetMDContext {
|
|||
|
||||
impl NetMDContext {
|
||||
/// Create a new context to control a NetMD device
|
||||
pub async fn new(device: Descriptor) -> Result<Self, InterfaceError> {
|
||||
pub async fn new(device: DeviceInfo) -> Result<Self, InterfaceError> {
|
||||
let interface = NetMDInterface::new(device).await?;
|
||||
|
||||
Ok(Self { interface })
|
||||
|
|
|
@ -306,11 +306,14 @@ pub struct NetMDInterface {
|
|||
|
||||
#[allow(dead_code)]
|
||||
impl NetMDInterface {
|
||||
/// The maximum number of times to retry after an interim response
|
||||
const MAX_INTERIM_READ_ATTEMPTS: u8 = 4;
|
||||
|
||||
/// The amount of time to wait after an interim response (in milliseconds)
|
||||
const INTERIM_RESPONSE_RETRY_INTERVAL: u32 = 100;
|
||||
|
||||
/// Get a new interface to a NetMD device
|
||||
pub async fn new(device: cross_usb::Descriptor) -> Result<Self, InterfaceError> {
|
||||
pub async fn new(device: cross_usb::DeviceInfo) -> Result<Self, InterfaceError> {
|
||||
let device = base::NetMD::new(device).await?;
|
||||
Ok(NetMDInterface { device })
|
||||
}
|
||||
|
@ -618,8 +621,6 @@ impl NetMDInterface {
|
|||
pub async fn disc_present(&mut self) -> Result<bool, InterfaceError> {
|
||||
let status = self.status().await?;
|
||||
|
||||
println!("{:X?}", status);
|
||||
|
||||
Ok(status[4] == 0x40)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue