-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from quartiq/feature/service-publish
Adding metadata topic publish on alive tree
- Loading branch information
Showing
10 changed files
with
179 additions
and
117 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! Booster run-time application metadata | ||
//! | ||
//! # Copyright | ||
//! Copyright (C) 2020 QUARTIQ GmbH - All Rights Reserved | ||
//! Unauthorized usage, editing, or copying is strictly prohibited. | ||
//! Proprietary and confidential. | ||
use serde::Serialize; | ||
|
||
use super::{platform, HardwareVersion}; | ||
|
||
mod build_info { | ||
include!(concat!(env!("OUT_DIR"), "/built.rs")); | ||
} | ||
|
||
#[derive(Serialize)] | ||
pub struct ApplicationMetadata { | ||
pub firmware_version: &'static str, | ||
pub rust_version: &'static str, | ||
pub profile: &'static str, | ||
pub git_dirty: bool, | ||
pub features: &'static str, | ||
pub panic_info: &'static str, | ||
pub watchdog: bool, | ||
pub hardware_version: HardwareVersion, | ||
} | ||
|
||
impl ApplicationMetadata { | ||
/// Construct the global metadata. | ||
/// | ||
/// # Note | ||
/// This may only be called once. | ||
/// | ||
/// # Args | ||
/// * `hardware_version` - The hardware version detected. | ||
/// | ||
/// # Returns | ||
/// A reference to the global metadata. | ||
pub fn new(hardware_version: HardwareVersion) -> &'static ApplicationMetadata { | ||
let mut meta = cortex_m::singleton!(: ApplicationMetadata = ApplicationMetadata { | ||
firmware_version: "Unspecified", | ||
rust_version: build_info::RUSTC_VERSION, | ||
profile: build_info::PROFILE, | ||
git_dirty: true, | ||
features: build_info::FEATURES_STR, | ||
panic_info: "None", | ||
watchdog: platform::watchdog_detected(), | ||
hardware_version, | ||
}) | ||
.unwrap(); | ||
|
||
if let Some(panic_data) = panic_persist::get_panic_message_utf8() { | ||
meta.panic_info = panic_data; | ||
} | ||
|
||
if let Some(dirty) = build_info::GIT_DIRTY { | ||
meta.git_dirty = dirty; | ||
} | ||
|
||
if let Some(version) = build_info::GIT_VERSION { | ||
meta.firmware_version = version; | ||
} | ||
|
||
meta | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.