Skip to main content

App

Struct App 

Source
pub struct App { /* private fields */ }
Expand description

Standard cFS application with automatic boilerplate.

Handles pipe creation, topic subscriptions, EVS registration, NoOp (fcn 0), and Reset Counters (fcn 1).

HK wakeups are surfaced as Event::Hk so the app controls what telemetry to publish.

§Example

let mut app = App::builder()
    .name("MY_APP")
    .cmd_topic(MY_CMD_TOPIC)
    .send_hk_topic(SEND_HK_TOPIC)
    .hk_tlm_topic(MY_HK_TLM_TOPIC)
    .version("1.0.0")
    .build()?;

let mut buf = [0u8; 256];
loop {
    match app.recv(&mut buf).await? {
        Event::Hk => app.send_hk(&my_hk)?,
        Event::Command(msg) => app.reject(msg)?,
    }
}

Implementations§

Source§

impl App

Source

pub fn builder() -> AppBuilder

Creates a new cFS application.

Registers with EVS, creates a Software Bus pipe, and subscribes to command and HK wakeup topics.

Both cmd_topic and send_hk_topic are treated as local command topic IDs. hk_tlm_topic is a local telemetry topic ID.

Source§

impl App

Source

pub async fn run(&mut self) -> Result<()>

Processes commands and HK in a loop.

Publishes base HK (cmd/err counters) on wakeup, rejects unrecognized commands. For custom HK or app-specific commands, use recv.

Source

pub async fn recv<'a>(&mut self, buf: &'a mut [u8]) -> Result<Event<'a>>

Receives the next event from the Software Bus.

Automatically handles NoOp (fcn 0) and Reset (fcn 1). Returns Event::Hk on HK wakeup so the app can publish its own telemetry. Returns Event::Command for app-specific commands.

Source

pub fn ack(&mut self)

Acknowledges successful command processing.

Increments the command counter.

Source

pub fn reject(&mut self, _msg: MessageRef<'_>) -> Result<()>

Rejects an unrecognized command.

Increments the error counter and sends an error event.

Source

pub fn send_hk<H: Copy>(&self, payload: &H) -> Result<()>

Publishes a custom HK telemetry packet.

The payload is serialized via as_bytes(). The app should include cmd/err counters (from cmd_count / err_count) in the struct.

Source

pub fn cmd_count(&self) -> u16

Returns the current command counter.

Source

pub fn err_count(&self) -> u16

Returns the current error counter.

Auto Trait Implementations§

§

impl Freeze for App

§

impl RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

§

impl UnwindSafe for App

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.