Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -65,6 +65,7 @@ impl<F: DsFile> App for Ds<F> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&mut self, rfe: &mut rfe::Rfe) {
|
fn run(&mut self, rfe: &mut rfe::Rfe) {
|
||||||
|
self.data.hk.perf.enter(rfe);
|
||||||
self.data.out_data.counter += 1;
|
self.data.out_data.counter += 1;
|
||||||
self.data.out_data.bytes_written_this_cycle = 0;
|
self.data.out_data.bytes_written_this_cycle = 0;
|
||||||
while let Some(msg) = rfe.recv() {
|
while let Some(msg) = rfe.recv() {
|
||||||
@@ -169,6 +170,7 @@ impl<F: DsFile> App for Ds<F> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.data.out_data.bytes_written += self.data.out_data.bytes_written_this_cycle;
|
self.data.out_data.bytes_written += self.data.out_data.bytes_written_this_cycle;
|
||||||
|
self.data.hk.perf.exit(rfe);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hk(&mut self, rfe: &mut rfe::Rfe) {
|
fn hk(&mut self, rfe: &mut rfe::Rfe) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ impl App for Example {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&mut self, rfe: &mut rfe::Rfe) {
|
fn run(&mut self, rfe: &mut rfe::Rfe) {
|
||||||
|
self.data.hk.perf.enter(rfe);
|
||||||
self.data.out_data.counter += 1;
|
self.data.out_data.counter += 1;
|
||||||
info!("example running {:?}", self.data);
|
info!("example running {:?}", self.data);
|
||||||
while let Some(msg) = rfe.recv() {
|
while let Some(msg) = rfe.recv() {
|
||||||
@@ -52,6 +53,7 @@ impl App for Example {
|
|||||||
if self.data.out_data.counter > 10 {
|
if self.data.out_data.counter > 10 {
|
||||||
rfe.send(Msg::ExampleCmd(ExampleCmd::Reset));
|
rfe.send(Msg::ExampleCmd(ExampleCmd::Reset));
|
||||||
};
|
};
|
||||||
|
self.data.hk.perf.exit(rfe);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hk(&mut self, rfe: &mut rfe::Rfe) {
|
fn hk(&mut self, rfe: &mut rfe::Rfe) {
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
path = "src/hs.rs"
|
path = "src/hs.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rp2040"]
|
default = []
|
||||||
std = ["dep:sysinfo"]
|
std = ["dep:sysinfo"]
|
||||||
nix = ["dep:watchdog-device"]
|
nix = ["dep:watchdog-device"]
|
||||||
rp2040 = ["dep:rp2040-hal", "dep:rp2040-pac"]
|
rp2040 = ["dep:rp2040-hal", "dep:rp2040-pac"]
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ impl App for Hs<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&mut self, rfe: &mut Rfe) {
|
fn run(&mut self, rfe: &mut Rfe) {
|
||||||
|
self.data.hk.perf.enter(rfe);
|
||||||
self.data.out_data.counter += 1;
|
self.data.out_data.counter += 1;
|
||||||
while let Some(msg) = rfe.recv() {
|
while let Some(msg) = rfe.recv() {
|
||||||
match msg.msg {
|
match msg.msg {
|
||||||
@@ -121,6 +122,8 @@ impl App for Hs<'_> {
|
|||||||
if self.config.temp_checks {
|
if self.config.temp_checks {
|
||||||
self.data.hk.temps = self.grabber.check_temps();
|
self.data.hk.temps = self.grabber.check_temps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.data.hk.perf.exit(rfe);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hk(&mut self, rfe: &mut Rfe) {
|
fn hk(&mut self, rfe: &mut Rfe) {
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ impl App for To<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&mut self, rfe: &mut Rfe) {
|
fn run(&mut self, rfe: &mut Rfe) {
|
||||||
|
self.data.hk.perf.enter(rfe);
|
||||||
self.data.out_data.counter += 1;
|
self.data.out_data.counter += 1;
|
||||||
let mut msgs = Vec::new();
|
let mut msgs = Vec::new();
|
||||||
while let Some(msg) = rfe.recv() {
|
while let Some(msg) = rfe.recv() {
|
||||||
@@ -135,6 +136,7 @@ impl App for To<'_> {
|
|||||||
rfe.post_message(msg);
|
rfe.post_message(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.data.hk.perf.exit(rfe);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hk(&mut self, rfe: &mut Rfe) {
|
fn hk(&mut self, rfe: &mut Rfe) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rfe.path = "../../rfe"
|
rfe.path = "../../rfe"
|
||||||
|
rfe.features = ["std"]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
simple_logger = "5.0.0"
|
simple_logger = "5.0.0"
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ pub fn to_csv_derive(input: TokenStream) -> TokenStream {
|
|||||||
let field_name = field_ident.to_string();
|
let field_name = field_ident.to_string();
|
||||||
|
|
||||||
quote! { {
|
quote! { {
|
||||||
let mut field_csvs: Vec<String> = (&self.#field_ident as &dyn ToCsv).to_csv();
|
let mut field_csvs: alloc::vec::Vec<String> = (&self.#field_ident as &dyn ToCsv).to_csv();
|
||||||
for entry in &mut field_csvs {
|
for entry in &mut field_csvs {
|
||||||
*entry = format!("{}.{}", #field_name, &entry);
|
*entry = format!("{}.{}", #field_name, &entry);
|
||||||
}
|
}
|
||||||
@@ -103,11 +103,11 @@ pub fn to_csv_derive(input: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
impl ToCsv for #name {
|
impl ToCsv for #name {
|
||||||
fn to_csv(&self) -> Vec<String> {
|
fn to_csv(&self) -> alloc::vec::Vec<String> {
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use alloc::format;
|
use alloc::format;
|
||||||
|
|
||||||
let mut values:Vec<String> = Vec::new();
|
let mut values:alloc::vec::Vec<String> = alloc::vec::Vec::new();
|
||||||
#(#arms)*
|
#(#arms)*
|
||||||
for value in &mut values {
|
for value in &mut values {
|
||||||
*value = format!("{}", value);
|
*value = format!("{}", value);
|
||||||
@@ -130,7 +130,7 @@ pub fn to_csv_derive(input: TokenStream) -> TokenStream {
|
|||||||
}
|
}
|
||||||
Fields::Unnamed(_) => {
|
Fields::Unnamed(_) => {
|
||||||
quote! {Self::#variant_name(l) => {
|
quote! {Self::#variant_name(l) => {
|
||||||
let mut field_csvs: Vec<String> = (l as &dyn ToCsv).to_csv();
|
let mut field_csvs: alloc::vec::Vec<String> = (l as &dyn ToCsv).to_csv();
|
||||||
for entry in &mut field_csvs {
|
for entry in &mut field_csvs {
|
||||||
*entry = format!("{}.{}", #variant_name_s, &entry);
|
*entry = format!("{}.{}", #variant_name_s, &entry);
|
||||||
}
|
}
|
||||||
@@ -145,10 +145,10 @@ pub fn to_csv_derive(input: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
impl ToCsv for #name {
|
impl ToCsv for #name {
|
||||||
fn to_csv(&self) -> Vec<String> {
|
fn to_csv(&self) -> alloc::vec::Vec<String> {
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use alloc::format;
|
use alloc::format;
|
||||||
let mut values: Vec<String> = Vec::new();
|
let mut values: alloc::vec::Vec<String> = alloc::vec::Vec::new();
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
#(#arms)*
|
#(#arms)*
|
||||||
|
|||||||
+1
-3
@@ -11,9 +11,7 @@ mod rfe;
|
|||||||
pub use rfe::*;
|
pub use rfe::*;
|
||||||
|
|
||||||
#[cfg(feature = "to_csv")]
|
#[cfg(feature = "to_csv")]
|
||||||
mod to_csv;
|
pub mod to_csv;
|
||||||
#[cfg(feature = "to_csv")]
|
|
||||||
pub use to_csv::*;
|
|
||||||
|
|
||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|||||||
-222
@@ -1,222 +0,0 @@
|
|||||||
extern crate alloc;
|
|
||||||
|
|
||||||
use alloc::string::String;
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
use bincode::{Decode, Encode};
|
|
||||||
use macros::Kind;
|
|
||||||
|
|
||||||
use crate::time::Timestamp;
|
|
||||||
#[cfg(feature = "to_csv")]
|
|
||||||
use crate::ToCsv;
|
|
||||||
#[cfg(feature = "to_csv")]
|
|
||||||
use macros::ToCsv;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct TargetMsg {
|
|
||||||
// instance is FROM for tlm, is TO for cmds
|
|
||||||
pub instance: Instance,
|
|
||||||
pub msg: MsgKind,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TargetMsg {
|
|
||||||
pub fn new(instance: Instance, msg: MsgKind) -> Self {
|
|
||||||
Self { instance, msg }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub enum Instance {
|
|
||||||
All,
|
|
||||||
Other,
|
|
||||||
Example,
|
|
||||||
Example2,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct ReinitAppCmd {
|
|
||||||
app_name: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Kind, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub enum Msg {
|
|
||||||
None,
|
|
||||||
SubRequest,
|
|
||||||
SubList(SubList),
|
|
||||||
SetTimeCmd(u64),
|
|
||||||
ReinitApp(ReinitAppCmd),
|
|
||||||
ExampleHk(ExampleHk),
|
|
||||||
ExampleOutData(ExampleOutData),
|
|
||||||
ExampleCmd(ExampleCmd),
|
|
||||||
DsHk(DsHk),
|
|
||||||
DsOutData(DsOutData),
|
|
||||||
DsCmd(DsCmd),
|
|
||||||
HsHk(HsHk),
|
|
||||||
HsOutData(HsOutData),
|
|
||||||
HsCmd(HsCmd),
|
|
||||||
ToHk(ToHk),
|
|
||||||
ToOutData(ToOutData),
|
|
||||||
ToCmd(ToCmd),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct MsgPacket {
|
|
||||||
pub instance: Instance,
|
|
||||||
pub msg: Msg,
|
|
||||||
pub timestamp: Timestamp,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MsgPacket {
|
|
||||||
pub fn to_target(&self) -> TargetMsg {
|
|
||||||
TargetMsg::new(self.instance, self.msg.kind())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(instance: Instance, msg: Msg, timestamp: Timestamp) -> Self {
|
|
||||||
Self {
|
|
||||||
instance,
|
|
||||||
msg,
|
|
||||||
timestamp,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn timestamp(&mut self, timestamp: Timestamp) {
|
|
||||||
self.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct SubList {
|
|
||||||
pub subs: Vec<TargetMsg>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct ExampleHk {
|
|
||||||
pub counter: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct ExampleOutData {
|
|
||||||
pub counter: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub enum ExampleCmd {
|
|
||||||
Noop,
|
|
||||||
Reset,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct DsTlmSet {
|
|
||||||
pub items: Vec<TlmSetItem>,
|
|
||||||
pub id: TlmSetId,
|
|
||||||
pub enabled: bool,
|
|
||||||
pub path: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type TlmSetId = u16;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct TlmSetItem {
|
|
||||||
pub target: TargetMsg,
|
|
||||||
pub decimation: u16,
|
|
||||||
pub counter: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
|
|
||||||
pub struct DsHk {
|
|
||||||
pub counter: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct DsOutData {
|
|
||||||
pub counter: u32,
|
|
||||||
pub bytes_written: u32,
|
|
||||||
pub bytes_written_this_cycle: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub enum DsCmd {
|
|
||||||
Noop,
|
|
||||||
Reset,
|
|
||||||
CloseAll,
|
|
||||||
Close(TlmSetId),
|
|
||||||
AddTlmSet(DsTlmSet),
|
|
||||||
RemoveTlmSet(TlmSetId),
|
|
||||||
DisableTlmSet(TlmSetId),
|
|
||||||
EnablTlmSet(TlmSetId),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct HsHk {
|
|
||||||
pub counter: u32,
|
|
||||||
pub cpu_usage: Vec<u8>,
|
|
||||||
pub mem_usage: u8,
|
|
||||||
pub fs_usage: Vec<u8>,
|
|
||||||
pub temps: Vec<i8>,
|
|
||||||
pub cmd_counter: u8,
|
|
||||||
pub cpu_usage_enabled: bool,
|
|
||||||
pub mem_usage_enabled: bool,
|
|
||||||
pub fs_usage_enabled: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct HsOutData {
|
|
||||||
pub counter: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub enum HsCmd {
|
|
||||||
Noop,
|
|
||||||
Reset,
|
|
||||||
WatchdogEnableManual(bool),
|
|
||||||
WatchdogEnableAuto(bool),
|
|
||||||
WatchdogResumeAuto,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct ToTlmSet {
|
|
||||||
pub items: Vec<TlmSetItem>,
|
|
||||||
pub id: TlmSetId,
|
|
||||||
pub enabled: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct ToHk {
|
|
||||||
pub counter: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub struct ToOutData {
|
|
||||||
pub counter: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
|
||||||
pub enum ToCmd {
|
|
||||||
Noop,
|
|
||||||
Reset,
|
|
||||||
AddTlmSet(ToTlmSet),
|
|
||||||
RemoveTlmSet(TlmSetId),
|
|
||||||
DisableTlmSet(TlmSetId),
|
|
||||||
EnablTlmSet(TlmSetId),
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use crate::to_csv::ToCsv;
|
||||||
|
use crate::utils::PerfData;
|
||||||
|
use bincode::{Decode, Encode};
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use macros::ToCsv;
|
||||||
|
extern crate alloc;
|
||||||
|
use alloc::string::String;
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
|
use super::{TlmSetId, TlmSetItem};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct DsTlmSet {
|
||||||
|
pub items: Vec<TlmSetItem>,
|
||||||
|
pub id: TlmSetId,
|
||||||
|
pub enabled: bool,
|
||||||
|
pub path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct DsHk {
|
||||||
|
pub perf: PerfData,
|
||||||
|
pub counter: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct DsOutData {
|
||||||
|
pub counter: u32,
|
||||||
|
pub bytes_written: u32,
|
||||||
|
pub bytes_written_this_cycle: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub enum DsCmd {
|
||||||
|
Noop,
|
||||||
|
Reset,
|
||||||
|
CloseAll,
|
||||||
|
Close(TlmSetId),
|
||||||
|
AddTlmSet(DsTlmSet),
|
||||||
|
RemoveTlmSet(TlmSetId),
|
||||||
|
DisableTlmSet(TlmSetId),
|
||||||
|
EnablTlmSet(TlmSetId),
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
extern crate alloc;
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use crate::to_csv::ToCsv;
|
||||||
|
use crate::utils::PerfData;
|
||||||
|
use bincode::{Decode, Encode};
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use macros::ToCsv;
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct ExampleHk {
|
||||||
|
pub perf: PerfData,
|
||||||
|
pub counter: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct ExampleOutData {
|
||||||
|
pub counter: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub enum ExampleCmd {
|
||||||
|
Noop,
|
||||||
|
Reset,
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use crate::to_csv::ToCsv;
|
||||||
|
use crate::utils::PerfData;
|
||||||
|
use bincode::{Decode, Encode};
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use macros::ToCsv;
|
||||||
|
extern crate alloc;
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct HsHk {
|
||||||
|
pub perf: PerfData,
|
||||||
|
pub counter: u32,
|
||||||
|
pub cpu_usage: Vec<u8>,
|
||||||
|
pub mem_usage: u8,
|
||||||
|
pub fs_usage: Vec<u8>,
|
||||||
|
pub temps: Vec<i8>,
|
||||||
|
pub cmd_counter: u8,
|
||||||
|
pub cpu_usage_enabled: bool,
|
||||||
|
pub mem_usage_enabled: bool,
|
||||||
|
pub fs_usage_enabled: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct HsOutData {
|
||||||
|
pub counter: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub enum HsCmd {
|
||||||
|
Noop,
|
||||||
|
Reset,
|
||||||
|
WatchdogEnableManual(bool),
|
||||||
|
WatchdogEnableAuto(bool),
|
||||||
|
WatchdogResumeAuto,
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::string::String;
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
use bincode::{Decode, Encode};
|
||||||
|
use macros::Kind;
|
||||||
|
|
||||||
|
mod example;
|
||||||
|
pub use example::*;
|
||||||
|
mod hs;
|
||||||
|
pub use hs::*;
|
||||||
|
mod to;
|
||||||
|
pub use to::*;
|
||||||
|
mod ds;
|
||||||
|
pub use ds::*;
|
||||||
|
|
||||||
|
use crate::time::Timestamp;
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use crate::to_csv::ToCsv;
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use macros::ToCsv;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct TargetMsg {
|
||||||
|
// instance is FROM for tlm, is TO for cmds
|
||||||
|
pub instance: Instance,
|
||||||
|
pub msg: MsgKind,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TargetMsg {
|
||||||
|
pub fn new(instance: Instance, msg: MsgKind) -> Self {
|
||||||
|
Self { instance, msg }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub enum Instance {
|
||||||
|
All,
|
||||||
|
Other,
|
||||||
|
Example,
|
||||||
|
Example2,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Kind, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub enum Msg {
|
||||||
|
None,
|
||||||
|
SubRequest,
|
||||||
|
SubList(SubList),
|
||||||
|
SetTimeCmd(u64),
|
||||||
|
ReinitApp(ReinitAppCmd),
|
||||||
|
ExampleHk(ExampleHk),
|
||||||
|
ExampleOutData(ExampleOutData),
|
||||||
|
ExampleCmd(ExampleCmd),
|
||||||
|
DsHk(DsHk),
|
||||||
|
DsOutData(DsOutData),
|
||||||
|
DsCmd(DsCmd),
|
||||||
|
HsHk(HsHk),
|
||||||
|
HsOutData(HsOutData),
|
||||||
|
HsCmd(HsCmd),
|
||||||
|
ToHk(ToHk),
|
||||||
|
ToOutData(ToOutData),
|
||||||
|
ToCmd(ToCmd),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct MsgPacket {
|
||||||
|
pub instance: Instance,
|
||||||
|
pub msg: Msg,
|
||||||
|
pub timestamp: Timestamp,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MsgPacket {
|
||||||
|
pub fn to_target(&self) -> TargetMsg {
|
||||||
|
TargetMsg::new(self.instance, self.msg.kind())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new(instance: Instance, msg: Msg, timestamp: Timestamp) -> Self {
|
||||||
|
Self {
|
||||||
|
instance,
|
||||||
|
msg,
|
||||||
|
timestamp,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn timestamp(&mut self, timestamp: Timestamp) {
|
||||||
|
self.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct SubList {
|
||||||
|
pub subs: Vec<TargetMsg>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct ReinitAppCmd {
|
||||||
|
app_name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type TlmSetId = u16;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct TlmSetItem {
|
||||||
|
pub target: TargetMsg,
|
||||||
|
pub decimation: u16,
|
||||||
|
pub counter: u16,
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use crate::to_csv::ToCsv;
|
||||||
|
use crate::utils::PerfData;
|
||||||
|
use bincode::{Decode, Encode};
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use macros::ToCsv;
|
||||||
|
extern crate alloc;
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
|
use super::{TlmSetId, TlmSetItem};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct ToTlmSet {
|
||||||
|
pub items: Vec<TlmSetItem>,
|
||||||
|
pub id: TlmSetId,
|
||||||
|
pub enabled: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct ToHk {
|
||||||
|
pub perf: PerfData,
|
||||||
|
pub counter: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct ToOutData {
|
||||||
|
pub counter: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub enum ToCmd {
|
||||||
|
Noop,
|
||||||
|
Reset,
|
||||||
|
AddTlmSet(ToTlmSet),
|
||||||
|
RemoveTlmSet(TlmSetId),
|
||||||
|
DisableTlmSet(TlmSetId),
|
||||||
|
EnablTlmSet(TlmSetId),
|
||||||
|
}
|
||||||
+2
-7
@@ -127,15 +127,10 @@ impl<'a> Rfe<'a> {
|
|||||||
self.msgs_recevied.pop_front()
|
self.msgs_recevied.pop_front()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// time in 10ms increments starting from power on
|
/// time starting from power on or program start
|
||||||
pub fn get_met_time(&self) -> u64 {
|
pub fn get_met_time(&self) -> u64 {
|
||||||
self.time.borrow().time_data.sch_counter
|
|
||||||
}
|
|
||||||
|
|
||||||
/// time in 10ms increments based on set time. Shows MET until time is set
|
|
||||||
pub fn get_time(&self) -> u64 {
|
|
||||||
let time = self.time.borrow();
|
let time = self.time.borrow();
|
||||||
time.time_data.sch_counter + time.time_data.time_offset
|
time.time_driver.get_monotonic_time(time.time_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Time in microseconds relative to system epoch
|
/// Time in microseconds relative to system epoch
|
||||||
|
|||||||
+24
-4
@@ -1,22 +1,30 @@
|
|||||||
|
/// Microseconds timestamp
|
||||||
pub type Timestamp = u64;
|
pub type Timestamp = u64;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct TimeData {
|
pub struct TimeData {
|
||||||
pub sch_counter: u64,
|
pub sch_counter: u64,
|
||||||
pub time_offset: u64,
|
pub time_offset: Timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait TimeDriver {
|
pub trait TimeDriver {
|
||||||
/// Time in microseconds relative to system epoch
|
/// Time in microseconds relative to system epoch
|
||||||
fn get_system_time(&self, time_data: TimeData) -> Timestamp;
|
fn get_system_time(&self, time_data: TimeData) -> Timestamp;
|
||||||
|
|
||||||
|
/// Time in microseconds since program start or power on
|
||||||
|
fn get_monotonic_time(&self, time_data: TimeData) -> Timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub struct UnixTimeDriver;
|
pub struct UnixTimeDriver {
|
||||||
|
start_time: std::time::Instant,
|
||||||
|
}
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl UnixTimeDriver {
|
impl UnixTimeDriver {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {}
|
Self {
|
||||||
|
start_time: std::time::Instant::now(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +35,11 @@ impl TimeDriver for UnixTimeDriver {
|
|||||||
SystemTime::now()
|
SystemTime::now()
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_micros() as u64
|
.as_micros() as Timestamp
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_monotonic_time(&self, _time_data: TimeData) -> Timestamp {
|
||||||
|
self.start_time.elapsed().as_micros() as Timestamp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +54,10 @@ impl TimeDriver for SchTimeDriver {
|
|||||||
fn get_system_time(&self, time_data: TimeData) -> Timestamp {
|
fn get_system_time(&self, time_data: TimeData) -> Timestamp {
|
||||||
time_data.sch_counter + time_data.time_offset
|
time_data.sch_counter + time_data.time_offset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_monotonic_time(&self, time_data: TimeData) -> Timestamp {
|
||||||
|
return time_data.sch_counter * 10000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "rp2040")]
|
#[cfg(feature = "rp2040")]
|
||||||
@@ -67,4 +83,8 @@ impl TimeDriver for Rp2040TimeDriver {
|
|||||||
fn get_system_time(&self, time_data: TimeData) -> Timestamp {
|
fn get_system_time(&self, time_data: TimeData) -> Timestamp {
|
||||||
self.timer.get_counter().ticks() + time_data.time_offset
|
self.timer.get_counter().ticks() + time_data.time_offset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_monotonic_time(&self, _time_data: TimeData) -> Timestamp {
|
||||||
|
self.timer.get_counter().ticks()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,41 @@
|
|||||||
|
use crate::time::Timestamp;
|
||||||
|
use crate::Rfe;
|
||||||
|
use bincode::{Decode, Encode};
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use crate::to_csv::ToCsv;
|
||||||
|
#[cfg(feature = "to_csv")]
|
||||||
|
use macros::ToCsv;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "to_csv", derive(ToCsv))]
|
||||||
|
pub struct PerfData {
|
||||||
|
enter_time: Timestamp,
|
||||||
|
elapsed: u32,
|
||||||
|
rate: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PerfData {
|
||||||
|
pub fn new(rfe: &Rfe) -> Self {
|
||||||
|
Self {
|
||||||
|
enter_time: rfe.get_met_time(),
|
||||||
|
elapsed: 0,
|
||||||
|
rate: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn enter(&mut self, rfe: &Rfe) {
|
||||||
|
let time = rfe.get_met_time();
|
||||||
|
self.rate = (time - self.enter_time) as u32;
|
||||||
|
self.enter_time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn exit(&mut self, rfe: &Rfe) {
|
||||||
|
let time = rfe.get_met_time();
|
||||||
|
self.elapsed = (time - self.enter_time) as u32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct ManualAuto<T: Clone + PartialEq> {
|
pub struct ManualAuto<T: Clone + PartialEq> {
|
||||||
value_auto: T,
|
value_auto: T,
|
||||||
|
|||||||
Reference in New Issue
Block a user