pub(super) fn drain(&self) {
        log::debug!("Draining probe of any pending data.");

        match self {
            CmsisDapDevice::V1 {
                handle,
                report_size,
                ..
            } => loop {
                let mut discard = vec![0u8; report_size + 1];
                match handle.read_timeout(&mut discard, 1) {
                    Ok(n) if n != 0 => continue,
                    _ => break,
                }
            },

            CmsisDapDevice::V2 {
                handle,
                in_ep,
                max_packet_size,
                ..
            } => {
                let timeout = Duration::from_millis(1);
                let mut discard = vec![0u8; *max_packet_size];
                loop {
                    match handle.read_bulk(*in_ep, &mut discard, timeout) {
                        Ok(n) if n != 0 => continue,
                        _ => break,
                    }
                }
            }
        }
    }
/// Drain any pending data from the probe, ensuring future responses are
/// synchronised to requests. Swallows any errors, which are expected if
/// there is no pending data to read.
Drain any pending data from the probe, ensuring future responses are
synchronised to requests. Swallows any errors, which are expected if
there is no pending data to read.
Drain any pending data from the probe ensuring future responses are synchronised to requests . Swallows any errors which are expected if there is no pending data to read .
pub(super) fn drain(&self) {
        log::debug!("Draining probe of any pending data.");
        match self {
            CmsisDapDevice::V1 {
                handle,
                report_size,
                ..
            } => loop {
                let mut discard = vec![0u8; report_size + 1];
                match handle.read_timeout(&mut discard, 1) {
                    Ok(n) if n != 0 => continue,
                    _ => break,
                }
            },
            CmsisDapDevice::V2 {
                handle,
                in_ep,
                max_packet_size,
                ..
            } => {
                let timeout = Duration::from_millis(1);
                let mut discard = vec![0u8; *max_packet_size];
                loop {
                    match handle.read_bulk(*in_ep, &mut discard, timeout) {
                        Ok(n) if n != 0 => continue,
                        _ => break,
                    }
                }
            }
        }
    }
pub ( super ) fn drain ( & self ) { log :: debug ! ( " " ) ; match self { CmsisDapDevice :: V1 { handle , report_size , .. } => loop { let mut discard = vec ! [ 0u8 report_size 1 ] ; match handle . read_timeout ( & mut discard , 1 ) { Ok ( n ) if n != 0 => continue , _ => break , } } , CmsisDapDevice :: V2 { handle , in_ep , max_packet_size , .. } => { let timeout = Duration :: from_millis ( 1 ) ; let mut discard = vec ! [ 0u8 max_packet_size ] ; loop { match handle . read_bulk ( * in_ep , & mut discard , timeout ) { Ok ( n ) if n != 0 => continue , _ => break , } } } } }
Drain any pending data from the probe, ensuring future responses are
synchronised to requests.
Drain any pending data from the probe ensuring future responses are synchronised to requests .
&self
&self