X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/71a448efcc3c8f53d523c291f12b0f08f3e2f372..4cfda08117c4288a5408d45db1ef4be82f4facaa:/m17core/src/decode.rs?ds=sidebyside diff --git a/m17core/src/decode.rs b/m17core/src/decode.rs index 7ec2224..115ff63 100755 --- a/m17core/src/decode.rs +++ b/m17core/src/decode.rs @@ -62,6 +62,7 @@ pub(crate) fn sync_burst_correlation(target: [i8; 8], samples: &[f32]) -> (f32, if gain < SYNC_MIN_GAIN { return (f32::MAX, gain, shift); } + let mut diff = 0.0; for i in 0..8 { let sym_diff = (((samples[i * 10] - shift) / gain) - target[i] as f32).abs(); @@ -94,7 +95,7 @@ pub(crate) fn parse_lsf(frame: &[f32] /* length 192 */) -> Option { None => return None, }; debug!("full lsf: {:?}", lsf.0); - let crc = lsf.crc(); + let crc = lsf.check_crc(); debug!("recv crc: {:04X}", crc); debug!("destination: {:?}", lsf.destination()); debug!("source: {:?}", lsf.source()); @@ -141,8 +142,10 @@ pub(crate) fn parse_packet(frame: &[f32] /* length 192 */) -> Option packet, None => return None, }; - let final_frame = (packet[25] & 0x80) > 0; - let number = (packet[25] >> 2) & 0x01f; + // TODO: the spec is inconsistent about which bit in packet[25] is EOF + // https://github.com/M17-Project/M17_spec/issues/147 + let final_frame = (packet[25] & 0x04) > 0; + let number = packet[25] >> 3; let counter = if final_frame { PacketFrameCounter::FinalFrame { payload_len: number as usize,