Wait for the specific card to reappear Waiting a maximum timeout, if it hasn't appeared by then, return None
(
api: &mut HidApi,
filter_devs: &[u16],
sn: &str,
)
| 475 | /// Wait for the specific card to reappear |
| 476 | /// Waiting a maximum timeout, if it hasn't appeared by then, return None |
| 477 | fn wait_to_reappear( |
| 478 | api: &mut HidApi, |
| 479 | filter_devs: &[u16], |
| 480 | sn: &str, |
| 481 | ) -> Option<(HidDevice, HidFirmwareInfo)> { |
| 482 | println!(" Waiting for Expansion Card to restart"); |
| 483 | let retries = RESTART_TIMEOUT / RESTART_PERIOD; |
| 484 | |
| 485 | for i in (0..retries).rev() { |
| 486 | os_specific::sleep(RESTART_PERIOD); |
| 487 | api.refresh_devices().unwrap(); |
| 488 | let new_devices = find_devices(api, filter_devs, Some(sn)); |
| 489 | if new_devices.is_empty() { |
| 490 | debug!("No devices found, retrying #{}/{}", retries - i, retries); |
| 491 | continue; |
| 492 | } |
| 493 | let dev_info = &new_devices[0]; |
| 494 | if let Ok(device) = dev_info.open_device(api) { |
| 495 | magic_unlock(&device); |
| 496 | let info = get_fw_info(&device); |
| 497 | return Some((device, info)); |
| 498 | } |
| 499 | } |
| 500 | None |
| 501 | } |
| 502 | |
| 503 | // HID Report on device before updating Firmware 2 |
| 504 | // Usage Page (Vendor) |
no test coverage detected