pub fn initialize_probe_data(
    testchannels: &[Mutex<CombinedTestChannel>; 4],
    data: HiveProbeData,
) -> Result<(), InitError> {
    let mut found_probes = Probe::list_all();

    log::debug!(
        "Found {} attached probes:\n{:#?}",
        found_probes.len(),
        found_probes
    );

    for (channel_idx, probe_info) in data.iter().enumerate().filter_map(|(channel_idx, data)| {
        if data.is_some() {
            return Some((channel_idx, data.as_ref().unwrap()));
        }
        None
    }) {
        let mut found_probes_idx = 0;
        while found_probes_idx < found_probes.len() {
            if found_probes[found_probes_idx].identifier == probe_info.identifier
                && found_probes[found_probes_idx].vendor_id == probe_info.vendor_id
                && found_probes[found_probes_idx].product_id == probe_info.product_id
                && found_probes[found_probes_idx].serial_number == probe_info.serial_number
                && found_probes[found_probes_idx].hid_interface == probe_info.hid_interface
            {
                let tss = testchannels[channel_idx].lock().unwrap();

                let probe_info = found_probes.remove(found_probes_idx);
                let probe = probe_info.open().expect("TODO either skip probe or panic");

                tss.bind_probe(probe, probe_info);
                break;
            } else {
                found_probes_idx += 1;
            }
        }
    }

    // Check for data desync
    if !found_probes.is_empty() {
        log::error!("Encountered data desync during probe data initialization.\nData received:\n{:#?}\nProbes detected by the application, which are not found in the received data:\n{:#?}", data, found_probes);
        return Err(InitError::ProbeInitDesync);
    }

    Ok(())
}
/// Initializes Testchannels with the debug probes and checks for data desyncs between the currently detected probe hardware and the provided data
Initializes Testchannels with the debug probes and checks for data desyncs between the currently detected probe hardware and the provided data
Initializes Testchannels with the debug probes and checks for data desyncs between the currently detected probe hardware and the provided data
pub fn initialize_probe_data(
    testchannels: &[Mutex<CombinedTestChannel>; 4],
    data: HiveProbeData,
) -> Result<(), InitError> {
    let mut found_probes = Probe::list_all();
    log::debug!(
        "Found {} attached probes:\n{:#?}",
        found_probes.len(),
        found_probes
    );
    for (channel_idx, probe_info) in data.iter().enumerate().filter_map(|(channel_idx, data)| {
        if data.is_some() {
            return Some((channel_idx, data.as_ref().unwrap()));
        }
        None
    }) {
        let mut found_probes_idx = 0;
        while found_probes_idx < found_probes.len() {
            if found_probes[found_probes_idx].identifier == probe_info.identifier
                && found_probes[found_probes_idx].vendor_id == probe_info.vendor_id
                && found_probes[found_probes_idx].product_id == probe_info.product_id
                && found_probes[found_probes_idx].serial_number == probe_info.serial_number
                && found_probes[found_probes_idx].hid_interface == probe_info.hid_interface
            {
                let tss = testchannels[channel_idx].lock().unwrap();
                let probe_info = found_probes.remove(found_probes_idx);
                let probe = probe_info.open().expect("TODO either skip probe or panic");
                tss.bind_probe(probe, probe_info);
                break;
            } else {
                found_probes_idx += 1;
            }
        }
    }
    // Check for data desync
    if !found_probes.is_empty() {
        log::error!("Encountered data desync during probe data initialization.\nData received:\n{:#?}\nProbes detected by the application, which are not found in the received data:\n{:#?}", data, found_probes);
        return Err(InitError::ProbeInitDesync);
    }
    Ok(())
}
pub fn initialize_probe_data ( testchannels : & [ Mutex < CombinedTestChannel > ; 4 ] , data : HiveProbeData , ) -> Result < ( ) , InitError > { let mut found_probes = Probe :: list_all ( ) ; log :: debug ! ( " \n " found_probes len ( ) found_probes ) ; for ( channel_idx , probe_info ) in data . iter ( ) . enumerate ( ) . filter_map ( | ( channel_idx , data ) | { if data . is_some ( ) { return Some ( ( channel_idx , data . as_ref ( ) . unwrap ( ) ) ) ; } None } ) { let mut found_probes_idx = 0 ; while found_probes_idx < found_probes . len ( ) { if found_probes [ found_probes_idx ] . identifier == probe_info . identifier && found_probes [ found_probes_idx ] . vendor_id == probe_info . vendor_id && found_probes [ found_probes_idx ] . product_id == probe_info . product_id && found_probes [ found_probes_idx ] . serial_number == probe_info . serial_number && found_probes [ found_probes_idx ] . hid_interface == probe_info . hid_interface { let tss = testchannels [ channel_idx ] . lock ( ) . unwrap ( ) ; let probe_info = found_probes . remove ( found_probes_idx ) ; let probe = probe_info . open ( ) . expect ( " " ) ; tss . bind_probe ( probe , probe_info ) ; break ; } else { found_probes_idx += 1 ; } } } // Check for data desync if ! found_probes . is_empty ( ) { log :: error ! ( " \n \n \n \n " data found_probes ) ; return Err ( InitError :: ProbeInitDesync ) ; } Ok ( ( ) ) }
Initializes Testchannels with the debug probes and checks for data desyncs between the currently detected probe hardware and the provided data
Initializes Testchannels with the debug probes and checks for data desyncs between the currently detected probe hardware and the provided data
testchannels
&[Mutex<CombinedTestChannel>; 4]
data
HiveProbeData