From 7062c12ef06bcb14ffd92244fe160279798857ac Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 17:05:30 +0100 Subject: [PATCH 01/11] added trybuild --- Cargo.lock | 64 ++++++++++++++++++++++++++++++++++++- satrs-macros/Cargo.toml | 12 ++++++- satrs-macros/src/lib.rs | 8 ++++- satrs-macros/tests/basic.rs | 7 ++++ satrs-macros/tests/tests.rs | 5 +++ 5 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 satrs-macros/tests/basic.rs create mode 100644 satrs-macros/tests/tests.rs diff --git a/Cargo.lock b/Cargo.lock index a210b52..fd2ae3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,6 +278,12 @@ dependencies = [ "syn", ] +[[package]] +name = "dissimilar" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c97b9233581d84b8e1e689cdd3a47b6f69770084fc246e86a7f78b0d9c1d4a5" + [[package]] name = "downcast-rs" version = "1.2.0" @@ -312,6 +318,12 @@ dependencies = [ "void", ] +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + [[package]] name = "hash32" version = "0.2.1" @@ -377,6 +389,12 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + [[package]] name = "js-sys" version = "0.3.60" @@ -595,6 +613,12 @@ dependencies = [ "semver 1.0.14", ] +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + [[package]] name = "satrs-core" version = "0.1.0" @@ -628,12 +652,14 @@ dependencies = [ ] [[package]] -name = "satrs-macro" +name = "satrs-macros" version = "0.1.0" dependencies = [ "proc-macro2", "quote", + "satrs-core", "syn", + "trybuild", ] [[package]] @@ -689,6 +715,17 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_json" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "smallvec" version = "1.10.0" @@ -743,6 +780,31 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "trybuild" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea496675d71016e9bc76aa42d87f16aefd95447cc5818e671e12b2d7e269075d" +dependencies = [ + "dissimilar", + "glob", + "once_cell", + "serde", + "serde_derive", + "serde_json", + "termcolor", + "toml", +] + [[package]] name = "unicode-ident" version = "1.0.5" diff --git a/satrs-macros/Cargo.toml b/satrs-macros/Cargo.toml index 7f56423..9c67bea 100644 --- a/satrs-macros/Cargo.toml +++ b/satrs-macros/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "satrs-macro" +name = "satrs-macros" version = "0.1.0" edition = "2021" @@ -7,10 +7,20 @@ edition = "2021" [lib] proc-macro = true +[[test]] +name = "tests" +path = "tests/tests.rs" + [dependencies] quote = "1.0" proc-macro2 = "1.0" +[dependencies.satrs-core] +path = "../satrs-core" + +[dev-dependencies] +trybuild = { version = "1.0", features = ["diff"] } + [dependencies.syn] version = "1.0" features = ["extra-traits"] diff --git a/satrs-macros/src/lib.rs b/satrs-macros/src/lib.rs index 8b13789..7bcd0cd 100644 --- a/satrs-macros/src/lib.rs +++ b/satrs-macros/src/lib.rs @@ -1 +1,7 @@ - +#[proc_macro_attribute] +pub fn result( + _attr: proc_macro::TokenStream, + item: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + item +} diff --git a/satrs-macros/tests/basic.rs b/satrs-macros/tests/basic.rs new file mode 100644 index 0000000..f9a8210 --- /dev/null +++ b/satrs-macros/tests/basic.rs @@ -0,0 +1,7 @@ +use satrs_core::resultcode::ResultU16; +use satrs_macros::*; + +#[result] +const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); + +fn main() {} diff --git a/satrs-macros/tests/tests.rs b/satrs-macros/tests/tests.rs new file mode 100644 index 0000000..71b63af --- /dev/null +++ b/satrs-macros/tests/tests.rs @@ -0,0 +1,5 @@ +#[test] +fn tests() { + let t = trybuild::TestCases::new(); + t.pass("tests/basic.rs"); +} -- 2.43.0 From 9b37c63280deda8541cb660bf1810798071d54f8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 18:21:50 +0100 Subject: [PATCH 02/11] first macro impl --- satrs-core/src/resultcode.rs | 8 +- satrs-macros/src/lib.rs | 102 +++++++++++++++++++++++- satrs-macros/src/main.rs | 7 ++ satrs-macros/tests/basic.rs | 2 +- satrs-macros/tests/group_in_enum.rs | 12 +++ satrs-macros/tests/tests.rs | 2 + satrs-macros/tests/verify_gen_struct.rs | 7 ++ 7 files changed, 135 insertions(+), 5 deletions(-) create mode 100644 satrs-macros/src/main.rs create mode 100644 satrs-macros/tests/group_in_enum.rs create mode 100644 satrs-macros/tests/verify_gen_struct.rs diff --git a/satrs-core/src/resultcode.rs b/satrs-core/src/resultcode.rs index ab2edc4..885c7fb 100644 --- a/satrs-core/src/resultcode.rs +++ b/satrs-core/src/resultcode.rs @@ -25,12 +25,16 @@ impl ResultU16 { #[derive(Debug)] pub struct ResultU16Ext { pub name: &'static str, - pub result: ResultU16, + pub result: &'static ResultU16, pub info: &'static str, } impl ResultU16Ext { - pub const fn const_new(name: &'static str, result: ResultU16, info: &'static str) -> Self { + pub const fn const_new( + name: &'static str, + result: &'static ResultU16, + info: &'static str, + ) -> Self { Self { name, result, info } } } diff --git a/satrs-macros/src/lib.rs b/satrs-macros/src/lib.rs index 7bcd0cd..83e3e00 100644 --- a/satrs-macros/src/lib.rs +++ b/satrs-macros/src/lib.rs @@ -1,7 +1,105 @@ +use proc_macro2::{Ident, TokenStream}; +use quote::{format_ident, quote, ToTokens}; +use syn::spanned::Spanned; +use syn::{parse_macro_input, AttributeArgs, Item, Lit, LitStr, Meta, NestedMeta, Type}; + +#[derive(Default)] +struct ResultExtGenerator { + name_str: Option, + info_str: Option, +} + #[proc_macro_attribute] pub fn result( - _attr: proc_macro::TokenStream, + args: proc_macro::TokenStream, item: proc_macro::TokenStream, ) -> proc_macro::TokenStream { - item + let args = parse_macro_input!(args as AttributeArgs); + let input = parse_macro_input!(item as Item); + + dbg!("Arguments: {}", &args); + dbg!("Input: {}", &input); + let mut result_ext_generator = ResultExtGenerator::default(); + result_ext_generator.parse(args, input).into() +} + +impl ResultExtGenerator { + pub fn parse(&mut self, args: AttributeArgs, input: Item) -> TokenStream { + let mut output = input.to_token_stream(); + if let Err(e) = self.parse_args(args) { + output.extend(e.into_compile_error()); + return output; + } + match self.gen_ext_struct(input) { + Ok(ts) => output.extend(ts), + Err(e) => output.extend(e.into_compile_error()), + } + output + } + + pub fn parse_args(&mut self, args: AttributeArgs) -> syn::Result<()> { + for arg in args { + if let NestedMeta::Meta(Meta::NameValue(nvm)) = arg { + if let Some(path) = nvm.path.segments.first() { + if path.ident == "info" { + if let Lit::Str(str) = nvm.lit { + self.info_str = Some(str); + } else { + return Err(syn::Error::new( + nvm.lit.span(), + "Only literal strings are allowed as information", + )); + } + } else { + return Err(syn::Error::new( + path.span(), + format!( + "Unknown attribute argument name {}", + path.ident + ), + )); + } + } + } + } + Ok(()) + } + + pub fn gen_ext_struct(&mut self, input: Item) -> syn::Result { + if let Item::Const(const_item) = &input { + self.name_str = Some(const_item.ident.clone()); + if let Type::Path(p) = &const_item.ty.as_ref() { + let mut valid_type_found = false; + for seg in &p.path.segments { + if seg.ident == "ResultU16" { + valid_type_found = true; + } + } + if !valid_type_found { + return Err(syn::Error::new( + p.span(), + "Can only be applied on items of type ResultU16", + )); + } + } + } else { + return Err(syn::Error::new( + input.span(), + "Only const items are allowed to be use with this attribute", + )); + } + let result_code_name = self.name_str.to_owned().unwrap(); + let name_as_str = result_code_name.to_string(); + let gen_struct_name = format_ident!("{}_EXT", result_code_name); + let info_str = self.info_str.to_owned().unwrap(); + let gen_struct = quote! { + const #gen_struct_name: satrs_core::resultcode::ResultU16Ext = satrs_core::resultcode::ResultU16Ext { + name: #name_as_str, + result: &#result_code_name, + info: #info_str + }; + }; + Ok(gen_struct) + //Ok(TokenStream::new()) + } } diff --git a/satrs-macros/src/main.rs b/satrs-macros/src/main.rs new file mode 100644 index 0000000..7eb903a --- /dev/null +++ b/satrs-macros/src/main.rs @@ -0,0 +1,7 @@ +use satrs_core::resultcode::ResultU16; +use satrs_macros::*; + +#[result(info = "This is a test result where the first parameter is foo")] +const _TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); + +fn main() {} diff --git a/satrs-macros/tests/basic.rs b/satrs-macros/tests/basic.rs index f9a8210..e224e4a 100644 --- a/satrs-macros/tests/basic.rs +++ b/satrs-macros/tests/basic.rs @@ -1,7 +1,7 @@ use satrs_core::resultcode::ResultU16; use satrs_macros::*; -#[result] +#[result(info = "This is a test result where the first parameter is foo")] const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); fn main() {} diff --git a/satrs-macros/tests/group_in_enum.rs b/satrs-macros/tests/group_in_enum.rs new file mode 100644 index 0000000..ecc71dc --- /dev/null +++ b/satrs-macros/tests/group_in_enum.rs @@ -0,0 +1,12 @@ +use satrs_core::resultcode::ResultU16; +use satrs_macros::*; + +pub enum GroupIds { + Group0 = 0, + Group1 = 1, +} + +#[result(info = "This is a test result where the first parameter is foo")] +const TEST_RESULT: ResultU16 = ResultU16::const_new(GroupIds::Group0 as u8, 1); + +fn main() {} diff --git a/satrs-macros/tests/tests.rs b/satrs-macros/tests/tests.rs index 71b63af..d1b72fe 100644 --- a/satrs-macros/tests/tests.rs +++ b/satrs-macros/tests/tests.rs @@ -2,4 +2,6 @@ fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/basic.rs"); + //t.pass("tests/verify_gen_struct.rs"); + //t.pass("tests/group_in_enum.rs"); } diff --git a/satrs-macros/tests/verify_gen_struct.rs b/satrs-macros/tests/verify_gen_struct.rs new file mode 100644 index 0000000..e224e4a --- /dev/null +++ b/satrs-macros/tests/verify_gen_struct.rs @@ -0,0 +1,7 @@ +use satrs_core::resultcode::ResultU16; +use satrs_macros::*; + +#[result(info = "This is a test result where the first parameter is foo")] +const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); + +fn main() {} -- 2.43.0 From 23150124485eae9c2d7a1bf5096e9f613eb40969 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 18:47:02 +0100 Subject: [PATCH 03/11] first version works --- satrs-macros/src/lib.rs | 22 ++++++++-------------- satrs-macros/src/main.rs | 2 +- satrs-macros/tests/basic.rs | 3 ++- satrs-macros/tests/group_in_enum.rs | 12 ------------ satrs-macros/tests/tests.rs | 2 +- satrs-macros/tests/verify_gen_struct.rs | 16 +++++++++++++--- 6 files changed, 25 insertions(+), 32 deletions(-) delete mode 100644 satrs-macros/tests/group_in_enum.rs diff --git a/satrs-macros/src/lib.rs b/satrs-macros/src/lib.rs index 83e3e00..98a6429 100644 --- a/satrs-macros/src/lib.rs +++ b/satrs-macros/src/lib.rs @@ -10,15 +10,12 @@ struct ResultExtGenerator { } #[proc_macro_attribute] -pub fn result( +pub fn resultcode( args: proc_macro::TokenStream, item: proc_macro::TokenStream, ) -> proc_macro::TokenStream { let args = parse_macro_input!(args as AttributeArgs); let input = parse_macro_input!(item as Item); - - dbg!("Arguments: {}", &args); - dbg!("Input: {}", &input); let mut result_ext_generator = ResultExtGenerator::default(); result_ext_generator.parse(args, input).into() } @@ -53,10 +50,7 @@ impl ResultExtGenerator { } else { return Err(syn::Error::new( path.span(), - format!( - "Unknown attribute argument name {}", - path.ident - ), + format!("Unknown attribute argument name {}", path.ident), )); } } @@ -93,13 +87,13 @@ impl ResultExtGenerator { let gen_struct_name = format_ident!("{}_EXT", result_code_name); let info_str = self.info_str.to_owned().unwrap(); let gen_struct = quote! { - const #gen_struct_name: satrs_core::resultcode::ResultU16Ext = satrs_core::resultcode::ResultU16Ext { - name: #name_as_str, - result: &#result_code_name, - info: #info_str - }; + const #gen_struct_name: satrs_core::resultcode::ResultU16Ext = + satrs_core::resultcode::ResultU16Ext::const_new( + #name_as_str, + &#result_code_name, + #info_str + ); }; Ok(gen_struct) - //Ok(TokenStream::new()) } } diff --git a/satrs-macros/src/main.rs b/satrs-macros/src/main.rs index 7eb903a..ed36991 100644 --- a/satrs-macros/src/main.rs +++ b/satrs-macros/src/main.rs @@ -1,7 +1,7 @@ use satrs_core::resultcode::ResultU16; use satrs_macros::*; -#[result(info = "This is a test result where the first parameter is foo")] +#[resultcode(info = "This is a test result where the first parameter is foo")] const _TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); fn main() {} diff --git a/satrs-macros/tests/basic.rs b/satrs-macros/tests/basic.rs index e224e4a..bcb16b5 100644 --- a/satrs-macros/tests/basic.rs +++ b/satrs-macros/tests/basic.rs @@ -1,7 +1,8 @@ +//! Basic check which just verifies that everything compiles use satrs_core::resultcode::ResultU16; use satrs_macros::*; -#[result(info = "This is a test result where the first parameter is foo")] +#[resultcode(info = "This is a test result where the first parameter is foo")] const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); fn main() {} diff --git a/satrs-macros/tests/group_in_enum.rs b/satrs-macros/tests/group_in_enum.rs deleted file mode 100644 index ecc71dc..0000000 --- a/satrs-macros/tests/group_in_enum.rs +++ /dev/null @@ -1,12 +0,0 @@ -use satrs_core::resultcode::ResultU16; -use satrs_macros::*; - -pub enum GroupIds { - Group0 = 0, - Group1 = 1, -} - -#[result(info = "This is a test result where the first parameter is foo")] -const TEST_RESULT: ResultU16 = ResultU16::const_new(GroupIds::Group0 as u8, 1); - -fn main() {} diff --git a/satrs-macros/tests/tests.rs b/satrs-macros/tests/tests.rs index d1b72fe..daf9fc7 100644 --- a/satrs-macros/tests/tests.rs +++ b/satrs-macros/tests/tests.rs @@ -2,6 +2,6 @@ fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/basic.rs"); - //t.pass("tests/verify_gen_struct.rs"); + t.pass("tests/verify_gen_struct.rs"); //t.pass("tests/group_in_enum.rs"); } diff --git a/satrs-macros/tests/verify_gen_struct.rs b/satrs-macros/tests/verify_gen_struct.rs index e224e4a..3d308a2 100644 --- a/satrs-macros/tests/verify_gen_struct.rs +++ b/satrs-macros/tests/verify_gen_struct.rs @@ -1,7 +1,17 @@ -use satrs_core::resultcode::ResultU16; +use satrs_core::resultcode::{ResultU16, ResultU16Ext}; use satrs_macros::*; -#[result(info = "This is a test result where the first parameter is foo")] +#[resultcode(info = "This is a test result where the first parameter is foo")] const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); +// Create named reference of auto-generated struct, which can be used by IDEs etc. +const TEST_RESULT_EXT_REF: &ResultU16Ext = &TEST_RESULT_EXT; -fn main() {} +fn main() { + assert_eq!(TEST_RESULT_EXT.name, "TEST_RESULT"); + assert_eq!(TEST_RESULT_EXT.result, &TEST_RESULT); + assert_eq!( + TEST_RESULT_EXT.info, + "This is a test result where the first parameter is foo" + ); + assert_eq!(TEST_RESULT_EXT_REF.name, "TEST_RESULT"); +} -- 2.43.0 From 7e0d3f394af309235854a62bbef22f1d0298733b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 19:24:18 +0100 Subject: [PATCH 04/11] add returncode module --- Cargo.lock | 1 + satrs-core/src/resultcode.rs | 27 +++++++++++++++++++++++++++ satrs-example/Cargo.toml | 3 +++ satrs-example/src/main.rs | 1 + satrs-example/src/pus.rs | 23 ++++++++++++----------- satrs-example/src/results.rs | 15 +++++++++++++++ satrs-macros/src/lib.rs | 6 +++++- 7 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 satrs-example/src/results.rs diff --git a/Cargo.lock b/Cargo.lock index fd2ae3e..a1eae3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -647,6 +647,7 @@ dependencies = [ "crossbeam-channel", "delegate 0.8.0", "satrs-core", + "satrs-macros", "spacepackets", "zerocopy", ] diff --git a/satrs-core/src/resultcode.rs b/satrs-core/src/resultcode.rs index 885c7fb..5bfc598 100644 --- a/satrs-core/src/resultcode.rs +++ b/satrs-core/src/resultcode.rs @@ -1,3 +1,6 @@ +use spacepackets::{ByteConversionError, SizeMissmatch}; +use spacepackets::ecss::{EcssEnumeration, EcssEnumU16}; + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct ResultU16 { group_id: u8, @@ -22,6 +25,30 @@ impl ResultU16 { } } +impl From for EcssEnumU16 { + fn from(v: ResultU16) -> Self { + EcssEnumU16::new(v.raw()) + } +} + +impl EcssEnumeration for ResultU16 { + fn pfc(&self) -> u8 { + 16 + } + + fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError> { + if buf.len() < 2 { + return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch { + found: buf.len(), + expected: 2 + })); + } + buf[0] = self.group_id; + buf[1] = self.unique_id; + Ok(()) + } +} + #[derive(Debug)] pub struct ResultU16Ext { pub name: &'static str, diff --git a/satrs-example/Cargo.toml b/satrs-example/Cargo.toml index 2542451..94bf27f 100644 --- a/satrs-example/Cargo.toml +++ b/satrs-example/Cargo.toml @@ -13,5 +13,8 @@ zerocopy = "0.6" [dependencies.spacepackets] path = "../spacepackets" +[dependencies.satrs-macros] +path = "../satrs-macros" + [dependencies.satrs-core] path = "../satrs-core" diff --git a/satrs-example/src/main.rs b/satrs-example/src/main.rs index efb6628..159fe67 100644 --- a/satrs-example/src/main.rs +++ b/satrs-example/src/main.rs @@ -1,6 +1,7 @@ mod ccsds; mod pus; mod tmtc; +mod results; use crate::tmtc::{core_tmtc_task, CoreTmtcArgs, TmStore, PUS_APID}; use satrs_core::event_man::{ diff --git a/satrs-example/src/pus.rs b/satrs-example/src/pus.rs index 18a21b9..a2950aa 100644 --- a/satrs-example/src/pus.rs +++ b/satrs-example/src/pus.rs @@ -1,4 +1,5 @@ use crate::tmtc::TmStore; +use crate::results::{INVALID_PUS_SERVICE, INVALID_PUS_SUBSERVICE, NOT_ENOUGH_APP_DATA}; use satrs_core::events::EventU32; use satrs_core::pool::StoreAddr; use satrs_core::pus::event::Subservices; @@ -8,11 +9,12 @@ use satrs_core::pus::verification::{ }; use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper; use satrs_core::tmtc::PusServiceProvider; -use spacepackets::ecss::{EcssEnumU16, PusPacket}; +use spacepackets::ecss::PusPacket; use spacepackets::tc::PusTc; use spacepackets::time::{CdsShortTimeProvider, TimeWriter}; use spacepackets::SpHeader; use std::sync::mpsc; +use satrs_core::resultcode::ResultU16; pub struct PusReceiver { pub tm_helper: PusTmWithCdsShortHelper, @@ -64,8 +66,9 @@ impl PusServiceProvider for PusReceiver { } else if service == 5 { self.handle_event_service(pus_tc, accepted_token); } else { - // TODO: Unknown service verification failure - // TODO: Unknown service returncode + self.update_time_stamp(); + self.verif_reporter.start_failure(accepted_token, FailParams::new(&self.time_stamp, &INVALID_PUS_SERVICE, None)) + .expect("Start failure verification failed") } Ok(()) } @@ -89,12 +92,11 @@ impl PusReceiver { .completion_success(start_token, &self.time_stamp) .expect("Error sending completion success"); } else { - // TODO: Unknown Subservice returncode self.update_time_stamp(); self.verif_reporter .start_failure( token, - FailParams::new(&self.time_stamp, &EcssEnumU16::new(2), None), + FailParams::new(&self.time_stamp, &INVALID_PUS_SUBSERVICE, None), ) .expect("Sending start failure TM failed"); } @@ -112,12 +114,12 @@ impl PusReceiver { fn handle_event_service(&mut self, pus_tc: &PusTc, token: VerificationToken) { let send_start_failure = |verif_reporter: &mut StdVerifReporterWithSender, timestamp: &[u8; 7], - failure_code: EcssEnumU16, + failure_code: &ResultU16, failure_data: Option<&[u8]>| { verif_reporter .start_failure( token, - FailParams::new(timestamp, &failure_code, failure_data), + FailParams::new(timestamp, failure_code, failure_data), ) .expect("Sending start failure TM failed"); }; @@ -132,7 +134,7 @@ impl PusReceiver { send_start_failure( &mut self.verif_reporter, &self.time_stamp, - EcssEnumU16::new(1), + &NOT_ENOUGH_APP_DATA, None, ); return; @@ -143,7 +145,7 @@ impl PusReceiver { send_start_failure( &mut self.verif_reporter, &self.time_stamp, - EcssEnumU16::new(1), + &NOT_ENOUGH_APP_DATA, None, ); return; @@ -171,12 +173,11 @@ impl PusReceiver { .expect("Sending event request failed"); } _ => { - // TODO: Unknown Subservice returncode self.update_time_stamp(); send_start_failure( &mut self.verif_reporter, &self.time_stamp, - EcssEnumU16::new(2), + &INVALID_PUS_SUBSERVICE, None, ); } diff --git a/satrs-example/src/results.rs b/satrs-example/src/results.rs new file mode 100644 index 0000000..e521a84 --- /dev/null +++ b/satrs-example/src/results.rs @@ -0,0 +1,15 @@ +use satrs_core::resultcode::ResultU16; +use satrs_macros::resultcode; + +#[derive(Debug)] +pub enum GroupId { + Tmtc = 0, +} + +#[resultcode] +pub const INVALID_PUS_SERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 0); +#[resultcode] +pub const INVALID_PUS_SUBSERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 1); + +#[resultcode(info="Not enough data inside the TC application data field")] +pub const NOT_ENOUGH_APP_DATA: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 2); diff --git a/satrs-macros/src/lib.rs b/satrs-macros/src/lib.rs index 98a6429..4d2598e 100644 --- a/satrs-macros/src/lib.rs +++ b/satrs-macros/src/lib.rs @@ -85,7 +85,11 @@ impl ResultExtGenerator { let result_code_name = self.name_str.to_owned().unwrap(); let name_as_str = result_code_name.to_string(); let gen_struct_name = format_ident!("{}_EXT", result_code_name); - let info_str = self.info_str.to_owned().unwrap(); + let info_str = if let Some(info_str) = &self.info_str { + info_str.value() + } else { + String::from("") + }; let gen_struct = quote! { const #gen_struct_name: satrs_core::resultcode::ResultU16Ext = satrs_core::resultcode::ResultU16Ext::const_new( -- 2.43.0 From b0b41a07dc0deef8801c1a56679b759696647569 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 22:05:42 +0100 Subject: [PATCH 05/11] new mib crate --- Cargo.lock | 117 +++++++++++++- Cargo.toml | 1 + satrs-core/Cargo.toml | 8 +- satrs-core/src/lib.rs | 2 +- satrs-core/src/{resultcode.rs => res_code.rs} | 24 +-- satrs-example/Cargo.toml | 4 + satrs-example/src/bin/simpleclient.rs | 4 +- satrs-example/src/lib.rs | 23 +++ satrs-example/src/main.rs | 1 - satrs-example/src/pus.rs | 10 +- satrs-example/src/results.rs | 15 -- satrs-macros/Cargo.toml | 3 + satrs-macros/src/lib.rs | 6 +- satrs-macros/src/main.rs | 7 - satrs-macros/tests/basic.rs | 4 +- satrs-macros/tests/verify_gen_struct.rs | 5 +- satrs-mib/Cargo.toml | 20 +++ satrs-mib/src/lib.rs | 1 + satrs-mib/src/res_code.rs | 151 ++++++++++++++++++ 19 files changed, 341 insertions(+), 65 deletions(-) rename satrs-core/src/{resultcode.rs => res_code.rs} (69%) delete mode 100644 satrs-example/src/results.rs delete mode 100644 satrs-macros/src/main.rs create mode 100644 satrs-mib/Cargo.toml create mode 100644 satrs-mib/src/lib.rs create mode 100644 satrs-mib/src/res_code.rs diff --git a/Cargo.lock b/Cargo.lock index a1eae3b..273cc77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,9 +15,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] @@ -31,6 +31,15 @@ dependencies = [ "libc", ] +[[package]] +name = "array-init" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" +dependencies = [ + "nodrop", +] + [[package]] name = "atomic-polyfill" version = "0.1.10" @@ -85,6 +94,18 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + [[package]] name = "bumpalo" version = "3.11.1" @@ -110,9 +131,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.76" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "cfg-if" @@ -205,13 +226,35 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422f23e724af1240ec469ea1e834d87a4b59ce2efe2c6a96256b0c47e2fd86aa" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" dependencies = [ "cfg-if", ] +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa 0.4.8", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + [[package]] name = "cxx" version = "1.0.82" @@ -389,6 +432,12 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + [[package]] name = "itoa" version = "1.0.4" @@ -444,6 +493,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + [[package]] name = "memchr" version = "2.5.0" @@ -465,6 +520,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "num-integer" version = "0.1.45" @@ -509,7 +570,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall", - "smallvec", + "smallvec 1.10.0", "windows-sys", ] @@ -568,6 +629,12 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-syntax" version = "0.6.28" @@ -645,9 +712,11 @@ name = "satrs-example" version = "0.1.0" dependencies = [ "crossbeam-channel", + "csv", "delegate 0.8.0", "satrs-core", "satrs-macros", + "satrs-mib", "spacepackets", "zerocopy", ] @@ -659,10 +728,22 @@ dependencies = [ "proc-macro2", "quote", "satrs-core", + "satrs-mib", "syn", "trybuild", ] +[[package]] +name = "satrs-mib" +version = "0.1.0" +dependencies = [ + "csv", + "satrs-core", + "satrs-macros", + "serde", + "serde-hex", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -705,6 +786,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-hex" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca37e3e4d1b39afd7ff11ee4e947efae85adfddf4841787bfa47c470e96dc26d" +dependencies = [ + "array-init", + "serde", + "smallvec 0.6.14", +] + [[package]] name = "serde_derive" version = "1.0.147" @@ -722,11 +814,20 @@ version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" dependencies = [ - "itoa", + "itoa 1.0.4", "ryu", "serde", ] +[[package]] +name = "smallvec" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" +dependencies = [ + "maybe-uninit", +] + [[package]] name = "smallvec" version = "1.10.0" diff --git a/Cargo.toml b/Cargo.toml index 54193d5..9cecf21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = [ "satrs-core", "satrs-macros", + "satrs-mib", "satrs-example", "spacepackets", ] diff --git a/satrs-core/Cargo.toml b/satrs-core/Cargo.toml index e57e4ce..9969718 100644 --- a/satrs-core/Cargo.toml +++ b/satrs-core/Cargo.toml @@ -29,6 +29,10 @@ optional = true version= "0.5" default-features = false +[dependencies.serde] +version = "1.0" +default-features = false + [dependencies.spacepackets] path = "../spacepackets" @@ -42,8 +46,8 @@ version = "1.0" [features] default = ["std"] -std = ["downcast-rs/std", "alloc", "bus", "postcard/use-std", "crossbeam-channel/std"] -alloc = [] +std = ["downcast-rs/std", "alloc", "bus", "postcard/use-std", "crossbeam-channel/std", "serde/std"] +alloc = ["serde/alloc"] heapless = [] doc-images = [] diff --git a/satrs-core/src/lib.rs b/satrs-core/src/lib.rs index 700ebff..5cb9a95 100644 --- a/satrs-core/src/lib.rs +++ b/satrs-core/src/lib.rs @@ -29,6 +29,6 @@ pub mod params; #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub mod pool; pub mod pus; -pub mod resultcode; +pub mod res_code; pub mod seq_count; pub mod tmtc; diff --git a/satrs-core/src/resultcode.rs b/satrs-core/src/res_code.rs similarity index 69% rename from satrs-core/src/resultcode.rs rename to satrs-core/src/res_code.rs index 5bfc598..26db165 100644 --- a/satrs-core/src/resultcode.rs +++ b/satrs-core/src/res_code.rs @@ -1,7 +1,8 @@ +use serde::{Deserialize, Serialize}; +use spacepackets::ecss::{EcssEnumU16, EcssEnumeration}; use spacepackets::{ByteConversionError, SizeMissmatch}; -use spacepackets::ecss::{EcssEnumeration, EcssEnumU16}; -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ResultU16 { group_id: u8, unique_id: u8, @@ -40,7 +41,7 @@ impl EcssEnumeration for ResultU16 { if buf.len() < 2 { return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch { found: buf.len(), - expected: 2 + expected: 2, })); } buf[0] = self.group_id; @@ -48,20 +49,3 @@ impl EcssEnumeration for ResultU16 { Ok(()) } } - -#[derive(Debug)] -pub struct ResultU16Ext { - pub name: &'static str, - pub result: &'static ResultU16, - pub info: &'static str, -} - -impl ResultU16Ext { - pub const fn const_new( - name: &'static str, - result: &'static ResultU16, - info: &'static str, - ) -> Self { - Self { name, result, info } - } -} diff --git a/satrs-example/Cargo.toml b/satrs-example/Cargo.toml index 94bf27f..4ba1cb2 100644 --- a/satrs-example/Cargo.toml +++ b/satrs-example/Cargo.toml @@ -9,6 +9,7 @@ default-run = "satrs-example" crossbeam-channel = "0.5" delegate = "0.8" zerocopy = "0.6" +csv = "1" [dependencies.spacepackets] path = "../spacepackets" @@ -18,3 +19,6 @@ path = "../satrs-macros" [dependencies.satrs-core] path = "../satrs-core" + +[dependencies.satrs-mib] +path = "../satrs-mib" diff --git a/satrs-example/src/bin/simpleclient.rs b/satrs-example/src/bin/simpleclient.rs index f29a7e9..e503b98 100644 --- a/satrs-example/src/bin/simpleclient.rs +++ b/satrs-example/src/bin/simpleclient.rs @@ -22,8 +22,8 @@ fn main() { .write_to_bytes(&mut buf) .expect("Creating PUS TC failed"); client - .send_to(&buf[0..size], &addr) - .expect(&*format!("Sending to {:?} failed", addr)); + .send_to(&buf[0..size], addr) + .unwrap_or_else(|_| panic!("Sending to {:?} failed", addr)); client .set_read_timeout(Some(Duration::from_secs(2))) .expect("Setting read timeout failed"); diff --git a/satrs-example/src/lib.rs b/satrs-example/src/lib.rs index b1bb894..7ba2416 100644 --- a/satrs-example/src/lib.rs +++ b/satrs-example/src/lib.rs @@ -1,4 +1,27 @@ use std::net::Ipv4Addr; +use satrs_core::res_code::ResultU16; +use satrs_macros::resultcode; +use satrs_mib::res_code::ResultU16Info; + +#[derive(Debug)] +pub enum GroupId { + Tmtc = 0, +} + pub const OBSW_SERVER_ADDR: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1); pub const SERVER_PORT: u16 = 7301; + +#[resultcode] +pub const INVALID_PUS_SERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 0); +#[resultcode] +pub const INVALID_PUS_SUBSERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 1); + +#[resultcode(info = "Not enough data inside the TC application data field")] +pub const NOT_ENOUGH_APP_DATA: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 2); + +pub const TMTC_RESULTS: &[ResultU16Info] = &[ + INVALID_PUS_SERVICE_EXT, + INVALID_PUS_SUBSERVICE_EXT, + NOT_ENOUGH_APP_DATA_EXT, +]; diff --git a/satrs-example/src/main.rs b/satrs-example/src/main.rs index 159fe67..efb6628 100644 --- a/satrs-example/src/main.rs +++ b/satrs-example/src/main.rs @@ -1,7 +1,6 @@ mod ccsds; mod pus; mod tmtc; -mod results; use crate::tmtc::{core_tmtc_task, CoreTmtcArgs, TmStore, PUS_APID}; use satrs_core::event_man::{ diff --git a/satrs-example/src/pus.rs b/satrs-example/src/pus.rs index a2950aa..41c7879 100644 --- a/satrs-example/src/pus.rs +++ b/satrs-example/src/pus.rs @@ -1,5 +1,4 @@ use crate::tmtc::TmStore; -use crate::results::{INVALID_PUS_SERVICE, INVALID_PUS_SUBSERVICE, NOT_ENOUGH_APP_DATA}; use satrs_core::events::EventU32; use satrs_core::pool::StoreAddr; use satrs_core::pus::event::Subservices; @@ -7,14 +6,15 @@ use satrs_core::pus::event_man::{EventRequest, EventRequestWithToken}; use satrs_core::pus::verification::{ FailParams, StdVerifReporterWithSender, TcStateAccepted, VerificationToken, }; +use satrs_core::res_code::ResultU16; use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper; use satrs_core::tmtc::PusServiceProvider; +use satrs_example::{INVALID_PUS_SERVICE, INVALID_PUS_SUBSERVICE, NOT_ENOUGH_APP_DATA}; use spacepackets::ecss::PusPacket; use spacepackets::tc::PusTc; use spacepackets::time::{CdsShortTimeProvider, TimeWriter}; use spacepackets::SpHeader; use std::sync::mpsc; -use satrs_core::resultcode::ResultU16; pub struct PusReceiver { pub tm_helper: PusTmWithCdsShortHelper, @@ -67,7 +67,11 @@ impl PusServiceProvider for PusReceiver { self.handle_event_service(pus_tc, accepted_token); } else { self.update_time_stamp(); - self.verif_reporter.start_failure(accepted_token, FailParams::new(&self.time_stamp, &INVALID_PUS_SERVICE, None)) + self.verif_reporter + .start_failure( + accepted_token, + FailParams::new(&self.time_stamp, &INVALID_PUS_SERVICE, None), + ) .expect("Start failure verification failed") } Ok(()) diff --git a/satrs-example/src/results.rs b/satrs-example/src/results.rs deleted file mode 100644 index e521a84..0000000 --- a/satrs-example/src/results.rs +++ /dev/null @@ -1,15 +0,0 @@ -use satrs_core::resultcode::ResultU16; -use satrs_macros::resultcode; - -#[derive(Debug)] -pub enum GroupId { - Tmtc = 0, -} - -#[resultcode] -pub const INVALID_PUS_SERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 0); -#[resultcode] -pub const INVALID_PUS_SUBSERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 1); - -#[resultcode(info="Not enough data inside the TC application data field")] -pub const NOT_ENOUGH_APP_DATA: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 2); diff --git a/satrs-macros/Cargo.toml b/satrs-macros/Cargo.toml index 9c67bea..9523869 100644 --- a/satrs-macros/Cargo.toml +++ b/satrs-macros/Cargo.toml @@ -21,6 +21,9 @@ path = "../satrs-core" [dev-dependencies] trybuild = { version = "1.0", features = ["diff"] } +[dev-dependencies.satrs-mib] +path = "../satrs-mib" + [dependencies.syn] version = "1.0" features = ["extra-traits"] diff --git a/satrs-macros/src/lib.rs b/satrs-macros/src/lib.rs index 4d2598e..2fa36ee 100644 --- a/satrs-macros/src/lib.rs +++ b/satrs-macros/src/lib.rs @@ -90,11 +90,13 @@ impl ResultExtGenerator { } else { String::from("") }; + // TODO: Group string let gen_struct = quote! { - const #gen_struct_name: satrs_core::resultcode::ResultU16Ext = - satrs_core::resultcode::ResultU16Ext::const_new( + const #gen_struct_name: satrs_mib::res_code::ResultU16Info = + satrs_mib::res_code::ResultU16Info::const_new( #name_as_str, &#result_code_name, + "", #info_str ); }; diff --git a/satrs-macros/src/main.rs b/satrs-macros/src/main.rs deleted file mode 100644 index ed36991..0000000 --- a/satrs-macros/src/main.rs +++ /dev/null @@ -1,7 +0,0 @@ -use satrs_core::resultcode::ResultU16; -use satrs_macros::*; - -#[resultcode(info = "This is a test result where the first parameter is foo")] -const _TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); - -fn main() {} diff --git a/satrs-macros/tests/basic.rs b/satrs-macros/tests/basic.rs index bcb16b5..3a4e430 100644 --- a/satrs-macros/tests/basic.rs +++ b/satrs-macros/tests/basic.rs @@ -1,8 +1,8 @@ //! Basic check which just verifies that everything compiles -use satrs_core::resultcode::ResultU16; +use satrs_core::res_code::ResultU16; use satrs_macros::*; #[resultcode(info = "This is a test result where the first parameter is foo")] -const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); +const _TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); fn main() {} diff --git a/satrs-macros/tests/verify_gen_struct.rs b/satrs-macros/tests/verify_gen_struct.rs index 3d308a2..39ef428 100644 --- a/satrs-macros/tests/verify_gen_struct.rs +++ b/satrs-macros/tests/verify_gen_struct.rs @@ -1,10 +1,11 @@ -use satrs_core::resultcode::{ResultU16, ResultU16Ext}; +use satrs_core::res_code::ResultU16; use satrs_macros::*; +use satrs_mib::res_code::ResultU16Info; #[resultcode(info = "This is a test result where the first parameter is foo")] const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); // Create named reference of auto-generated struct, which can be used by IDEs etc. -const TEST_RESULT_EXT_REF: &ResultU16Ext = &TEST_RESULT_EXT; +const TEST_RESULT_EXT_REF: &ResultU16Info = &TEST_RESULT_EXT; fn main() { assert_eq!(TEST_RESULT_EXT.name, "TEST_RESULT"); diff --git a/satrs-mib/Cargo.toml b/satrs-mib/Cargo.toml new file mode 100644 index 0000000..b196f1c --- /dev/null +++ b/satrs-mib/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "satrs-mib" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde-hex = "0.1.0" +csv = "1" + +[dependencies.satrs-core] +path = "../satrs-core" + +[dependencies.satrs-macros] +path = "../satrs-macros" + +[dependencies.serde] +version = "1.0" +default-features = false diff --git a/satrs-mib/src/lib.rs b/satrs-mib/src/lib.rs new file mode 100644 index 0000000..1563025 --- /dev/null +++ b/satrs-mib/src/lib.rs @@ -0,0 +1 @@ +pub mod res_code; diff --git a/satrs-mib/src/res_code.rs b/satrs-mib/src/res_code.rs new file mode 100644 index 0000000..7c0bde1 --- /dev/null +++ b/satrs-mib/src/res_code.rs @@ -0,0 +1,151 @@ +use std::io; +use std::path::Path; + +pub use satrs_core::res_code::ResultU16; +use serde::{Deserialize, Serialize}; +use serde_hex::{SerHex, StrictCapPfx}; + +#[derive(Debug, Copy, Clone, Serialize)] +pub struct ResultU16Info { + pub name: &'static str, + pub result: &'static ResultU16, + pub group_str: &'static str, + pub info: &'static str, +} + +impl ResultU16Info { + pub const fn const_new( + name: &'static str, + result: &'static ResultU16, + group_str: &'static str, + info: &'static str, + ) -> Self { + Self { + name, + result, + group_str, + info, + } + } +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct ResultU16InfoSerializable { + #[serde(with = "SerHex::")] + raw: u16, + #[serde(with = "SerHex::")] + group_id: u8, + #[serde(with = "SerHex::")] + unique_id: u8, + name: &'static str, + group_str: &'static str, + info: &'static str, +} + +impl From for ResultU16InfoSerializable { + fn from(v: ResultU16Info) -> Self { + Self { + raw: v.result.raw(), + group_id: v.result.group_id(), + unique_id: v.result.unique_id(), + name: v.name, + group_str: v.group_str, + info: v.info, + } + } +} + +pub fn print_resultcodes_as_csv(codes: &[ResultU16Info]) -> Result<(), csv::Error> { + let mut wtr = csv::Writer::from_writer(io::stdout()); + for result in codes { + wtr.serialize(ResultU16InfoSerializable::from(*result))?; + } + wtr.flush()?; + Ok(()) +} + +pub fn write_resultcodes_to_csv( + results: &[ResultU16Info], + path: impl AsRef, +) -> Result<(), csv::Error> { + let mut wtr = csv::Writer::from_path(path)?; + for result_code in results { + wtr.serialize(ResultU16InfoSerializable::from(*result_code))?; + } + wtr.flush()?; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::fs::File; + use std::io::{BufRead, BufReader}; + // Special solution for this crate because the code generated by a macro will use + // satrs_mib::res_code::* + use crate as satrs_mib; + use satrs_core::res_code::ResultU16; + use satrs_macros::resultcode; + + #[derive(Debug)] + #[allow(dead_code)] + pub enum GroupId { + Tmtc = 0, + } + + #[resultcode] + pub const INVALID_PUS_SERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 0); + #[resultcode] + pub const INVALID_PUS_SUBSERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 1); + + #[resultcode(info = "Not enough data inside the TC application data field")] + pub const NOT_ENOUGH_APP_DATA: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 2); + + pub const TMTC_RESULTS: &[ResultU16Info] = &[ + INVALID_PUS_SERVICE_EXT, + INVALID_PUS_SUBSERVICE_EXT, + NOT_ENOUGH_APP_DATA_EXT, + ]; + + const CSV_NAME: &'static str = "dummy.csv"; + + #[test] + fn test_printout() { + print_resultcodes_as_csv(TMTC_RESULTS).expect("Priting result codes failed"); + } + + #[test] + fn test_csv_export() { + let csvpath = Path::new(CSV_NAME); + write_resultcodes_to_csv(TMTC_RESULTS, csvpath).expect("CSV export failed"); + assert!(csvpath.exists()); + let file = File::open(csvpath).expect("Opening CSV file failed"); + let buf_reader = BufReader::new(file); + for (idx, line) in buf_reader.lines().enumerate() { + match idx { + 0 => { + assert!(line.is_ok()); + let line = line.unwrap(); + assert_eq!(line, "raw,group_id,unique_id,name,group_str,info"); + } + 1 => { + assert!(line.is_ok()); + let line = line.unwrap(); + assert_eq!(line, "0x0000,0x00,0x00,INVALID_PUS_SERVICE,,"); + } + 2 => { + assert!(line.is_ok()); + let line = line.unwrap(); + assert_eq!(line, "0x0001,0x00,0x01,INVALID_PUS_SUBSERVICE,,"); + } + 3 => { + assert!(line.is_ok()); + let line = line.unwrap(); + assert_eq!(line, "0x0002,0x00,0x02,NOT_ENOUGH_APP_DATA,,Not enough data inside the TC application data field"); + } + _ => (), + } + } + std::fs::remove_file(Path::new("dummy.csv")).expect("Removing dummy csv failed"); + } +} -- 2.43.0 From 489686c8ce2d9bc13e7860800a170194bd8868f2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 22:13:15 +0100 Subject: [PATCH 06/11] trying to internalize mib codegen --- Cargo.toml | 1 - satrs-mib/Cargo.toml | 3 +++ {satrs-macros => satrs-mib/codegen}/Cargo.toml | 6 +++--- {satrs-macros => satrs-mib/codegen}/src/lib.rs | 0 {satrs-macros => satrs-mib/codegen}/tests/basic.rs | 0 {satrs-macros => satrs-mib/codegen}/tests/tests.rs | 0 .../codegen}/tests/verify_gen_struct.rs | 0 satrs-mib/src/lib.rs | 1 + 8 files changed, 7 insertions(+), 4 deletions(-) rename {satrs-macros => satrs-mib/codegen}/Cargo.toml (87%) rename {satrs-macros => satrs-mib/codegen}/src/lib.rs (100%) rename {satrs-macros => satrs-mib/codegen}/tests/basic.rs (100%) rename {satrs-macros => satrs-mib/codegen}/tests/tests.rs (100%) rename {satrs-macros => satrs-mib/codegen}/tests/verify_gen_struct.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 9cecf21..aa7ec58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ members = [ "satrs-core", - "satrs-macros", "satrs-mib", "satrs-example", "spacepackets", diff --git a/satrs-mib/Cargo.toml b/satrs-mib/Cargo.toml index b196f1c..975aed8 100644 --- a/satrs-mib/Cargo.toml +++ b/satrs-mib/Cargo.toml @@ -15,6 +15,9 @@ path = "../satrs-core" [dependencies.satrs-macros] path = "../satrs-macros" +[dependencies.satrs-mib-codegen] +path = "codegen" + [dependencies.serde] version = "1.0" default-features = false diff --git a/satrs-macros/Cargo.toml b/satrs-mib/codegen/Cargo.toml similarity index 87% rename from satrs-macros/Cargo.toml rename to satrs-mib/codegen/Cargo.toml index 9523869..7a1d882 100644 --- a/satrs-macros/Cargo.toml +++ b/satrs-mib/codegen/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "satrs-macros" +name = "satrs-mib-codegen" version = "0.1.0" edition = "2021" @@ -16,13 +16,13 @@ quote = "1.0" proc-macro2 = "1.0" [dependencies.satrs-core] -path = "../satrs-core" +path = "../../satrs-core" [dev-dependencies] trybuild = { version = "1.0", features = ["diff"] } [dev-dependencies.satrs-mib] -path = "../satrs-mib" +path = ".." [dependencies.syn] version = "1.0" diff --git a/satrs-macros/src/lib.rs b/satrs-mib/codegen/src/lib.rs similarity index 100% rename from satrs-macros/src/lib.rs rename to satrs-mib/codegen/src/lib.rs diff --git a/satrs-macros/tests/basic.rs b/satrs-mib/codegen/tests/basic.rs similarity index 100% rename from satrs-macros/tests/basic.rs rename to satrs-mib/codegen/tests/basic.rs diff --git a/satrs-macros/tests/tests.rs b/satrs-mib/codegen/tests/tests.rs similarity index 100% rename from satrs-macros/tests/tests.rs rename to satrs-mib/codegen/tests/tests.rs diff --git a/satrs-macros/tests/verify_gen_struct.rs b/satrs-mib/codegen/tests/verify_gen_struct.rs similarity index 100% rename from satrs-macros/tests/verify_gen_struct.rs rename to satrs-mib/codegen/tests/verify_gen_struct.rs diff --git a/satrs-mib/src/lib.rs b/satrs-mib/src/lib.rs index 1563025..cd42767 100644 --- a/satrs-mib/src/lib.rs +++ b/satrs-mib/src/lib.rs @@ -1 +1,2 @@ +pub use satrs_mib_codegen::*; pub mod res_code; -- 2.43.0 From fd59f25fea4b215f8aa7e5a78b89e07f9ebef9eb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 22:30:38 +0100 Subject: [PATCH 07/11] this structure is a lot better --- Cargo.lock | 27 ++++++++++---------- satrs-example/Cargo.toml | 3 --- satrs-example/src/lib.rs | 5 ++-- satrs-mib/Cargo.toml | 12 ++++++--- satrs-mib/codegen/tests/basic.rs | 2 +- satrs-mib/codegen/tests/verify_gen_struct.rs | 2 +- satrs-mib/src/lib.rs | 6 +++++ satrs-mib/src/res_code.rs | 18 +++++++++---- 8 files changed, 44 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 273cc77..f313f4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,35 +715,34 @@ dependencies = [ "csv", "delegate 0.8.0", "satrs-core", - "satrs-macros", "satrs-mib", "spacepackets", "zerocopy", ] -[[package]] -name = "satrs-macros" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "satrs-core", - "satrs-mib", - "syn", - "trybuild", -] - [[package]] name = "satrs-mib" version = "0.1.0" dependencies = [ "csv", "satrs-core", - "satrs-macros", + "satrs-mib-codegen", "serde", "serde-hex", ] +[[package]] +name = "satrs-mib-codegen" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "satrs-core", + "satrs-mib", + "syn", + "trybuild", +] + [[package]] name = "scopeguard" version = "1.1.0" diff --git a/satrs-example/Cargo.toml b/satrs-example/Cargo.toml index 4ba1cb2..c6626ee 100644 --- a/satrs-example/Cargo.toml +++ b/satrs-example/Cargo.toml @@ -14,9 +14,6 @@ csv = "1" [dependencies.spacepackets] path = "../spacepackets" -[dependencies.satrs-macros] -path = "../satrs-macros" - [dependencies.satrs-core] path = "../satrs-core" diff --git a/satrs-example/src/lib.rs b/satrs-example/src/lib.rs index 7ba2416..5be45a9 100644 --- a/satrs-example/src/lib.rs +++ b/satrs-example/src/lib.rs @@ -1,8 +1,7 @@ use std::net::Ipv4Addr; -use satrs_core::res_code::ResultU16; -use satrs_macros::resultcode; -use satrs_mib::res_code::ResultU16Info; +use satrs_mib::resultcode; +use satrs_mib::res_code::{ResultU16, ResultU16Info}; #[derive(Debug)] pub enum GroupId { diff --git a/satrs-mib/Cargo.toml b/satrs-mib/Cargo.toml index 975aed8..8be0562 100644 --- a/satrs-mib/Cargo.toml +++ b/satrs-mib/Cargo.toml @@ -7,17 +7,21 @@ edition = "2021" [dependencies] serde-hex = "0.1.0" -csv = "1" + +[dependencies.csv] +version = "1" +optional = true [dependencies.satrs-core] path = "../satrs-core" -[dependencies.satrs-macros] -path = "../satrs-macros" - [dependencies.satrs-mib-codegen] path = "codegen" [dependencies.serde] version = "1.0" default-features = false + +[features] +default = ["std"] +std = ["csv", "serde/std"] diff --git a/satrs-mib/codegen/tests/basic.rs b/satrs-mib/codegen/tests/basic.rs index 3a4e430..2030920 100644 --- a/satrs-mib/codegen/tests/basic.rs +++ b/satrs-mib/codegen/tests/basic.rs @@ -1,6 +1,6 @@ //! Basic check which just verifies that everything compiles use satrs_core::res_code::ResultU16; -use satrs_macros::*; +use satrs_mib::resultcode; #[resultcode(info = "This is a test result where the first parameter is foo")] const _TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); diff --git a/satrs-mib/codegen/tests/verify_gen_struct.rs b/satrs-mib/codegen/tests/verify_gen_struct.rs index 39ef428..675f6d6 100644 --- a/satrs-mib/codegen/tests/verify_gen_struct.rs +++ b/satrs-mib/codegen/tests/verify_gen_struct.rs @@ -1,5 +1,5 @@ use satrs_core::res_code::ResultU16; -use satrs_macros::*; +use satrs_mib::resultcode; use satrs_mib::res_code::ResultU16Info; #[resultcode(info = "This is a test result where the first parameter is foo")] diff --git a/satrs-mib/src/lib.rs b/satrs-mib/src/lib.rs index cd42767..d2ba843 100644 --- a/satrs-mib/src/lib.rs +++ b/satrs-mib/src/lib.rs @@ -1,2 +1,8 @@ +#![no_std] +#[cfg(feature = "alloc")] +extern crate alloc; +#[cfg(any(feature = "std", test))] +extern crate std; + pub use satrs_mib_codegen::*; pub mod res_code; diff --git a/satrs-mib/src/res_code.rs b/satrs-mib/src/res_code.rs index 7c0bde1..8de5d2f 100644 --- a/satrs-mib/src/res_code.rs +++ b/satrs-mib/src/res_code.rs @@ -1,10 +1,10 @@ -use std::io; -use std::path::Path; +#[cfg(feature = "std")] +pub use stdmod::*; pub use satrs_core::res_code::ResultU16; + use serde::{Deserialize, Serialize}; use serde_hex::{SerHex, StrictCapPfx}; - #[derive(Debug, Copy, Clone, Serialize)] pub struct ResultU16Info { pub name: &'static str, @@ -55,7 +55,13 @@ impl From for ResultU16InfoSerializable { } } -pub fn print_resultcodes_as_csv(codes: &[ResultU16Info]) -> Result<(), csv::Error> { +#[cfg(feature = "std")] +pub mod stdmod { + use std::path::Path; + use std::io; + use super::*; + + pub fn print_resultcodes_as_csv(codes: &[ResultU16Info]) -> Result<(), csv::Error> { let mut wtr = csv::Writer::from_writer(io::stdout()); for result in codes { wtr.serialize(ResultU16InfoSerializable::from(*result))?; @@ -76,16 +82,18 @@ pub fn write_resultcodes_to_csv( Ok(()) } +} #[cfg(test)] mod tests { use super::*; use std::fs::File; + use std::path::Path; use std::io::{BufRead, BufReader}; // Special solution for this crate because the code generated by a macro will use // satrs_mib::res_code::* use crate as satrs_mib; use satrs_core::res_code::ResultU16; - use satrs_macros::resultcode; + use satrs_mib::resultcode; #[derive(Debug)] #[allow(dead_code)] -- 2.43.0 From 6a488f77dbb4f8efc970657494aa17190fb1262a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 22:32:10 +0100 Subject: [PATCH 08/11] run cargo fmt --- satrs-example/src/lib.rs | 2 +- satrs-mib/codegen/tests/verify_gen_struct.rs | 2 +- satrs-mib/src/res_code.rs | 42 ++++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/satrs-example/src/lib.rs b/satrs-example/src/lib.rs index 5be45a9..34f6d0d 100644 --- a/satrs-example/src/lib.rs +++ b/satrs-example/src/lib.rs @@ -1,7 +1,7 @@ use std::net::Ipv4Addr; -use satrs_mib::resultcode; use satrs_mib::res_code::{ResultU16, ResultU16Info}; +use satrs_mib::resultcode; #[derive(Debug)] pub enum GroupId { diff --git a/satrs-mib/codegen/tests/verify_gen_struct.rs b/satrs-mib/codegen/tests/verify_gen_struct.rs index 675f6d6..ccd40e8 100644 --- a/satrs-mib/codegen/tests/verify_gen_struct.rs +++ b/satrs-mib/codegen/tests/verify_gen_struct.rs @@ -1,6 +1,6 @@ use satrs_core::res_code::ResultU16; -use satrs_mib::resultcode; use satrs_mib::res_code::ResultU16Info; +use satrs_mib::resultcode; #[resultcode(info = "This is a test result where the first parameter is foo")] const TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1); diff --git a/satrs-mib/src/res_code.rs b/satrs-mib/src/res_code.rs index 8de5d2f..dabf939 100644 --- a/satrs-mib/src/res_code.rs +++ b/satrs-mib/src/res_code.rs @@ -57,38 +57,38 @@ impl From for ResultU16InfoSerializable { #[cfg(feature = "std")] pub mod stdmod { - use std::path::Path; - use std::io; use super::*; + use std::io; + use std::path::Path; pub fn print_resultcodes_as_csv(codes: &[ResultU16Info]) -> Result<(), csv::Error> { - let mut wtr = csv::Writer::from_writer(io::stdout()); - for result in codes { - wtr.serialize(ResultU16InfoSerializable::from(*result))?; + let mut wtr = csv::Writer::from_writer(io::stdout()); + for result in codes { + wtr.serialize(ResultU16InfoSerializable::from(*result))?; + } + wtr.flush()?; + Ok(()) + } + + pub fn write_resultcodes_to_csv( + results: &[ResultU16Info], + path: impl AsRef, + ) -> Result<(), csv::Error> { + let mut wtr = csv::Writer::from_path(path)?; + for result_code in results { + wtr.serialize(ResultU16InfoSerializable::from(*result_code))?; + } + wtr.flush()?; + Ok(()) } - wtr.flush()?; - Ok(()) } -pub fn write_resultcodes_to_csv( - results: &[ResultU16Info], - path: impl AsRef, -) -> Result<(), csv::Error> { - let mut wtr = csv::Writer::from_path(path)?; - for result_code in results { - wtr.serialize(ResultU16InfoSerializable::from(*result_code))?; - } - wtr.flush()?; - Ok(()) -} - -} #[cfg(test)] mod tests { use super::*; use std::fs::File; - use std::path::Path; use std::io::{BufRead, BufReader}; + use std::path::Path; // Special solution for this crate because the code generated by a macro will use // satrs_mib::res_code::* use crate as satrs_mib; -- 2.43.0 From b846ba30144633ae1275e8fab9eeabb6a9d87642 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 27 Nov 2022 22:44:40 +0100 Subject: [PATCH 09/11] make csv writer more configurable --- satrs-mib/src/res_code.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/satrs-mib/src/res_code.rs b/satrs-mib/src/res_code.rs index dabf939..9635ec0 100644 --- a/satrs-mib/src/res_code.rs +++ b/satrs-mib/src/res_code.rs @@ -57,12 +57,12 @@ impl From for ResultU16InfoSerializable { #[cfg(feature = "std")] pub mod stdmod { + use std::fs::File; use super::*; use std::io; - use std::path::Path; - pub fn print_resultcodes_as_csv(codes: &[ResultU16Info]) -> Result<(), csv::Error> { - let mut wtr = csv::Writer::from_writer(io::stdout()); + pub fn print_resultcodes_as_csv(writer_builder: csv::WriterBuilder, codes: &[ResultU16Info]) -> Result<(), csv::Error> { + let mut wtr = writer_builder.from_writer(io::stdout()); for result in codes { wtr.serialize(ResultU16InfoSerializable::from(*result))?; } @@ -71,10 +71,11 @@ pub mod stdmod { } pub fn write_resultcodes_to_csv( + writer_builder: csv::WriterBuilder, results: &[ResultU16Info], - path: impl AsRef, + file: File, ) -> Result<(), csv::Error> { - let mut wtr = csv::Writer::from_path(path)?; + let mut wtr = writer_builder.from_writer(file); for result_code in results { wtr.serialize(ResultU16InfoSerializable::from(*result_code))?; } @@ -119,13 +120,18 @@ mod tests { #[test] fn test_printout() { - print_resultcodes_as_csv(TMTC_RESULTS).expect("Priting result codes failed"); + let mut wtrb = csv::WriterBuilder::new(); + wtrb.delimiter(';' as u8); + print_resultcodes_as_csv(wtrb, TMTC_RESULTS).expect("Priting result codes failed"); } #[test] fn test_csv_export() { let csvpath = Path::new(CSV_NAME); - write_resultcodes_to_csv(TMTC_RESULTS, csvpath).expect("CSV export failed"); + let mut wtrb = csv::WriterBuilder::new(); + let file = File::create(csvpath).expect("Creating CSV file failed"); + wtrb.delimiter(';' as u8); + write_resultcodes_to_csv(wtrb, TMTC_RESULTS, file).expect("CSV export failed"); assert!(csvpath.exists()); let file = File::open(csvpath).expect("Opening CSV file failed"); let buf_reader = BufReader::new(file); @@ -134,22 +140,22 @@ mod tests { 0 => { assert!(line.is_ok()); let line = line.unwrap(); - assert_eq!(line, "raw,group_id,unique_id,name,group_str,info"); + assert_eq!(line, "raw;group_id;unique_id;name;group_str;info"); } 1 => { assert!(line.is_ok()); let line = line.unwrap(); - assert_eq!(line, "0x0000,0x00,0x00,INVALID_PUS_SERVICE,,"); + assert_eq!(line, "0x0000;0x00;0x00;INVALID_PUS_SERVICE;;"); } 2 => { assert!(line.is_ok()); let line = line.unwrap(); - assert_eq!(line, "0x0001,0x00,0x01,INVALID_PUS_SUBSERVICE,,"); + assert_eq!(line, "0x0001;0x00;0x01;INVALID_PUS_SUBSERVICE;;"); } 3 => { assert!(line.is_ok()); let line = line.unwrap(); - assert_eq!(line, "0x0002,0x00,0x02,NOT_ENOUGH_APP_DATA,,Not enough data inside the TC application data field"); + assert_eq!(line, "0x0002;0x00;0x02;NOT_ENOUGH_APP_DATA;;Not enough data inside the TC application data field"); } _ => (), } -- 2.43.0 From f80fe82b47ee3b8d93ee1b194536b6b7c47debd6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 10:02:57 +0100 Subject: [PATCH 10/11] bump some deps --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f313f4b..af6ceed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -778,9 +778,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] @@ -798,9 +798,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -863,9 +863,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "syn" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" dependencies = [ "proc-macro2", "quote", @@ -892,9 +892,9 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea496675d71016e9bc76aa42d87f16aefd95447cc5818e671e12b2d7e269075d" +checksum = "db29f438342820400f2d9acfec0d363e987a38b2950bdb50a7069ed17b2148ee" dependencies = [ "dissimilar", "glob", -- 2.43.0 From f95b10832a2bea638c99c3f1a65c07522ae0fb80 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Nov 2022 01:07:17 +0100 Subject: [PATCH 11/11] bump spacepackets and lock file --- Cargo.lock | 213 +++++---------------------------------------------- spacepackets | 2 +- 2 files changed, 21 insertions(+), 194 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f313f4b..21e48e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,15 +13,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -42,9 +33,9 @@ dependencies = [ [[package]] name = "atomic-polyfill" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c041a8d9751a520ee19656232a18971f18946a7900f1520ee4400002244dd89" +checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" dependencies = [ "critical-section", ] @@ -55,39 +46,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bare-metal" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" -dependencies = [ - "rustc_version 0.2.3", -] - -[[package]] -name = "bare-metal" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" - [[package]] name = "base64" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "bit_field" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" - -[[package]] -name = "bitfield" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" - [[package]] name = "bitflags" version = "1.3.2" @@ -175,18 +139,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" -[[package]] -name = "cortex-m" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70858629a458fdfd39f9675c4dc309411f2a3f83bede76988d81bf1a0ecee9e0" -dependencies = [ - "bare-metal 0.2.5", - "bitfield", - "embedded-hal", - "volatile-register", -] - [[package]] name = "crc" version = "3.0.0" @@ -204,15 +156,9 @@ checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff" [[package]] name = "critical-section" -version = "0.2.7" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95da181745b56d4bd339530ec393508910c909c784e8962d15d722bacf0bcbcd" -dependencies = [ - "bare-metal 1.0.0", - "cfg-if", - "cortex-m", - "riscv", -] +checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" [[package]] name = "crossbeam-channel" @@ -299,17 +245,6 @@ dependencies = [ "syn", ] -[[package]] -name = "delegate" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d70a2d4995466955a415223acf3c9c934b9ff2339631cdf4ffc893da4bacd717" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "delegate" version = "0.8.0" @@ -351,16 +286,6 @@ dependencies = [ "syn", ] -[[package]] -name = "embedded-hal" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" -dependencies = [ - "nb 0.1.3", - "void", -] - [[package]] name = "glob" version = "0.3.0" @@ -393,7 +318,7 @@ checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" dependencies = [ "atomic-polyfill", "hash32", - "rustc_version 0.4.0", + "rustc_version", "serde", "spin", "stable_deref_trait", @@ -505,21 +430,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "nb" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" -dependencies = [ - "nb 1.0.0", -] - -[[package]] -name = "nb" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" - [[package]] name = "nodrop" version = "0.1.14" @@ -563,9 +473,9 @@ checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" dependencies = [ "cfg-if", "libc", @@ -618,66 +528,19 @@ dependencies = [ "bitflags", ] -[[package]] -name = "regex" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - [[package]] name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -[[package]] -name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "riscv" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6907ccdd7a31012b70faf2af85cd9e5ba97657cc3987c4f13f8e4d2c2a088aba" -dependencies = [ - "bare-metal 1.0.0", - "bit_field", - "riscv-target", -] - -[[package]] -name = "riscv-target" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222" -dependencies = [ - "lazy_static", - "regex", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.14", + "semver", ] [[package]] @@ -692,7 +555,7 @@ version = "0.1.0" dependencies = [ "bus", "crossbeam-channel", - "delegate 0.8.0", + "delegate", "downcast-rs", "dyn-clone", "embed-doc-image", @@ -713,7 +576,7 @@ version = "0.1.0" dependencies = [ "crossbeam-channel", "csv", - "delegate 0.8.0", + "delegate", "satrs-core", "satrs-mib", "spacepackets", @@ -755,32 +618,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] @@ -798,9 +646,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -835,11 +683,11 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "spacepackets" -version = "0.2.0" +version = "0.3.0" dependencies = [ "chrono", "crc", - "delegate 0.7.0", + "delegate", "num-traits", "postcard", "serde", @@ -863,9 +711,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "syn" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" dependencies = [ "proc-macro2", "quote", @@ -892,9 +740,9 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea496675d71016e9bc76aa42d87f16aefd95447cc5818e671e12b2d7e269075d" +checksum = "db29f438342820400f2d9acfec0d363e987a38b2950bdb50a7069ed17b2148ee" dependencies = [ "dissimilar", "glob", @@ -918,33 +766,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" -[[package]] -name = "vcell" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "volatile-register" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" -dependencies = [ - "vcell", -] - [[package]] name = "wasm-bindgen" version = "0.2.83" diff --git a/spacepackets b/spacepackets index 1ec21c1..03d112c 160000 --- a/spacepackets +++ b/spacepackets @@ -1 +1 @@ -Subproject commit 1ec21c1bff69a04b9112c66bec39cb0acb3412be +Subproject commit 03d112cbefa83fd1973cb2bccc88243ee05392bf -- 2.43.0