Updated the way you build an interface

This commit is contained in:
G2-Games 2023-09-25 09:09:33 -05:00
parent 797c37ded6
commit cc2918fb2e
2 changed files with 6 additions and 3 deletions

View file

@ -182,9 +182,9 @@ impl NetMDInterface {
const MAX_INTERIM_READ_ATTEMPTS: u8 = 4; const MAX_INTERIM_READ_ATTEMPTS: u8 = 4;
const INTERIM_RESPONSE_RETRY_INTERVAL: u32 = 100; const INTERIM_RESPONSE_RETRY_INTERVAL: u32 = 100;
pub fn new(device: rusb::DeviceHandle<rusb::GlobalContext>, descriptor: rusb::DeviceDescriptor) -> Self { pub fn new(device: rusb::DeviceHandle<rusb::GlobalContext>, descriptor: rusb::DeviceDescriptor) -> Result<Self, Box<dyn Error>> {
let net_md_device = base::NetMD::new(device, descriptor).unwrap(); let net_md_device = base::NetMD::new(device, descriptor).unwrap();
NetMDInterface { net_md_device } Ok(NetMDInterface { net_md_device })
} }
fn construct_multibyte(&self, buffer: &Vec<u8>, n: u8, offset: &mut usize) -> u32 { fn construct_multibyte(&self, buffer: &Vec<u8>, n: u8, offset: &mut usize) -> u32 {

View file

@ -19,7 +19,10 @@ fn main() {
new_device.read_product_string_ascii(&device_desc) new_device.read_product_string_ascii(&device_desc)
); );
let player_controller = netmd::interface::NetMDInterface::new(new_device, device_desc); let player_controller = match netmd::interface::NetMDInterface::new(new_device, device_desc) {
Ok(player) => player,
Err(_) => continue
};
println!( println!(
"Player Model: {}", "Player Model: {}",