From f43d92a9827967b86f73f811df262fc53b75c396 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 14 Jan 2024 18:00:54 +0100 Subject: Move cutting the length prefix to the fake receiver --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7423e3f..42044be 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,8 @@ async fn main() -> std::io::Result<()> { let mut buf = [0; 1024]; while let Ok((len, addr)) = sock_r.recv_from(&mut buf).await { println!("{:?} bytes received from {:?}", len, addr); - let packet = buf[..len].to_vec(); + // Cut the length prefix, which isn't returned by the real radio + let packet = buf[2..len].to_vec(); let rssi = 0f64; radio_rx_queue.send((packet, rssi)).await.expect("Inject frame"); } @@ -80,7 +81,7 @@ async fn main() -> std::io::Result<()> { while let Some((packet_data, rssi)) = packet_receive.recv().await { debug!("RX RSSI {} len {}", rssi, packet_data.len()); let mut buf = [0; MAX_PACKET_LEN]; - match ham_cats::packet::Packet::fully_decode(&packet_data[2..], &mut buf) { + match ham_cats::packet::Packet::fully_decode(&packet_data, &mut buf) { Ok(packet) => { if let Some(ident) = packet.identification() { debug!(" From {}-{}", ident.callsign, ident.ssid); -- cgit v1.2.3