MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / wait_to_reappear

Function wait_to_reappear

framework_lib/src/ccgx/hid.rs:477–501  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

475/// Wait for the specific card to reappear
476/// Waiting a maximum timeout, if it hasn't appeared by then, return None
477fn 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)

Callers 1

flash_firmwareFunction · 0.85

Calls 5

sleepFunction · 0.85
find_devicesFunction · 0.85
magic_unlockFunction · 0.85
get_fw_infoFunction · 0.85
open_deviceMethod · 0.45

Tested by

no test coverage detected