From e8bfa38476bc1f18a4c709dcdfff8c8737a89814 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 23 May 2023 10:10:03 -0600 Subject: [PATCH 01/44] Fix silly copyright space --- rust/oxide-bin/src/main.rs | 2 +- rust/oxide-config/src/lib.rs | 2 +- rust/oxide-decoders/src/decoders/acars.rs | 2 +- rust/oxide-decoders/src/lib.rs | 2 +- rust/oxide-logging/src/lib.rs | 2 +- rust/oxide-output/src/lib.rs | 2 +- rust/oxide-rtlsdr/src/lib.rs | 2 +- rust/oxide-scanner/src/lib.rs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rust/oxide-bin/src/main.rs b/rust/oxide-bin/src/main.rs index 0c2b182..038fbc0 100644 --- a/rust/oxide-bin/src/main.rs +++ b/rust/oxide-bin/src/main.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Fred Clausen +// Copyright (C) 2023 Fred Clausen // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/rust/oxide-config/src/lib.rs b/rust/oxide-config/src/lib.rs index 2b9fb43..e57ca83 100644 --- a/rust/oxide-config/src/lib.rs +++ b/rust/oxide-config/src/lib.rs @@ -19,7 +19,7 @@ const MAX_GAIN: f32 = 60.0; about, long_about = "ACARS Oxide is a program that allows you to receive and decode ACARS and VDLM2 messages." )] -// Copyright (C) 2023 Fred Clausen +// Copyright (C) 2023 Fred Clausen // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index bfda72a..6399726 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Fred Clausen +// Copyright (C) 2023 Fred Clausen // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/rust/oxide-decoders/src/lib.rs b/rust/oxide-decoders/src/lib.rs index 05ddb88..395b13c 100644 --- a/rust/oxide-decoders/src/lib.rs +++ b/rust/oxide-decoders/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Fred Clausen +// Copyright (C) 2023 Fred Clausen // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/rust/oxide-logging/src/lib.rs b/rust/oxide-logging/src/lib.rs index 0048a9e..f1de02e 100644 --- a/rust/oxide-logging/src/lib.rs +++ b/rust/oxide-logging/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Fred Clausen +// Copyright (C) 2023 Fred Clausen // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/rust/oxide-output/src/lib.rs b/rust/oxide-output/src/lib.rs index d64c0ec..753795e 100644 --- a/rust/oxide-output/src/lib.rs +++ b/rust/oxide-output/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Fred Clausen +// Copyright (C) 2023 Fred Clausen // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/rust/oxide-rtlsdr/src/lib.rs b/rust/oxide-rtlsdr/src/lib.rs index cc0d262..762fcf9 100644 --- a/rust/oxide-rtlsdr/src/lib.rs +++ b/rust/oxide-rtlsdr/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Fred Clausen +// Copyright (C) 2023 Fred Clausen // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/rust/oxide-scanner/src/lib.rs b/rust/oxide-scanner/src/lib.rs index aa3bebc..7401cd8 100644 --- a/rust/oxide-scanner/src/lib.rs +++ b/rust/oxide-scanner/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Fred Clausen +// Copyright (C) 2023 Fred Clausen // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License From 614e2d30d333e884aa1d835888393c9c85618b74 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 23 May 2023 10:10:22 -0600 Subject: [PATCH 02/44] bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f6638d7..8a17ebc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ members = [ [workspace.package] edition = "2021" -version = "0.1.1" +version = "0.1.2" authors = ["Fred Clausen"] description = "ACARS Oxide. A utility to receive, via librtlsdr and RTL-SDR dongle(s), ACARS and VDLM2 messages." documentation = "https://github.com/sdr-enthusiasts/acars-oxide" From b00e713e5a3b66c1fcf5b57864f1c1b64f9fb5f0 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 23 May 2023 10:16:35 -0600 Subject: [PATCH 03/44] make all acars consts usizes --- rust/oxide-decoders/src/decoders/acars.rs | 16 +++++++--------- rust/oxide-rtlsdr/src/lib.rs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 6399726..ad2683d 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -25,11 +25,11 @@ use std::time::SystemTime; use std::time::UNIX_EPOCH; use tokio::sync::mpsc::UnboundedSender; -pub const INTRATE: i32 = 12500; +pub const INTRATE: usize = 12500; pub const RTLOUTBUFSZ: usize = 1024; -const FLEN: i32 = (INTRATE / 1200) + 1; +const FLEN: usize = (INTRATE / 1200) + 1; const MFLTOVER: usize = 12; -const FLENO: usize = FLEN as usize * MFLTOVER + 1; +const FLENO: usize = FLEN * MFLTOVER + 1; const PLLG: f32 = 38e-4; const PLLC: f32 = 0.52; const SYN: u8 = 0x16; @@ -416,7 +416,7 @@ pub struct ACARSDecoder { msk_bit_count: i32, msk_s: u32, idx: u32, - inb: [Complex; FLEN as usize], + inb: [Complex; FLEN], outbits: u8, // original was unsigned char..... nbits: i32, acars_state: ACARSState, @@ -468,7 +468,7 @@ impl ACARSDecoder { msk_bit_count: 0, msk_s: 0, idx: 0, - inb: [Complex::new(0.0, 0.0); FLEN as usize], + inb: [Complex::new(0.0, 0.0); FLEN], outbits: 0, nbits: 8, acars_state: ACARSState::Wsyn, @@ -511,10 +511,8 @@ impl ACARSDecoder { o = MFLTOVER as f32 }; - for j in 0..FLEN as usize { - v = v.add( - self.h[o as usize] * self.inb[(j + self.idx as usize) % FLEN as usize], - ); + for j in 0..FLEN { + v = v.add(self.h[o as usize] * self.inb[(j + self.idx as usize) % FLEN]); o += MFLTOVER as f32; } diff --git a/rust/oxide-rtlsdr/src/lib.rs b/rust/oxide-rtlsdr/src/lib.rs index 762fcf9..167fd0c 100644 --- a/rust/oxide-rtlsdr/src/lib.rs +++ b/rust/oxide-rtlsdr/src/lib.rs @@ -94,7 +94,7 @@ impl RtlSdr { fn get_intrate(&self) -> i32 { match self.decoder_type { - ValidDecoderType::ACARS => acars::INTRATE, + ValidDecoderType::ACARS => acars::INTRATE as i32, ValidDecoderType::VDL2 => 0, } } From 874908afd2f6204af80514af465e715d8f3be0b4 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 23 May 2023 11:00:59 -0600 Subject: [PATCH 04/44] Add in HFDL decoder type for the future --- rust/oxide-decoders/src/lib.rs | 2 ++ rust/oxide-rtlsdr/src/lib.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/rust/oxide-decoders/src/lib.rs b/rust/oxide-decoders/src/lib.rs index 395b13c..ab2cf65 100644 --- a/rust/oxide-decoders/src/lib.rs +++ b/rust/oxide-decoders/src/lib.rs @@ -24,12 +24,14 @@ extern crate log; pub mod decoders { pub mod acars; + pub mod acars_labels; } #[derive(Debug, Clone)] pub enum ValidDecoderType { ACARS, VDL2, + HFDL, } pub trait Decoder: Send + Sync { diff --git a/rust/oxide-rtlsdr/src/lib.rs b/rust/oxide-rtlsdr/src/lib.rs index 167fd0c..d4ed17a 100644 --- a/rust/oxide-rtlsdr/src/lib.rs +++ b/rust/oxide-rtlsdr/src/lib.rs @@ -96,6 +96,7 @@ impl RtlSdr { match self.decoder_type { ValidDecoderType::ACARS => acars::INTRATE as i32, ValidDecoderType::VDL2 => 0, + ValidDecoderType::HFDL => 0, } } @@ -103,6 +104,7 @@ impl RtlSdr { match self.decoder_type { ValidDecoderType::ACARS => acars::RTLOUTBUFSZ, ValidDecoderType::VDL2 => 0, + ValidDecoderType::HFDL => 0, } } From 1ee1a746310f1c83b1d5342997626ffa04e2f34e Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 23 May 2023 11:01:23 -0600 Subject: [PATCH 05/44] Move ack to an enum type to better indicate in the output what is going on --- rust/oxide-decoders/src/decoders/acars.rs | 29 ++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index ad2683d..0f9be98 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -271,12 +271,28 @@ impl Display for DownlinkStatus { } } } + +#[derive(Debug, Clone)] +enum AckStatus { + Nack, + Ack(char), +} + +impl Display for AckStatus { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + AckStatus::Nack => write!(f, "NACK"), + AckStatus::Ack(ack_status) => write!(f, "ACK({})", ack_status), + } + } +} + #[derive(Debug, Clone)] #[allow(dead_code)] pub struct AssembledACARSMessage { mode: char, tail_addr: [char; 8], - ack: char, + ack: AckStatus, label: [char; 3], bid: char, no: [char; 5], @@ -322,7 +338,7 @@ impl AssembledACARSMessage { frequency: 0.0, tail_addr: [' '; 8], downlink_status: DownlinkStatus::AirToGround, - ack: ' ', + ack: AckStatus::Nack, label: [' '; 3], bid: ' ', no: [' '; 5], @@ -955,12 +971,9 @@ impl ACARSDecoder { output_message.tail_addr[j] = '\0'; - // /* ACK/NAK */ - output_message.ack = self.blk.txt[k] as char; - if output_message.ack == 0x15 as char - // NAK is nonprintable - { - output_message.ack = '!'; + /* ACK/NAK */ + if self.blk.txt[k] != 0x15 { + output_message.ack = AckStatus::Ack(self.blk.txt[k] as char); } k += 1; From 9ff50f10cc7cbc26ef90185b23990a6ae51c234b Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 23 May 2023 11:05:13 -0600 Subject: [PATCH 06/44] start of labels --- rust/oxide-decoders/src/decoders/acars_labels.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 rust/oxide-decoders/src/decoders/acars_labels.rs diff --git a/rust/oxide-decoders/src/decoders/acars_labels.rs b/rust/oxide-decoders/src/decoders/acars_labels.rs new file mode 100644 index 0000000..f4c31d2 --- /dev/null +++ b/rust/oxide-decoders/src/decoders/acars_labels.rs @@ -0,0 +1,15 @@ +// Copyright (C) 2023 Fred Clausen + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA From 28ac8d2b8f299ff8644160b00ba059707976e687 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 23 May 2023 14:41:00 -0600 Subject: [PATCH 07/44] Remove to_owned() on bytes iteration in SDR read --- rust/oxide-rtlsdr/src/lib.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rust/oxide-rtlsdr/src/lib.rs b/rust/oxide-rtlsdr/src/lib.rs index d4ed17a..1219509 100644 --- a/rust/oxide-rtlsdr/src/lib.rs +++ b/rust/oxide-rtlsdr/src/lib.rs @@ -311,14 +311,11 @@ impl RtlSdr { for m in 0..rtloutbufz { for vb_item in vb.iter_mut().take(self.rtl_mult as usize) { - *vb_item = (bytes_iterator - .next() - .expect("Ran out of bytes!") - .to_owned() as f32 - - 127.37) - + (bytes_iterator.next().expect("Ran out of bytes!").to_owned() - as f32 - - 127.37) + *vb_item = (*bytes_iterator.next().expect("Ran out of bytes!") + as f32 + - 127.37_f32) + + (*bytes_iterator.next().expect("Ran out of bytes!") as f32 + - 127.37_f32) * Complex::i(); } From abfcc068860a248d761d41652d66afa9061a9cf9 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 07:02:16 -0600 Subject: [PATCH 08/44] testing --- rust/oxide-decoders/src/decoders/acars.rs | 33 ++++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 0f9be98..c69ac11 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -742,9 +742,7 @@ impl ACARSDecoder { fn update_crc(&self, crc: u32, c: u32) -> u32 { // #define update_crc(crc,c) crc= (crc>> 8)^crc_ccitt_table[(crc^(c))&0xff]; - let mut crc: u32 = crc; - crc = (crc >> 8) ^ CRC[((crc ^ c) & 0xff) as usize]; - crc + (crc >> 8) ^ CRC[((crc ^ c) & 0xff) as usize] } fn fixdberr(&mut self, crc: u32) -> Result<(), ACARSDecodingError> { @@ -781,13 +779,17 @@ impl ACARSDecoder { pr_index: usize, pn: usize, ) -> Result<(), ACARSDecodingError> { + debug!("Called fixprerr pn {}", pn); if pn > 0 { /* try to recursievly fix parity error */ for i in 0..8 { + debug!("Running recursion {}", i); + //syndrom[i + 8 * (blk->len - *pr + 1)] let test = crc ^ SYNDROM[i + 8 * (self.blk.len as usize - pr[pr_index] as usize + 1)]; if self.fixprerr(test, pr, pr_index + 1, pn - 1).is_ok() { - self.blk.txt[pr_index] ^= 1 << i; + self.blk.txt[self.blk.txt[pr[pr_index] as usize] as usize] ^= 1 << i; + debug!("Fixed!"); return Ok(()); } // { @@ -797,6 +799,7 @@ impl ACARSDecoder { } Err(ACARSDecodingError::FixPR) } else { + debug!("No more parity errors. CRC {}", crc); /* end of recursion : no more parity error */ if crc == 0 { return Ok(()); @@ -853,8 +856,9 @@ impl ACARSDecoder { } if pn > 0 { info!( - "[{: <13}] Parity errors: {}", + "[{: <13}] Initial parity error{}: {}", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), + if pn > 1 { "s" } else { "" }, pn ); } @@ -870,9 +874,8 @@ impl ACARSDecoder { crc = self.update_crc(crc, self.blk.crc[1] as u32); if crc != 0 { error!( - "[{: <13}] {} crc error", + "[{: <13}] CRC error", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), - self.blk.chn + 1 ); } else { trace!( @@ -888,34 +891,32 @@ impl ACARSDecoder { Ok(_) => {} Err(_) => { error!( - "[{: <13}] {:#} not able to fix errors", + "[{: <13}] Not able to fix parity errors", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), - self.blk.chn + 1 ); return; } } info!( - "[{: <13}] {:#} errors fixed", + "[{: <13}] {:#} total parity error{} fixed", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), - self.blk.chn + 1 + pn, + if pn > 1 { "s" } else { "" } ); } else if crc > 0 { match self.fixdberr(crc) { Ok(_) => {} Err(_) => { error!( - "[{: <13}] {:#} not able to fix errors", + "[{: <13}] Not able to fix CRC errors", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), - self.blk.chn + 1 ); return; } } info!( - "[{: <13}] {:#} errors fixed", + "[{: <13}] CRC errors fixed", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), - self.blk.chn + 1 ); } @@ -929,7 +930,7 @@ impl ACARSDecoder { } if pn > 0 { info!( - "[{: <13}] Parity errors: {}", + "[{: <13}] Final parity errors: {}", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), pn ); From 2d9b01dae3d154e5a4cef20c1123dad93d66cf15 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 09:07:47 -0600 Subject: [PATCH 09/44] make MskBlks.len a usize --- rust/oxide-decoders/src/decoders/acars.rs | 34 +++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index c69ac11..45323fb 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -358,7 +358,7 @@ impl AssembledACARSMessage { struct Mskblks { chn: i32, timeval: u64, - len: i32, + len: usize, pub err: usize, lvl: f32, pub txt: [u8; 250], @@ -402,7 +402,7 @@ impl Mskblks { self.timeval = timeval; } - pub fn set_len(&mut self, len: i32) { + pub fn set_len(&mut self, len: usize) { self.len = len; } @@ -414,7 +414,7 @@ impl Mskblks { self.txt[index] = txt; } - pub fn len(&self) -> i32 { + pub fn len(&self) -> usize { self.len } } @@ -656,8 +656,7 @@ impl ACARSDecoder { "[{: <13}] TXT", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) ); - self.blk - .set_text_by_index(self.blk.len as usize, self.outbits); + self.blk.set_text_by_index(self.blk.len, self.outbits); self.blk.len += 1; if (NUMBITS[self.outbits as usize] & 1) == 0 { @@ -683,8 +682,8 @@ impl ACARSDecoder { } if self.blk.len > 20 && self.outbits == DLE { self.blk.len -= 3; - self.blk.crc[0] = self.blk.txt[self.blk.len as usize]; - self.blk.crc[1] = self.blk.txt[self.blk.len as usize + 1]; + self.blk.crc[0] = self.blk.txt[self.blk.len]; + self.blk.crc[1] = self.blk.txt[self.blk.len + 1]; self.acars_state = ACARSState::Crc2; self.put_msg_label(); } @@ -754,8 +753,8 @@ impl ACARSDecoder { } /* test double error in bytes */ - for k in 0..self.blk.len as usize { - let bo: usize = 8 * (self.blk.len as usize - k + 1); + for k in 0..self.blk.len { + let bo: usize = 8 * (self.blk.len - k + 1); for i in 0..8_usize { for j in 0..8_usize { if i == j { @@ -785,8 +784,7 @@ impl ACARSDecoder { for i in 0..8 { debug!("Running recursion {}", i); //syndrom[i + 8 * (blk->len - *pr + 1)] - let test = - crc ^ SYNDROM[i + 8 * (self.blk.len as usize - pr[pr_index] as usize + 1)]; + let test = crc ^ SYNDROM[i + 8 * (self.blk.len - pr[pr_index] as usize + 1)]; if self.fixprerr(test, pr, pr_index + 1, pn - 1).is_ok() { self.blk.txt[self.blk.txt[pr[pr_index] as usize] as usize] ^= 1 << i; debug!("Fixed!"); @@ -833,7 +831,7 @@ impl ACARSDecoder { /* parity check */ let mut pn: usize = 0; - for i in 0..self.blk.len as usize { + for i in 0..self.blk.len { if (NUMBITS[self.blk.txt[i] as usize] & 1) == 0 { if pn < MAXPERR { pr[pn] = i as u8; @@ -866,7 +864,7 @@ impl ACARSDecoder { /* crc check */ let mut crc: u32 = 0; - for i in 0..self.blk.len as usize { + for i in 0..self.blk.len { crc = self.update_crc(crc, self.blk.txt[i] as u32); } @@ -922,7 +920,7 @@ impl ACARSDecoder { // /* redo parity checking and removing */ pn = 0; - for i in 0..self.blk.len as usize { + for i in 0..self.blk.len { if (NUMBITS[self.blk.txt[i] as usize] & 1) == 0 { pn += 1; } @@ -1004,12 +1002,12 @@ impl ACARSDecoder { output_message.bs = self.blk.txt[k] as char; k += 1; - output_message.be = self.blk.txt[self.blk.len as usize - 1] as char; + output_message.be = self.blk.txt[self.blk.len - 1] as char; if output_message.bs != 0x03 as char { if is_downlink { /* message no */ - while i < 4 && k < self.blk.len as usize - 1 { + while i < 4 && k < self.blk.len - 1 { output_message.no[i] = self.blk.txt[k] as char; i += 1; k += 1; @@ -1030,7 +1028,7 @@ impl ACARSDecoder { // msg.fid[i] = blk->txt[k]; // } i = 0; - while i < 6 && k < self.blk.len as usize - 1 { + while i < 6 && k < self.blk.len - 1 { output_message.flight_id[i] = self.blk.txt[k] as char; i += 1; k += 1; @@ -1041,7 +1039,7 @@ impl ACARSDecoder { //outflg = true; } - let txt_len = self.blk.len as usize - k - 1; + let txt_len = self.blk.len - k - 1; // libacars step. Skipping for now // TODO: Don't skip From c49e9510b0e60e935dbc6907a1007389504cd3a6 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 11:18:41 -0600 Subject: [PATCH 10/44] more logging for testing --- rust/oxide-decoders/src/decoders/acars.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 45323fb..b065b1c 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -790,22 +790,20 @@ impl ACARSDecoder { debug!("Fixed!"); return Ok(()); } - // { - // blk.txt[*pr] ^= (1 << i); - // return Ok(()); - // } } Err(ACARSDecodingError::FixPR) } else { debug!("No more parity errors. CRC {}", crc); /* end of recursion : no more parity error */ if crc == 0 { + debug!("CRC is 0"); return Ok(()); - }; + } - /* test remainding error in crc */ + /* test remaining error in crc */ for item in SYNDROM.iter().take(16_usize) { if *item == crc { + debug!("Found CRC in syndrom"); return Ok(()); } } From 77c23e3329bca405531ad6fda122e5658f37b3e9 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 11:39:33 -0600 Subject: [PATCH 11/44] more logging --- rust/oxide-decoders/src/decoders/acars.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index b065b1c..2751118 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -785,6 +785,9 @@ impl ACARSDecoder { debug!("Running recursion {}", i); //syndrom[i + 8 * (blk->len - *pr + 1)] let test = crc ^ SYNDROM[i + 8 * (self.blk.len - pr[pr_index] as usize + 1)]; + debug!("Test {}", test); + debug!("pr_index {}", pr_index); + debug!("pr[pr_index] {}", pr[pr_index]); if self.fixprerr(test, pr, pr_index + 1, pn - 1).is_ok() { self.blk.txt[self.blk.txt[pr[pr_index] as usize] as usize] ^= 1 << i; debug!("Fixed!"); From 167b003b70b6a5f0c54710f39579ddd0b93182cc Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 11:48:13 -0600 Subject: [PATCH 12/44] more debugging --- rust/oxide-bin/src/main.rs | 3 +++ rust/oxide-decoders/src/decoders/acars.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/rust/oxide-bin/src/main.rs b/rust/oxide-bin/src/main.rs index 038fbc0..1ee8783 100644 --- a/rust/oxide-bin/src/main.rs +++ b/rust/oxide-bin/src/main.rs @@ -29,6 +29,9 @@ use tokio::time::{sleep, Duration}; async fn main() { let args: OxideInput = OxideInput::parse(); args.logging.enable_logging(); + // print current version + info!("ACARS Oxide v{}", env!("CARGO_PKG_VERSION")); + debug!( "Starting ACARS Oxide with the following options: {:#?}", args diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 2751118..d92bd8c 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -788,6 +788,10 @@ impl ACARSDecoder { debug!("Test {}", test); debug!("pr_index {}", pr_index); debug!("pr[pr_index] {}", pr[pr_index]); + debug!( + "index into SYNDROM {}", + i + 8 * (self.blk.len - pr[pr_index] as usize + 1) + ); if self.fixprerr(test, pr, pr_index + 1, pn - 1).is_ok() { self.blk.txt[self.blk.txt[pr[pr_index] as usize] as usize] ^= 1 << i; debug!("Fixed!"); From d14c70a888bd93dddef22a9a326f09d19e2552b7 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 13:49:27 -0600 Subject: [PATCH 13/44] ????? --- rust/oxide-decoders/src/decoders/acars.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index d92bd8c..12701e1 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -843,12 +843,12 @@ impl ACARSDecoder { } pn += 1; } - if (NUMBITS[self.blk.txt[i] as usize] & 1) == 0 { - if pn < MAXPERR { - pr[pn] = i as u8; - } - pn += 1; - } + // if (NUMBITS[self.blk.txt[i] as usize] & 1) == 0 { + // if pn < MAXPERR { + // pr[pn] = i as u8; + // } + // pn += 1; + // } } if pn > MAXPERR { info!( From 89a1055f8ce16eea614fe21b2332d5c074dbea83 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 14:05:45 -0600 Subject: [PATCH 14/44] Parity errors are fixed --- rust/oxide-decoders/src/decoders/acars.rs | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 12701e1..c45a3b9 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -778,23 +778,13 @@ impl ACARSDecoder { pr_index: usize, pn: usize, ) -> Result<(), ACARSDecodingError> { - debug!("Called fixprerr pn {}", pn); if pn > 0 { /* try to recursievly fix parity error */ for i in 0..8 { - debug!("Running recursion {}", i); //syndrom[i + 8 * (blk->len - *pr + 1)] let test = crc ^ SYNDROM[i + 8 * (self.blk.len - pr[pr_index] as usize + 1)]; - debug!("Test {}", test); - debug!("pr_index {}", pr_index); - debug!("pr[pr_index] {}", pr[pr_index]); - debug!( - "index into SYNDROM {}", - i + 8 * (self.blk.len - pr[pr_index] as usize + 1) - ); if self.fixprerr(test, pr, pr_index + 1, pn - 1).is_ok() { self.blk.txt[self.blk.txt[pr[pr_index] as usize] as usize] ^= 1 << i; - debug!("Fixed!"); return Ok(()); } } @@ -803,14 +793,12 @@ impl ACARSDecoder { debug!("No more parity errors. CRC {}", crc); /* end of recursion : no more parity error */ if crc == 0 { - debug!("CRC is 0"); return Ok(()); } /* test remaining error in crc */ for item in SYNDROM.iter().take(16_usize) { if *item == crc { - debug!("Found CRC in syndrom"); return Ok(()); } } @@ -843,15 +831,9 @@ impl ACARSDecoder { } pn += 1; } - // if (NUMBITS[self.blk.txt[i] as usize] & 1) == 0 { - // if pn < MAXPERR { - // pr[pn] = i as u8; - // } - // pn += 1; - // } } if pn > MAXPERR { - info!( + error!( "[{: <13}] Too many parity errors", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) ); @@ -887,7 +869,6 @@ impl ACARSDecoder { ); } - // TODO: Fix Error correcting. It seems broken. /* try to fix error */ if pn > 0 { match self.fixprerr(crc, &pr, 0, pn) { From fa44a02c4816e22db483719aea1dbd9aa6a4afdb Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 18:46:17 -0600 Subject: [PATCH 15/44] Remove unnecessary debug statement --- rust/oxide-decoders/src/decoders/acars.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index c45a3b9..4828eb8 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -790,7 +790,6 @@ impl ACARSDecoder { } Err(ACARSDecodingError::FixPR) } else { - debug!("No more parity errors. CRC {}", crc); /* end of recursion : no more parity error */ if crc == 0 { return Ok(()); From 9701e9ba8f7a5455345f9b10ef6f3f2b12c4776e Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 19:50:36 -0600 Subject: [PATCH 16/44] Grab and save the msn and msn sequence --- rust/oxide-decoders/src/decoders/acars.rs | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 4828eb8..df410db 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -306,6 +306,8 @@ pub struct AssembledACARSMessage { lvl: f32, frequency: f32, downlink_status: DownlinkStatus, + msn: [char; 4], + msn_seq: char, } impl Display for AssembledACARSMessage { @@ -350,6 +352,8 @@ impl AssembledACARSMessage { txt: Vec::new(), err: 0, lvl: 0.0, + msn: [' '; 4], + msn_seq: ' ', } } } @@ -998,20 +1002,17 @@ impl ACARSDecoder { k += 1; } output_message.no[i] = '\0'; - // libacars step. Skipping for now - // TODO: Don't skip - // #ifdef HAVE_LIBACARS - // /* The 3-char prefix is used in reassembly hash table key, so we need */ - // /* to store the MSN separately as prefix and seq character. */ - // for (i = 0; i < 3; i++) - // msg.msn[i] = msg.no[i]; - // msg.msn[3] = '\0'; - // msg.msn_seq = msg.no[3]; - // #endif - // /* Flight id */ - // for (i = 0; i < 6 && k < blk->len - 1; i++, k++) { - // msg.fid[i] = blk->txt[k]; - // } + + /* The 3-char prefix is used in reassembly hash table key, so we need */ + /* to store the MSN separately as prefix and seq character. */ + i = 0; + while i < 3 { + output_message.msn[i] = output_message.no[i]; + i += 1; + } + output_message.msn[3] = '\0'; + output_message.msn_seq = output_message.no[3]; + i = 0; while i < 6 && k < self.blk.len - 1 { output_message.flight_id[i] = self.blk.txt[k] as char; From ea838b247df6aa8b8de302d4bf399dc1f3d5dba1 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Wed, 24 May 2023 19:53:45 -0600 Subject: [PATCH 17/44] add msn to output --- rust/oxide-decoders/src/decoders/acars.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index df410db..6a63123 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -314,7 +314,7 @@ impl Display for AssembledACARSMessage { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, - "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {}, mfi: {}, txt: {}, err: {}, lvl: {}", + "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {}, mfi: {}, txt: {}, err: {}, lvl: {}, msn: {}, msn seq: {}", self.frequency, self.mode, self.tail_addr.iter().collect::().trim(), @@ -328,7 +328,9 @@ impl Display for AssembledACARSMessage { self.mfi.iter().collect::().trim(), self.txt.iter().collect::().trim(), self.err, - self.lvl + self.lvl, + self.msn.iter().collect::().trim(), + self.msn_seq, ) } } From 3d1ebe87beaf3029a72b3b56fe898f5087d36b8d Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 08:18:54 -0600 Subject: [PATCH 18/44] sublabel and mfi --- rust/oxide-decoders/src/decoders/acars.rs | 149 ++++++++++++++++++---- 1 file changed, 122 insertions(+), 27 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 6a63123..c88a94b 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -257,7 +257,7 @@ enum ACARSState { End, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] enum DownlinkStatus { AirToGround, GroundToAir, @@ -272,6 +272,32 @@ impl Display for DownlinkStatus { } } +#[allow(dead_code)] +#[derive(Debug, Clone)] +enum ReassemblyStatus { + Unknown, + Complete, + InProgress, + Skipped, + Duplicate, + FragOutOfSequence, + ArgsInvalid, +} + +impl Display for ReassemblyStatus { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + ReassemblyStatus::Unknown => write!(f, "Unknown"), + ReassemblyStatus::Complete => write!(f, "Complete"), + ReassemblyStatus::InProgress => write!(f, "In Progress"), + ReassemblyStatus::Skipped => write!(f, "Skipped"), + ReassemblyStatus::Duplicate => write!(f, "Duplicate"), + ReassemblyStatus::FragOutOfSequence => write!(f, "Fragment out of sequence"), + ReassemblyStatus::ArgsInvalid => write!(f, "Invalid arguments"), + } + } +} + #[derive(Debug, Clone)] enum AckStatus { Nack, @@ -297,8 +323,8 @@ pub struct AssembledACARSMessage { bid: char, no: [char; 5], flight_id: [char; 7], - sublabel: [char; 3], - mfi: [char; 3], + sublabel: Option<[char; 3]>, + mfi: Option<[char; 3]>, bs: char, be: char, txt: Vec, @@ -308,13 +334,16 @@ pub struct AssembledACARSMessage { downlink_status: DownlinkStatus, msn: [char; 4], msn_seq: char, + reassembly_status: ReassemblyStatus, } impl Display for AssembledACARSMessage { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + // TODO: Format the optional fields appropriately + write!( f, - "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {}, mfi: {}, txt: {}, err: {}, lvl: {}, msn: {}, msn seq: {}", + "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {:?}, mfi: {:?}, txt: {}, err: {}, lvl: {}, msn: {}, msn seq: {}, reassembly status: {}", self.frequency, self.mode, self.tail_addr.iter().collect::().trim(), @@ -324,13 +353,14 @@ impl Display for AssembledACARSMessage { self.bid, self.no.iter().collect::().trim(), self.flight_id.iter().collect::().trim(), - self.sublabel.iter().collect::().trim(), - self.mfi.iter().collect::().trim(), + self.sublabel, + self.mfi, self.txt.iter().collect::().trim(), self.err, self.lvl, self.msn.iter().collect::().trim(), self.msn_seq, + self.reassembly_status ) } } @@ -347,8 +377,8 @@ impl AssembledACARSMessage { bid: ' ', no: [' '; 5], flight_id: [' '; 7], - sublabel: [' '; 3], - mfi: [' '; 3], + sublabel: None, + mfi: None, bs: ' ', be: ' ', txt: Vec::new(), @@ -356,6 +386,7 @@ impl AssembledACARSMessage { lvl: 0.0, msn: [' '; 4], msn_seq: ' ', + reassembly_status: ReassemblyStatus::Skipped, } } } @@ -918,11 +949,14 @@ impl ACARSDecoder { self.blk.txt[i] &= 0x7f; } if pn > 0 { - info!( - "[{: <13}] Final parity errors: {}", + error!( + "[{: <13}] Final parity error{}: {}", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), + if pn > 1 { "s" } else { "" }, pn ); + + return; } trace!( @@ -1027,19 +1061,15 @@ impl ACARSDecoder { //outflg = true; } - let txt_len = self.blk.len - k - 1; + let mut txt_len = self.blk.len - k - 1; - // libacars step. Skipping for now - // TODO: Don't skip - // #ifdef HAVE_LIBACARS + // Extract sublabel and MFI if present + let offset = self.acars_extract_sublabel_and_mfi(&mut output_message, k); - // // Extract sublabel and MFI if present - // int offset = la_acars_extract_sublabel_and_mfi(msg.label, msg_dir, - // blk->txt + k, txt_len, msg.sublabel, msg.mfi); - // if(offset > 0) { - // k += offset; - // txt_len -= offset; - // } + if offset > 0 { + k += offset; + txt_len -= offset; + } // la_reasm_table *acars_rtable = NULL; // if(msg.bid != 0 && reasm_ctx != NULL) { // not a squitter && reassembly engine is enabled @@ -1049,12 +1079,12 @@ impl ACARSDecoder { // acars_reasm_funcs, LA_ACARS_REASM_TABLE_CLEANUP_INTERVAL); // } - // // The sequence number at which block id wraps at. - // // - downlinks: none (MSN always goes from 'A' up to 'P') - // // - uplinks: - // // - for VHF Category A (mode=2): wraps after block id 'Z' - // // - for VHF Category B (mode!=2): wraps after block id 'W' - // // (blocks 'X'-'Z' are reserved for empty ACKs) + // The sequence number at which block id wraps at. + // - downlinks: none (MSN always goes from 'A' up to 'P') + // - uplinks: + // - for VHF Category A (mode=2): wraps after block id 'Z' + // - for VHF Category B (mode!=2): wraps after block id 'W' + // (blocks 'X'-'Z' are reserved for empty ACKs) // int seq_num_wrap = SEQ_WRAP_NONE; // if(!down) @@ -1122,4 +1152,69 @@ impl ACARSDecoder { output_channel.send(output_message).unwrap(); } } + + fn acars_extract_sublabel_and_mfi( + &self, + output_message: &mut AssembledACARSMessage, + txt_start_position: usize, + ) -> usize { + if self.blk.len < 2 { + return 0; + } + + let mut consumed: usize = 0; + let mut remaining: usize = self.blk.len; + let mut internal_start_position = txt_start_position; + + if output_message.label[0] == 'H' && output_message.label[1] == '1' { + if output_message.downlink_status == DownlinkStatus::GroundToAir + && remaining >= 5 + && self.blk.txt[internal_start_position] as char == '-' + && self.blk.txt[internal_start_position + 1] as char == ' ' + && self.blk.txt[internal_start_position + 2] as char == '#' + { + debug!("Found sublabel in H1 message G2A"); + output_message.sublabel = Some([ + self.blk.txt[internal_start_position + 3] as char, + self.blk.txt[internal_start_position + 4] as char, + '\0', + ]); + + internal_start_position += 5; + consumed += 5; + remaining -= 5; + } else if output_message.downlink_status == DownlinkStatus::AirToGround + && remaining >= 4 + && self.blk.txt[internal_start_position] as char == '#' + && self.blk.txt[internal_start_position + 3] as char == 'B' + { + debug!("Found sublabel in H1 message A2G"); + output_message.sublabel = Some([ + self.blk.txt[internal_start_position + 1] as char, + self.blk.txt[internal_start_position + 2] as char, + '\0', + ]); + + internal_start_position += 4; + consumed += 4; + remaining -= 4; + } + + // find the MFI + + if remaining >= 4 + && self.blk.txt[internal_start_position] as char == '/' + && self.blk.txt[internal_start_position + 3] as char == ' ' + { + output_message.mfi = Some([ + self.blk.txt[internal_start_position + 1] as char, + self.blk.txt[internal_start_position + 2] as char, + '\0', + ]); + + consumed += 4; + } + } + consumed + } } From dcc311f0b1428b000a11b1982ec54a5397b0adec Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 08:49:00 -0600 Subject: [PATCH 19/44] Working on logic error in text length --- rust/oxide-decoders/src/decoders/acars.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index c88a94b..8130e6e 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -1113,10 +1113,10 @@ impl ACARSDecoder { // } else { // #endif // HAVE_LIBACARS // msg.txt = calloc(txt_len + 1, sizeof(char)); - k += 1; + //k += 1; if txt_len > 0 { - while k < txt_len { + while k <= txt_len { output_message.txt.push(self.blk.txt[k] as char); k += 1; i += 1; @@ -1202,7 +1202,8 @@ impl ACARSDecoder { // find the MFI - if remaining >= 4 + if output_message.sublabel.is_some() + && remaining >= 4 && self.blk.txt[internal_start_position] as char == '/' && self.blk.txt[internal_start_position + 3] as char == ' ' { From 250f7ae12fdbbc9f9ac40915610764cda3ba599b Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 08:53:50 -0600 Subject: [PATCH 20/44] debugging --- rust/oxide-decoders/src/decoders/acars.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 8130e6e..7200ba5 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -1062,6 +1062,7 @@ impl ACARSDecoder { } let mut txt_len = self.blk.len - k - 1; + debug!("txt_len: {}", txt_len); // Extract sublabel and MFI if present let offset = self.acars_extract_sublabel_and_mfi(&mut output_message, k); From 582f4c1c79d6a05338dfef8b72d9748f0269d472 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 08:55:43 -0600 Subject: [PATCH 21/44] testing --- rust/oxide-decoders/src/decoders/acars.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 7200ba5..40cba22 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -1116,10 +1116,10 @@ impl ACARSDecoder { // msg.txt = calloc(txt_len + 1, sizeof(char)); //k += 1; + i = 0; if txt_len > 0 { - while k <= txt_len { - output_message.txt.push(self.blk.txt[k] as char); - k += 1; + while i <= txt_len { + output_message.txt.push(self.blk.txt[k + i] as char); i += 1; } } From d6d22f59b3ce15ada857573856eaab0917f3407f Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 08:57:15 -0600 Subject: [PATCH 22/44] more testing --- rust/oxide-decoders/src/decoders/acars.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 40cba22..0f1cf4f 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -1118,7 +1118,7 @@ impl ACARSDecoder { i = 0; if txt_len > 0 { - while i <= txt_len { + while i < txt_len { output_message.txt.push(self.blk.txt[k + i] as char); i += 1; } From 523e386bfc51a3cd4ae5e6ada9cf81613d00ac65 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 09:08:10 -0600 Subject: [PATCH 23/44] Cleaning up debug stuff --- rust/oxide-decoders/src/decoders/acars.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 0f1cf4f..d5534dc 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -1062,15 +1062,12 @@ impl ACARSDecoder { } let mut txt_len = self.blk.len - k - 1; - debug!("txt_len: {}", txt_len); // Extract sublabel and MFI if present let offset = self.acars_extract_sublabel_and_mfi(&mut output_message, k); - if offset > 0 { - k += offset; - txt_len -= offset; - } + k += offset; + txt_len -= offset; // la_reasm_table *acars_rtable = NULL; // if(msg.bid != 0 && reasm_ctx != NULL) { // not a squitter && reassembly engine is enabled @@ -1174,7 +1171,6 @@ impl ACARSDecoder { && self.blk.txt[internal_start_position + 1] as char == ' ' && self.blk.txt[internal_start_position + 2] as char == '#' { - debug!("Found sublabel in H1 message G2A"); output_message.sublabel = Some([ self.blk.txt[internal_start_position + 3] as char, self.blk.txt[internal_start_position + 4] as char, @@ -1189,7 +1185,6 @@ impl ACARSDecoder { && self.blk.txt[internal_start_position] as char == '#' && self.blk.txt[internal_start_position + 3] as char == 'B' { - debug!("Found sublabel in H1 message A2G"); output_message.sublabel = Some([ self.blk.txt[internal_start_position + 1] as char, self.blk.txt[internal_start_position + 2] as char, From 330c1dfc7adac54458c8d7032670c3011c3df4f8 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 09:12:45 -0600 Subject: [PATCH 24/44] Fix (???) db error correcting --- rust/oxide-decoders/src/decoders/acars.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index d5534dc..4ff3043 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -785,7 +785,7 @@ impl ACARSDecoder { /* test remaining error in crc */ for item in SYNDROM.iter().take(16_usize) { if *item == crc { - return Err(ACARSDecodingError::FixDB); + return Ok(()); } } @@ -800,12 +800,12 @@ impl ACARSDecoder { if (crc ^ SYNDROM[i + bo] ^ SYNDROM[j + bo]) == 0 { self.blk.txt[k] ^= 1 << i; self.blk.txt[k] ^= 1 << j; - return Err(ACARSDecodingError::FixDB); + return Ok(()); } } } } - Ok(()) + Err(ACARSDecodingError::FixDB) } fn fixprerr( From 507fb02875a4deb194876cc00d63f0a153b7969b Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 09:17:53 -0600 Subject: [PATCH 25/44] change initial CRC/parity logging to warn --- rust/oxide-decoders/src/decoders/acars.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 4ff3043..f958e96 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -876,7 +876,7 @@ impl ACARSDecoder { return; } if pn > 0 { - info!( + warn!( "[{: <13}] Initial parity error{}: {}", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), if pn > 1 { "s" } else { "" }, @@ -894,7 +894,7 @@ impl ACARSDecoder { crc = self.update_crc(crc, self.blk.crc[0] as u32); crc = self.update_crc(crc, self.blk.crc[1] as u32); if crc != 0 { - error!( + warn!( "[{: <13}] CRC error", format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), ); From 6c5a70f33c4b03cd82cb7a20546e7c03f6ecb1db Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 20:07:15 -0600 Subject: [PATCH 26/44] more parity fixes --- rust/oxide-decoders/src/decoders/acars.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index f958e96..5fc9d10 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -821,7 +821,7 @@ impl ACARSDecoder { //syndrom[i + 8 * (blk->len - *pr + 1)] let test = crc ^ SYNDROM[i + 8 * (self.blk.len - pr[pr_index] as usize + 1)]; if self.fixprerr(test, pr, pr_index + 1, pn - 1).is_ok() { - self.blk.txt[self.blk.txt[pr[pr_index] as usize] as usize] ^= 1 << i; + self.blk.txt[pr[pr_index] as usize] ^= 1 << i; return Ok(()); } } @@ -942,12 +942,13 @@ impl ACARSDecoder { // /* redo parity checking and removing */ pn = 0; - for i in 0..self.blk.len { - if (NUMBITS[self.blk.txt[i] as usize] & 1) == 0 { + for blk_item in self.blk.txt.iter_mut().take(self.blk.len) { + if (NUMBITS[*blk_item as usize] & 1) == 0 { pn += 1; } - self.blk.txt[i] &= 0x7f; + *blk_item &= 0x7f; } + if pn > 0 { error!( "[{: <13}] Final parity error{}: {}", From 13716719724bf01d07acd992ff913294d97319f8 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:03:13 -0600 Subject: [PATCH 27/44] remove some casts --- rust/oxide-decoders/src/decoders/acars.rs | 85 +++++++++-------------- 1 file changed, 32 insertions(+), 53 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 5fc9d10..ad443a5 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -26,10 +26,13 @@ use std::time::UNIX_EPOCH; use tokio::sync::mpsc::UnboundedSender; pub const INTRATE: usize = 12500; +pub const INTRATE_F32: f32 = 12500.0; pub const RTLOUTBUFSZ: usize = 1024; const FLEN: usize = (INTRATE / 1200) + 1; const MFLTOVER: usize = 12; +const MFLTOVER_F32: f32 = 12.0; const FLENO: usize = FLEN * MFLTOVER + 1; +const FLENO_F32: f32 = FLENO as f32; const PLLG: f32 = 38e-4; const PLLC: f32 = 0.52; const SYN: u8 = 0x16; @@ -459,7 +462,7 @@ impl Mskblks { #[derive(Clone)] pub struct ACARSDecoder { channel_number: i32, - freq: i32, + freq: f32, wf: [Complex; 192], dm_buffer: [f32; RTLOUTBUFSZ], msk_phi: f32, @@ -501,8 +504,8 @@ impl ACARSDecoder { let mut h: [f32; FLENO] = [0.0; FLENO]; for (i, h_item) in h.iter_mut().enumerate().take(FLENO) { *h_item = f32::cos( - 2.0 * std::f32::consts::PI * 600.0 / INTRATE as f32 / MFLTOVER as f32 - * (i as f32 - (FLENO as f32 - 1.0) / 2.0), + 2.0 * std::f32::consts::PI * 600.0 / INTRATE_F32 / MFLTOVER_F32 + * (i as f32 - (FLENO_F32 - 1.0) / 2.0), ); if *h_item < 0.0 { *h_item = 0.0; @@ -511,7 +514,7 @@ impl ACARSDecoder { Self { channel_number, - freq, + freq: freq as f32 / 1000000.0, wf, dm_buffer: [0.0; RTLOUTBUFSZ], msk_phi: 0.0, @@ -535,7 +538,7 @@ impl ACARSDecoder { /* MSK demod */ for in_ in &mut self.dm_buffer.into_iter().take(len) { - let s: f32 = 1800.0 / INTRATE as f32 * 2.0 * std::f32::consts::PI + self.msk_df; + let s: f32 = 1800.0 / INTRATE_F32 * 2.0 * std::f32::consts::PI + self.msk_df; let mut v: Complex = Complex::new(0.0, 0.0); let mut o: f32; @@ -559,14 +562,14 @@ impl ACARSDecoder { self.msk_clk -= 3.0 * std::f32::consts::PI / 2.0; /* matched filter */ - o = MFLTOVER as f32 * (self.msk_clk / s + 0.5); - if o > MFLTOVER as f32 { - o = MFLTOVER as f32 + o = MFLTOVER_F32 * (self.msk_clk / s + 0.5); + if o > MFLTOVER_F32 { + o = MFLTOVER_F32 }; for j in 0..FLEN { v = v.add(self.h[o as usize] * self.inb[(j + self.idx as usize) % FLEN]); - o += MFLTOVER as f32; + o += MFLTOVER_F32; } /* normalize */ @@ -655,10 +658,7 @@ impl ACARSDecoder { self.reset_acars(); } ACARSState::Soh1 => { - trace!( - "[{: <13}] SOH1", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) - ); + trace!("[{: <13}] SOH1", format!("{}:{}", "ACARS", self.freq)); // let test = AssembledACARSMessage::new(); // if let Some(ref mut output_channel) = self.output_channel { // trace!("sending"); @@ -689,24 +689,18 @@ impl ACARSDecoder { self.reset_acars(); } ACARSState::Txt => { - trace!( - "[{: <13}] TXT", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) - ); + trace!("[{: <13}] TXT", format!("{}:{}", "ACARS", self.freq)); self.blk.set_text_by_index(self.blk.len, self.outbits); self.blk.len += 1; if (NUMBITS[self.outbits as usize] & 1) == 0 { - trace!( - "[{: <13}] TXT ERROR", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) - ); + trace!("[{: <13}] TXT ERROR", format!("{}:{}", "ACARS", self.freq)); self.blk.err += 1; if self.blk.err > MAXPERR + 1 { trace!( "[{: <13}] TXT TOO MANY ERRORS", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) + format!("{}:{}", "ACARS", self.freq) ); self.reset_acars(); return; @@ -731,28 +725,19 @@ impl ACARSDecoder { self.nbits = 8; } ACARSState::Crc1 => { - trace!( - "[{: <13}] CRC1", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) - ); + trace!("[{: <13}] CRC1", format!("{}:{}", "ACARS", self.freq)); self.blk.crc[0] = self.outbits; self.acars_state = ACARSState::Crc2; self.nbits = 8; } ACARSState::Crc2 => { - trace!( - "[{: <13}] CRC2", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) - ); + trace!("[{: <13}] CRC2", format!("{}:{}", "ACARS", self.freq)); self.blk.crc[1] = self.outbits; self.put_msg_label(); } ACARSState::End => { - trace!( - "[{: <13}] END", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) - ); + trace!("[{: <13}] END", format!("{}:{}", "ACARS", self.freq)); self.reset_acars(); self.nbits = 8; } @@ -849,7 +834,7 @@ impl ACARSDecoder { // too short error!( "[{: <13}] Message too short", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) + format!("{}:{}", "ACARS", self.freq) ); return; } @@ -871,14 +856,14 @@ impl ACARSDecoder { if pn > MAXPERR { error!( "[{: <13}] Too many parity errors", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) + format!("{}:{}", "ACARS", self.freq) ); return; } if pn > 0 { warn!( "[{: <13}] Initial parity error{}: {}", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), + format!("{}:{}", "ACARS", self.freq), if pn > 1 { "s" } else { "" }, pn ); @@ -894,15 +879,9 @@ impl ACARSDecoder { crc = self.update_crc(crc, self.blk.crc[0] as u32); crc = self.update_crc(crc, self.blk.crc[1] as u32); if crc != 0 { - warn!( - "[{: <13}] CRC error", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), - ); + warn!("[{: <13}] CRC error", format!("{}:{}", "ACARS", self.freq),); } else { - trace!( - "[{: <13}] CRC OK", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) - ); + trace!("[{: <13}] CRC OK", format!("{}:{}", "ACARS", self.freq)); } /* try to fix error */ @@ -912,14 +891,14 @@ impl ACARSDecoder { Err(_) => { error!( "[{: <13}] Not able to fix parity errors", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), + format!("{}:{}", "ACARS", self.freq), ); return; } } info!( "[{: <13}] {:#} total parity error{} fixed", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), + format!("{}:{}", "ACARS", self.freq), pn, if pn > 1 { "s" } else { "" } ); @@ -929,14 +908,14 @@ impl ACARSDecoder { Err(_) => { error!( "[{: <13}] Not able to fix CRC errors", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), + format!("{}:{}", "ACARS", self.freq), ); return; } } info!( "[{: <13}] CRC errors fixed", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), + format!("{}:{}", "ACARS", self.freq), ); } @@ -952,7 +931,7 @@ impl ACARSDecoder { if pn > 0 { error!( "[{: <13}] Final parity error{}: {}", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0), + format!("{}:{}", "ACARS", self.freq), if pn > 1 { "s" } else { "" }, pn ); @@ -962,7 +941,7 @@ impl ACARSDecoder { trace!( "[{: <13}] Parity and CRC check complete", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) + format!("{}:{}", "ACARS", self.freq) ); self.generate_output_message(); @@ -971,13 +950,13 @@ impl ACARSDecoder { fn generate_output_message(&mut self) { trace!( "[{: <13}] Generating output message", - format!("{}:{}", "ACARS", self.freq as f32 / 1000000.0) + format!("{}:{}", "ACARS", self.freq) ); let mut output_message = AssembledACARSMessage::new(); output_message.lvl = self.blk.lvl; output_message.err = self.blk.err as u8; - output_message.frequency = self.freq as f32 / 1000000.0; + output_message.frequency = self.freq; let mut k: usize = 0; let mut j: usize = 0; From 7d1d7b03e775b7467a3a3fd9e328324c5d81946b Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:22:28 -0600 Subject: [PATCH 28/44] Remove \0 from char arrays --- rust/oxide-decoders/src/decoders/acars.rs | 35 +++++++++-------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index ad443a5..78ae4ab 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -320,14 +320,14 @@ impl Display for AckStatus { #[allow(dead_code)] pub struct AssembledACARSMessage { mode: char, - tail_addr: [char; 8], + tail_addr: [char; 7], ack: AckStatus, - label: [char; 3], + label: [char; 2], bid: char, - no: [char; 5], - flight_id: [char; 7], - sublabel: Option<[char; 3]>, - mfi: Option<[char; 3]>, + no: [char; 4], + flight_id: [char; 6], + sublabel: Option<[char; 2]>, + mfi: Option<[char; 2]>, bs: char, be: char, txt: Vec, @@ -335,7 +335,7 @@ pub struct AssembledACARSMessage { lvl: f32, frequency: f32, downlink_status: DownlinkStatus, - msn: [char; 4], + msn: [char; 3], msn_seq: char, reassembly_status: ReassemblyStatus, } @@ -373,13 +373,13 @@ impl AssembledACARSMessage { Self { mode: ' ', frequency: 0.0, - tail_addr: [' '; 8], + tail_addr: [' '; 7], downlink_status: DownlinkStatus::AirToGround, ack: AckStatus::Nack, - label: [' '; 3], + label: [' '; 2], bid: ' ', - no: [' '; 5], - flight_id: [' '; 7], + no: [' '; 4], + flight_id: [' '; 6], sublabel: None, mfi: None, bs: ' ', @@ -387,7 +387,7 @@ impl AssembledACARSMessage { txt: Vec::new(), err: 0, lvl: 0.0, - msn: [' '; 4], + msn: [' '; 3], msn_seq: ' ', reassembly_status: ReassemblyStatus::Skipped, } @@ -973,8 +973,6 @@ impl ACARSDecoder { k += 1; } - output_message.tail_addr[j] = '\0'; - /* ACK/NAK */ if self.blk.txt[k] != 0x15 { output_message.ack = AckStatus::Ack(self.blk.txt[k] as char); @@ -989,7 +987,6 @@ impl ACARSDecoder { output_message.label[1] = 'd'; } k += 1; - output_message.label[2] = '\0'; output_message.bid = self.blk.txt[k] as char; @@ -1017,7 +1014,6 @@ impl ACARSDecoder { i += 1; k += 1; } - output_message.no[i] = '\0'; /* The 3-char prefix is used in reassembly hash table key, so we need */ /* to store the MSN separately as prefix and seq character. */ @@ -1026,7 +1022,7 @@ impl ACARSDecoder { output_message.msn[i] = output_message.no[i]; i += 1; } - output_message.msn[3] = '\0'; + output_message.msn_seq = output_message.no[3]; i = 0; @@ -1036,8 +1032,6 @@ impl ACARSDecoder { k += 1; } - output_message.flight_id[i] = '\0'; - //outflg = true; } @@ -1154,7 +1148,6 @@ impl ACARSDecoder { output_message.sublabel = Some([ self.blk.txt[internal_start_position + 3] as char, self.blk.txt[internal_start_position + 4] as char, - '\0', ]); internal_start_position += 5; @@ -1168,7 +1161,6 @@ impl ACARSDecoder { output_message.sublabel = Some([ self.blk.txt[internal_start_position + 1] as char, self.blk.txt[internal_start_position + 2] as char, - '\0', ]); internal_start_position += 4; @@ -1186,7 +1178,6 @@ impl ACARSDecoder { output_message.mfi = Some([ self.blk.txt[internal_start_position + 1] as char, self.blk.txt[internal_start_position + 2] as char, - '\0', ]); consumed += 4; From ad209f86cc18c1105f7e4d01659d3ea3a0e0bd7a Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:29:40 -0600 Subject: [PATCH 29/44] AssembledACARSMessage txt as option --- rust/oxide-decoders/src/decoders/acars.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 78ae4ab..b1e960e 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -330,7 +330,7 @@ pub struct AssembledACARSMessage { mfi: Option<[char; 2]>, bs: char, be: char, - txt: Vec, + txt: Option>, err: u8, lvl: f32, frequency: f32, @@ -346,7 +346,7 @@ impl Display for AssembledACARSMessage { write!( f, - "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {:?}, mfi: {:?}, txt: {}, err: {}, lvl: {}, msn: {}, msn seq: {}, reassembly status: {}", + "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {}, msn seq: {}, reassembly status: {}", self.frequency, self.mode, self.tail_addr.iter().collect::().trim(), @@ -358,7 +358,7 @@ impl Display for AssembledACARSMessage { self.flight_id.iter().collect::().trim(), self.sublabel, self.mfi, - self.txt.iter().collect::().trim(), + self.txt, self.err, self.lvl, self.msn.iter().collect::().trim(), @@ -384,7 +384,7 @@ impl AssembledACARSMessage { mfi: None, bs: ' ', be: ' ', - txt: Vec::new(), + txt: None, err: 0, lvl: 0.0, msn: [' '; 3], @@ -1089,17 +1089,20 @@ impl ACARSDecoder { i = 0; if txt_len > 0 { + let mut output_text: Vec = Vec::new(); while i < txt_len { - output_message.txt.push(self.blk.txt[k + i] as char); + output_text.push(self.blk.txt[k + i] as char); i += 1; } + + output_message.txt = Some(output_text); } // #ifdef HAVE_LIBACARS // } // #endif } else { // empty message text - output_message.txt.push('\0'); + output_message.txt = Some(vec!['\0']); } // #ifdef HAVE_LIBACARS From 9328305a1366b2c72a4379d70337f17b93ff1e5a Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:32:47 -0600 Subject: [PATCH 30/44] msn and msn_seq as Option --- rust/oxide-decoders/src/decoders/acars.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index b1e960e..403ee8b 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -335,8 +335,8 @@ pub struct AssembledACARSMessage { lvl: f32, frequency: f32, downlink_status: DownlinkStatus, - msn: [char; 3], - msn_seq: char, + msn: Option<[char; 3]>, + msn_seq: Option, reassembly_status: ReassemblyStatus, } @@ -346,7 +346,7 @@ impl Display for AssembledACARSMessage { write!( f, - "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {}, msn seq: {}, reassembly status: {}", + "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {:?}, msn seq: {:?}, reassembly status: {}", self.frequency, self.mode, self.tail_addr.iter().collect::().trim(), @@ -361,7 +361,7 @@ impl Display for AssembledACARSMessage { self.txt, self.err, self.lvl, - self.msn.iter().collect::().trim(), + self.msn, self.msn_seq, self.reassembly_status ) @@ -387,8 +387,8 @@ impl AssembledACARSMessage { txt: None, err: 0, lvl: 0.0, - msn: [' '; 3], - msn_seq: ' ', + msn: None, + msn_seq: None, reassembly_status: ReassemblyStatus::Skipped, } } @@ -1018,12 +1018,15 @@ impl ACARSDecoder { /* The 3-char prefix is used in reassembly hash table key, so we need */ /* to store the MSN separately as prefix and seq character. */ i = 0; + let mut output_msn: [char; 3] = [' '; 3]; while i < 3 { - output_message.msn[i] = output_message.no[i]; + output_msn[i] = output_message.no[i]; i += 1; } - output_message.msn_seq = output_message.no[3]; + output_message.msn = Some(output_msn); + + output_message.msn_seq = Some(output_message.no[3]); i = 0; while i < 6 && k < self.blk.len - 1 { From df09c70a5f24eadba49d2af76ea167975a631366 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:35:14 -0600 Subject: [PATCH 31/44] flight id as option --- rust/oxide-decoders/src/decoders/acars.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 403ee8b..453f136 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -325,7 +325,7 @@ pub struct AssembledACARSMessage { label: [char; 2], bid: char, no: [char; 4], - flight_id: [char; 6], + flight_id: Option<[char; 6]>, sublabel: Option<[char; 2]>, mfi: Option<[char; 2]>, bs: char, @@ -346,7 +346,7 @@ impl Display for AssembledACARSMessage { write!( f, - "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {:?}, msn seq: {:?}, reassembly status: {}", + "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {:?}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {:?}, msn seq: {:?}, reassembly status: {}", self.frequency, self.mode, self.tail_addr.iter().collect::().trim(), @@ -355,7 +355,7 @@ impl Display for AssembledACARSMessage { self.label.iter().collect::().trim(), self.bid, self.no.iter().collect::().trim(), - self.flight_id.iter().collect::().trim(), + self.flight_id, self.sublabel, self.mfi, self.txt, @@ -379,7 +379,7 @@ impl AssembledACARSMessage { label: [' '; 2], bid: ' ', no: [' '; 4], - flight_id: [' '; 6], + flight_id: None, sublabel: None, mfi: None, bs: ' ', @@ -1029,12 +1029,15 @@ impl ACARSDecoder { output_message.msn_seq = Some(output_message.no[3]); i = 0; + let mut output_flight_id = [' '; 6]; while i < 6 && k < self.blk.len - 1 { - output_message.flight_id[i] = self.blk.txt[k] as char; + output_flight_id[i] = self.blk.txt[k] as char; i += 1; k += 1; } + output_message.flight_id = Some(output_flight_id); + //outflg = true; } From 2fb31702a3d2cb13068ba2ed32f8ebd46c2f39a6 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:39:54 -0600 Subject: [PATCH 32/44] tail addr as option --- rust/oxide-decoders/src/decoders/acars.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 453f136..7fa7694 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -320,7 +320,7 @@ impl Display for AckStatus { #[allow(dead_code)] pub struct AssembledACARSMessage { mode: char, - tail_addr: [char; 7], + tail_addr: Option<[char; 7]>, ack: AckStatus, label: [char; 2], bid: char, @@ -346,10 +346,10 @@ impl Display for AssembledACARSMessage { write!( f, - "frequency: {}, mode: {}, tail addr: {}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {:?}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {:?}, msn seq: {:?}, reassembly status: {}", + "frequency: {}, mode: {}, tail addr: {:?}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {:?}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {:?}, msn seq: {:?}, reassembly status: {}", self.frequency, self.mode, - self.tail_addr.iter().collect::().trim(), + self.tail_addr, self.downlink_status, self.ack, self.label.iter().collect::().trim(), @@ -373,7 +373,7 @@ impl AssembledACARSMessage { Self { mode: ' ', frequency: 0.0, - tail_addr: [' '; 7], + tail_addr: None, downlink_status: DownlinkStatus::AirToGround, ack: AckStatus::Nack, label: [' '; 2], @@ -965,14 +965,17 @@ impl ACARSDecoder { output_message.mode = self.blk.txt[k] as char; k += 1; + let mut tail_addr: [char; 7] = [' '; 7]; for _ in 0..7_usize { if self.blk.txt[k] != b'.' { - output_message.tail_addr[j] = self.blk.txt[k] as char; + tail_addr[j] = self.blk.txt[k] as char; j += 1; } k += 1; } + output_message.tail_addr = Some(tail_addr); + /* ACK/NAK */ if self.blk.txt[k] != 0x15 { output_message.ack = AckStatus::Ack(self.blk.txt[k] as char); From 38c6106ceb516fdef912ebfb56084da0c810970a Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:41:59 -0600 Subject: [PATCH 33/44] no as option --- rust/oxide-decoders/src/decoders/acars.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 7fa7694..d40d907 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -324,7 +324,7 @@ pub struct AssembledACARSMessage { ack: AckStatus, label: [char; 2], bid: char, - no: [char; 4], + no: Option<[char; 4]>, flight_id: Option<[char; 6]>, sublabel: Option<[char; 2]>, mfi: Option<[char; 2]>, @@ -346,7 +346,7 @@ impl Display for AssembledACARSMessage { write!( f, - "frequency: {}, mode: {}, tail addr: {:?}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {}, flight id: {:?}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {:?}, msn seq: {:?}, reassembly status: {}", + "frequency: {}, mode: {}, tail addr: {:?}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {:?}, flight id: {:?}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {:?}, msn seq: {:?}, reassembly status: {}", self.frequency, self.mode, self.tail_addr, @@ -354,7 +354,7 @@ impl Display for AssembledACARSMessage { self.ack, self.label.iter().collect::().trim(), self.bid, - self.no.iter().collect::().trim(), + self.no, self.flight_id, self.sublabel, self.mfi, @@ -378,7 +378,7 @@ impl AssembledACARSMessage { ack: AckStatus::Nack, label: [' '; 2], bid: ' ', - no: [' '; 4], + no: None, flight_id: None, sublabel: None, mfi: None, @@ -1012,24 +1012,27 @@ impl ACARSDecoder { if output_message.bs != 0x03 as char { if is_downlink { /* message no */ + let mut no: [char; 4] = [' '; 4]; while i < 4 && k < self.blk.len - 1 { - output_message.no[i] = self.blk.txt[k] as char; + no[i] = self.blk.txt[k] as char; i += 1; k += 1; } + output_message.no = Some(no); + /* The 3-char prefix is used in reassembly hash table key, so we need */ /* to store the MSN separately as prefix and seq character. */ i = 0; let mut output_msn: [char; 3] = [' '; 3]; while i < 3 { - output_msn[i] = output_message.no[i]; + output_msn[i] = no[i]; i += 1; } output_message.msn = Some(output_msn); - output_message.msn_seq = Some(output_message.no[3]); + output_message.msn_seq = Some(no[3]); i = 0; let mut output_flight_id = [' '; 6]; From 76674d249716f51b610b13c504194642d40b7a5a Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:56:26 -0600 Subject: [PATCH 34/44] Console message formatting improvements --- rust/oxide-decoders/src/decoders/acars.rs | 77 ++++++++++++++++++++--- 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index d40d907..8dc6afe 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -346,24 +346,25 @@ impl Display for AssembledACARSMessage { write!( f, - "frequency: {}, mode: {}, tail addr: {:?}, downlink status: {}, ack: {}, label: {}, bid: {}, no: {:?}, flight id: {:?}, sublabel: {:?}, mfi: {:?}, txt: {:?}, err: {}, lvl: {}, msn: {:?}, msn seq: {:?}, reassembly status: {}", + "Frequency: {}, Mode: {}, {}Downlink Status: {}, Ack: {}, Label: {}, BID: {}, {}{}{}{}ERR: {}, Signal Level: {}, {}{}Reassembly Status: {}{}{}", self.frequency, self.mode, - self.tail_addr, + self.get_tail_addr_display(), self.downlink_status, self.ack, self.label.iter().collect::().trim(), self.bid, - self.no, - self.flight_id, - self.sublabel, - self.mfi, - self.txt, + self.get_no_display(), + self.get_flight_id_display(), + self.get_sub_label_display(), + self.get_mfi_display(), self.err, self.lvl, - self.msn, - self.msn_seq, - self.reassembly_status + self.get_msn_display(), + self.get_msn_seq_display(), + self.reassembly_status, + if self.txt.is_some() { ", " } else { "" }, + self.get_text_display(), ) } } @@ -392,6 +393,62 @@ impl AssembledACARSMessage { reassembly_status: ReassemblyStatus::Skipped, } } + + fn get_text_display(&self) -> String { + match &self.txt { + Some(txt) => format!("Text: {}", txt.iter().collect::()), + None => "".to_string(), + } + } + + fn get_tail_addr_display(&self) -> String { + match &self.tail_addr { + Some(tail_addr) => format!("Tail: {}, ", tail_addr.iter().collect::()), + None => "".to_string(), + } + } + + fn get_no_display(&self) -> String { + match &self.no { + Some(no) => format!("No: {}, ", no.iter().collect::()), + None => "".to_string(), + } + } + + fn get_flight_id_display(&self) -> String { + match &self.flight_id { + Some(flight_id) => format!("Flight ID: {}, ", flight_id.iter().collect::()), + None => "".to_string(), + } + } + + fn get_sub_label_display(&self) -> String { + match &self.sublabel { + Some(sublabel) => format!("Sublabel: {}, ", sublabel.iter().collect::()), + None => "".to_string(), + } + } + + fn get_mfi_display(&self) -> String { + match &self.mfi { + Some(mfi) => format!("MFI: {}, ", mfi.iter().collect::()), + None => "".to_string(), + } + } + + fn get_msn_display(&self) -> String { + match &self.msn { + Some(msn) => format!("MSN: {}, ", msn.iter().collect::()), + None => "".to_string(), + } + } + + fn get_msn_seq_display(&self) -> String { + match &self.msn_seq { + Some(msn_seq) => format!("MSN Seq: {}, ", msn_seq), + None => "".to_string(), + } + } } #[derive(Clone)] From 86121920c455843884bc0fb35d85d2f36321de7f Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 25 May 2023 23:59:12 -0600 Subject: [PATCH 35/44] handle \0 txt case as blank --- rust/oxide-decoders/src/decoders/acars.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 8dc6afe..76cc156 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -396,7 +396,13 @@ impl AssembledACARSMessage { fn get_text_display(&self) -> String { match &self.txt { - Some(txt) => format!("Text: {}", txt.iter().collect::()), + Some(txt) => { + if txt[0] != '\0' { + format!("Text: {}", txt.iter().collect::()) + } else { + "".to_string() + } + } None => "".to_string(), } } From bb949a76ccafd069dac67d3fcaab8681e65fe471 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 00:10:05 -0600 Subject: [PATCH 36/44] Ensure all output formatted fields are actually storing values --- rust/oxide-decoders/src/decoders/acars.rs | 65 +++++++++++++++++++---- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 76cc156..392a9a5 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -342,8 +342,6 @@ pub struct AssembledACARSMessage { impl Display for AssembledACARSMessage { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - // TODO: Format the optional fields appropriately - write!( f, "Frequency: {}, Mode: {}, {}Downlink Status: {}, Ack: {}, Label: {}, BID: {}, {}{}{}{}ERR: {}, Signal Level: {}, {}{}Reassembly Status: {}{}{}", @@ -409,49 +407,98 @@ impl AssembledACARSMessage { fn get_tail_addr_display(&self) -> String { match &self.tail_addr { - Some(tail_addr) => format!("Tail: {}, ", tail_addr.iter().collect::()), + Some(tail_addr) => { + let output = tail_addr.iter().collect::(); + if !output.trim().is_empty() { + format!("Tail: {}, ", output.trim()) + } else { + "".to_string() + } + } None => "".to_string(), } } fn get_no_display(&self) -> String { match &self.no { - Some(no) => format!("No: {}, ", no.iter().collect::()), + Some(no) => { + let output = no.iter().collect::(); + if !output.trim().is_empty() { + format!("No: {}, ", output.trim()) + } else { + "".to_string() + } + } None => "".to_string(), } } fn get_flight_id_display(&self) -> String { match &self.flight_id { - Some(flight_id) => format!("Flight ID: {}, ", flight_id.iter().collect::()), + Some(flight_id) => { + let output = flight_id.iter().collect::(); + if !output.trim().is_empty() { + format!("Flight ID: {}, ", output.trim()) + } else { + "".to_string() + } + } None => "".to_string(), } } fn get_sub_label_display(&self) -> String { match &self.sublabel { - Some(sublabel) => format!("Sublabel: {}, ", sublabel.iter().collect::()), + Some(sublabel) => { + let output = sublabel.iter().collect::(); + if !output.trim().is_empty() { + format!("Sublabel: {}, ", output.trim()) + } else { + "".to_string() + } + } None => "".to_string(), } } fn get_mfi_display(&self) -> String { match &self.mfi { - Some(mfi) => format!("MFI: {}, ", mfi.iter().collect::()), + Some(mfi) => { + let output = mfi.iter().collect::(); + if !output.trim().is_empty() { + format!("MFI: {}, ", output.trim()) + } else { + "".to_string() + } + } None => "".to_string(), } } fn get_msn_display(&self) -> String { match &self.msn { - Some(msn) => format!("MSN: {}, ", msn.iter().collect::()), + Some(msn) => { + let output = msn.iter().collect::(); + if !output.trim().is_empty() { + format!("MSN: {}, ", output.trim()) + } else { + "".to_string() + } + } None => "".to_string(), } } fn get_msn_seq_display(&self) -> String { match &self.msn_seq { - Some(msn_seq) => format!("MSN Seq: {}, ", msn_seq), + Some(msn_seq) => { + let output = String::from(*msn_seq); + if !output.trim().is_empty() { + format!("MSN Seq: {}, ", output.trim()) + } else { + "".to_string() + } + } None => "".to_string(), } } From 602268b0d2ef56d8e9b954d8305a2401734cfa55 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 00:14:34 -0600 Subject: [PATCH 37/44] Ensuring tail is actually a printable value --- rust/oxide-decoders/src/decoders/acars.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 392a9a5..eaf0e32 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -1078,13 +1078,23 @@ impl ACARSDecoder { let mut tail_addr: [char; 7] = [' '; 7]; for _ in 0..7_usize { if self.blk.txt[k] != b'.' { + // ensure self.blk.txt[k] is A-Z or 0-9 + if (self.blk.txt[k] < b'0' || self.blk.txt[k] > b'9') + && (self.blk.txt[k] < b'A' || self.blk.txt[k] > b'Z') + { + continue; + } + tail_addr[j] = self.blk.txt[k] as char; j += 1; } k += 1; } - output_message.tail_addr = Some(tail_addr); + // Ensure we actually saved something as a tail address + if tail_addr[0] != ' ' { + output_message.tail_addr = Some(tail_addr); + } /* ACK/NAK */ if self.blk.txt[k] != 0x15 { From 715077902f7bd8a107bc90135c062543ee7c3868 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 00:25:20 -0600 Subject: [PATCH 38/44] Instead of \0 as the text no display, use length --- rust/oxide-decoders/src/decoders/acars.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index eaf0e32..4926402 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -395,7 +395,7 @@ impl AssembledACARSMessage { fn get_text_display(&self) -> String { match &self.txt { Some(txt) => { - if txt[0] != '\0' { + if txt.len() > 1 { format!("Text: {}", txt.iter().collect::()) } else { "".to_string() From 20cb947251ba6fdadae29730f5c9ad892b8b648e Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 00:35:44 -0600 Subject: [PATCH 39/44] fix labels for messages with no tail --- rust/oxide-decoders/src/decoders/acars.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 4926402..39bbfd4 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -1079,13 +1079,12 @@ impl ACARSDecoder { for _ in 0..7_usize { if self.blk.txt[k] != b'.' { // ensure self.blk.txt[k] is A-Z or 0-9 - if (self.blk.txt[k] < b'0' || self.blk.txt[k] > b'9') - && (self.blk.txt[k] < b'A' || self.blk.txt[k] > b'Z') + if (self.blk.txt[k] >= b'0' && self.blk.txt[k] <= b'9') + || (self.blk.txt[k] >= b'A' && self.blk.txt[k] <= b'Z') { - continue; + tail_addr[j] = self.blk.txt[k] as char; } - tail_addr[j] = self.blk.txt[k] as char; j += 1; } k += 1; From 6c9fe39e870ce35b3892a8e9c39e58612950b353 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 00:53:25 -0600 Subject: [PATCH 40/44] try and stop BID from being displayed if it's a SQ or non-printable.... --- rust/oxide-decoders/src/decoders/acars.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 39bbfd4..23b6394 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -344,14 +344,14 @@ impl Display for AssembledACARSMessage { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, - "Frequency: {}, Mode: {}, {}Downlink Status: {}, Ack: {}, Label: {}, BID: {}, {}{}{}{}ERR: {}, Signal Level: {}, {}{}Reassembly Status: {}{}{}", + "Frequency: {}, Mode: {}, {}Downlink Status: {}, Ack: {}, Label: {}, {}{}{}{}{}ERR: {}, Signal Level: {}, {}{}Reassembly Status: {}{}{}", self.frequency, self.mode, self.get_tail_addr_display(), self.downlink_status, self.ack, self.label.iter().collect::().trim(), - self.bid, + self.get_bid_display(), self.get_no_display(), self.get_flight_id_display(), self.get_sub_label_display(), @@ -502,6 +502,17 @@ impl AssembledACARSMessage { None => "".to_string(), } } + + fn get_bid_display(&self) -> String { + if self.bid as u8 == 0 { + "".to_string() + } else { + match self.bid { + ' ' => "".to_string(), + _ => format!("Block ID: {}, ", self.bid), + } + } + } } #[derive(Clone)] From 4125df433ca3477f6f2d0cb7aefa1151a6483d27 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 00:55:48 -0600 Subject: [PATCH 41/44] Set config gain defaults to not autogain --- rust/oxide-config/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rust/oxide-config/src/lib.rs b/rust/oxide-config/src/lib.rs index e57ca83..5a6dea7 100644 --- a/rust/oxide-config/src/lib.rs +++ b/rust/oxide-config/src/lib.rs @@ -71,7 +71,7 @@ pub struct OxideInput { long, env = "AO_SDR1GAIN", value_parser = parse_sdr_gain, - default_value = "60", + default_value = "42", hide = true, requires = "sdr1serial" )] @@ -137,7 +137,7 @@ pub struct OxideInput { long, env = "AO_SDR2GAIN", value_parser = parse_sdr_gain, - default_value = "60", + default_value = "42", hide = true, requires = "sdr2serial" )] @@ -203,7 +203,7 @@ pub struct OxideInput { long, env = "AO_SDR3GAIN", value_parser = parse_sdr_gain, - default_value = "60", + default_value = "42", hide = true, requires = "sdr3serial" )] @@ -269,7 +269,7 @@ pub struct OxideInput { long, env = "AO_SDR4GAIN", value_parser = parse_sdr_gain, - default_value = "60", + default_value = "42", hide = true, requires = "sdr4serial" )] @@ -335,7 +335,7 @@ pub struct OxideInput { long, env = "AO_SDR5GAIN", value_parser = parse_sdr_gain, - default_value = "60", + default_value = "42", hide = true, requires = "sdr5serial" )] @@ -401,7 +401,7 @@ pub struct OxideInput { long, env = "AO_SDR6GAIN", value_parser = parse_sdr_gain, - default_value = "60", + default_value = "42", hide = true, requires = "sdr6serial" )] @@ -467,7 +467,7 @@ pub struct OxideInput { long, env = "AO_SDR7GAIN", value_parser = parse_sdr_gain, - default_value = "60", + default_value = "42", hide = true, requires = "sdr7serial" )] @@ -533,7 +533,7 @@ pub struct OxideInput { long, env = "AO_SDR8GAIN", value_parser = parse_sdr_gain, - default_value = "60", + default_value = "42", hide = true, requires = "sdr8serial" )] From 5373971fa2f90fdd742709dccff85294adb4deb2 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 00:58:49 -0600 Subject: [PATCH 42/44] Use better language for printing the error --- rust/oxide-decoders/src/decoders/acars.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 23b6394..8ef75b8 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -344,7 +344,7 @@ impl Display for AssembledACARSMessage { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, - "Frequency: {}, Mode: {}, {}Downlink Status: {}, Ack: {}, Label: {}, {}{}{}{}{}ERR: {}, Signal Level: {}, {}{}Reassembly Status: {}{}{}", + "Frequency: {}, Mode: {}, {}Downlink Status: {}, Ack: {}, Label: {}, {}{}{}{}{}Reception Errors: {}, Signal Level: {}, {}{}Reassembly Status: {}{}{}", self.frequency, self.mode, self.get_tail_addr_display(), From b16cbe0a98d4276adcc87c2a8941f82e8421afd4 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 12:21:24 -0600 Subject: [PATCH 43/44] remove oooi parsing --- rust/oxide-decoders/src/decoders/acars_labels.rs | 15 --------------- rust/oxide-decoders/src/lib.rs | 1 - 2 files changed, 16 deletions(-) delete mode 100644 rust/oxide-decoders/src/decoders/acars_labels.rs diff --git a/rust/oxide-decoders/src/decoders/acars_labels.rs b/rust/oxide-decoders/src/decoders/acars_labels.rs deleted file mode 100644 index f4c31d2..0000000 --- a/rust/oxide-decoders/src/decoders/acars_labels.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Fred Clausen - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA diff --git a/rust/oxide-decoders/src/lib.rs b/rust/oxide-decoders/src/lib.rs index ab2cf65..0dc0a9c 100644 --- a/rust/oxide-decoders/src/lib.rs +++ b/rust/oxide-decoders/src/lib.rs @@ -24,7 +24,6 @@ extern crate log; pub mod decoders { pub mod acars; - pub mod acars_labels; } #[derive(Debug, Clone)] From 791ae8099da40fc3d6472f689c063ca6ff097ce8 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Fri, 26 May 2023 15:47:06 -0600 Subject: [PATCH 44/44] Disable Reassembly status --- rust/oxide-decoders/src/decoders/acars.rs | 60 +++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/rust/oxide-decoders/src/decoders/acars.rs b/rust/oxide-decoders/src/decoders/acars.rs index 8ef75b8..6c8a5af 100644 --- a/rust/oxide-decoders/src/decoders/acars.rs +++ b/rust/oxide-decoders/src/decoders/acars.rs @@ -275,31 +275,31 @@ impl Display for DownlinkStatus { } } -#[allow(dead_code)] -#[derive(Debug, Clone)] -enum ReassemblyStatus { - Unknown, - Complete, - InProgress, - Skipped, - Duplicate, - FragOutOfSequence, - ArgsInvalid, -} - -impl Display for ReassemblyStatus { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - ReassemblyStatus::Unknown => write!(f, "Unknown"), - ReassemblyStatus::Complete => write!(f, "Complete"), - ReassemblyStatus::InProgress => write!(f, "In Progress"), - ReassemblyStatus::Skipped => write!(f, "Skipped"), - ReassemblyStatus::Duplicate => write!(f, "Duplicate"), - ReassemblyStatus::FragOutOfSequence => write!(f, "Fragment out of sequence"), - ReassemblyStatus::ArgsInvalid => write!(f, "Invalid arguments"), - } - } -} +// #[allow(dead_code)] +// #[derive(Debug, Clone)] +// enum ReassemblyStatus { +// Unknown, +// Complete, +// InProgress, +// Skipped, +// Duplicate, +// FragOutOfSequence, +// ArgsInvalid, +// } + +// impl Display for ReassemblyStatus { +// fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { +// match self { +// ReassemblyStatus::Unknown => write!(f, "Unknown"), +// ReassemblyStatus::Complete => write!(f, "Complete"), +// ReassemblyStatus::InProgress => write!(f, "In Progress"), +// ReassemblyStatus::Skipped => write!(f, "Skipped"), +// ReassemblyStatus::Duplicate => write!(f, "Duplicate"), +// ReassemblyStatus::FragOutOfSequence => write!(f, "Fragment out of sequence"), +// ReassemblyStatus::ArgsInvalid => write!(f, "Invalid arguments"), +// } +// } +// } #[derive(Debug, Clone)] enum AckStatus { @@ -337,14 +337,14 @@ pub struct AssembledACARSMessage { downlink_status: DownlinkStatus, msn: Option<[char; 3]>, msn_seq: Option, - reassembly_status: ReassemblyStatus, + // reassembly_status: ReassemblyStatus, } impl Display for AssembledACARSMessage { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, - "Frequency: {}, Mode: {}, {}Downlink Status: {}, Ack: {}, Label: {}, {}{}{}{}{}Reception Errors: {}, Signal Level: {}, {}{}Reassembly Status: {}{}{}", + "Frequency: {}, Mode: {}, {}Downlink Status: {}, Ack: {}, Label: {}, {}{}{}{}{}Reception Errors: {}, Signal Level: {}, {}{}{}", self.frequency, self.mode, self.get_tail_addr_display(), @@ -360,8 +360,8 @@ impl Display for AssembledACARSMessage { self.lvl, self.get_msn_display(), self.get_msn_seq_display(), - self.reassembly_status, - if self.txt.is_some() { ", " } else { "" }, + // self.reassembly_status, + // if self.txt.is_some() { ", " } else { "" }, self.get_text_display(), ) } @@ -388,7 +388,7 @@ impl AssembledACARSMessage { lvl: 0.0, msn: None, msn_seq: None, - reassembly_status: ReassemblyStatus::Skipped, + // reassembly_status: ReassemblyStatus::Skipped, } }