fn read_ubx_message(
        &mut self,
        msg_len: usize,
        dump_ck: bool,
    ) -> Result<(bool, usize), DI::InterfaceError> {
        // The length sent in the header is defined as being that of the payload only.
        // It does not include the Preamble, Message Class, Message ID, Length, or CRC fields.
        // The number format of the length field is a Little-Endian unsigned 16-bit integer.

        let max_pay_idx = UBX_HEADER_LEN + msg_len;
        let max_msg_idx = max_pay_idx + UBX_CKSUM_LEN;
        let desired_count = max_msg_idx - UBX_HEADER_LEN;
        self.read_buf[max_msg_idx] = 0;
        let read_count = self
            .di
            .read_many(&mut self.read_buf[UBX_HEADER_LEN..max_msg_idx])?;
        if read_count < desired_count {
            // unable to read enough bytes to fill the message struct
            return Ok((false, 0));
        }
        let calc_ck =
            Self::checksum_for_payload(&self.read_buf[..max_pay_idx], dump_ck);
        let recvd_ck =
            &self.read_buf[(max_msg_idx - UBX_CKSUM_LEN)..max_msg_idx];
        let matches = calc_ck[0] == recvd_ck[0] && calc_ck[1] == recvd_ck[1];
        if matches {
            Ok((true, max_pay_idx))
        } else {
            Ok((false, 0))
        }
    }
/// Read our interface for a message of known size
///
Read our interface for a message of known size
Read our interface for a message of known size
fn read_ubx_message(
        &mut self,
        msg_len: usize,
        dump_ck: bool,
    ) -> Result<(bool, usize), DI::InterfaceError> {
        // The length sent in the header is defined as being that of the payload only.
        // It does not include the Preamble, Message Class, Message ID, Length, or CRC fields.
        // The number format of the length field is a Little-Endian unsigned 16-bit integer.
        let max_pay_idx = UBX_HEADER_LEN + msg_len;
        let max_msg_idx = max_pay_idx + UBX_CKSUM_LEN;
        let desired_count = max_msg_idx - UBX_HEADER_LEN;
        self.read_buf[max_msg_idx] = 0;
        let read_count = self
            .di
            .read_many(&mut self.read_buf[UBX_HEADER_LEN..max_msg_idx])?;
        if read_count < desired_count {
            // unable to read enough bytes to fill the message struct
            return Ok((false, 0));
        }
        let calc_ck =
            Self::checksum_for_payload(&self.read_buf[..max_pay_idx], dump_ck);
        let recvd_ck =
            &self.read_buf[(max_msg_idx - UBX_CKSUM_LEN)..max_msg_idx];
        let matches = calc_ck[0] == recvd_ck[0] && calc_ck[1] == recvd_ck[1];
        if matches {
            Ok((true, max_pay_idx))
        } else {
            Ok((false, 0))
        }
    }
fn read_ubx_message ( & mut self , msg_len : usize , dump_ck : bool , ) -> Result < ( bool , usize ) , DI :: InterfaceError > { // The length sent in the header is defined as being that of the payload only. // It does not include the Preamble, Message Class, Message ID, Length, or CRC fields. // The number format of the length field is a Little-Endian unsigned 16-bit integer. let max_pay_idx = UBX_HEADER_LEN + msg_len ; let max_msg_idx = max_pay_idx + UBX_CKSUM_LEN ; let desired_count = max_msg_idx - UBX_HEADER_LEN ; self . read_buf [ max_msg_idx ] = 0 ; let read_count = self . di . read_many ( & mut self . read_buf [ UBX_HEADER_LEN .. max_msg_idx ] ) ? ; if read_count < desired_count { // unable to read enough bytes to fill the message struct return Ok ( ( false , 0 ) ) ; } let calc_ck = Self :: checksum_for_payload ( & self . read_buf [ .. max_pay_idx ] , dump_ck ) ; let recvd_ck = & self . read_buf [ ( max_msg_idx - UBX_CKSUM_LEN ) .. max_msg_idx ] ; let matches = calc_ck [ 0 ] == recvd_ck [ 0 ] && calc_ck [ 1 ] == recvd_ck [ 1 ] ; if matches { Ok ( ( true , max_pay_idx ) ) } else { Ok ( ( false , 0 ) ) } }
Read our interface for a message of known size
Read our interface for a message of known size
&mut self
msg_len
usize
dump_ck
bool
&mut self
msg_len
usize
dump_ck
bool