Skip to main content

Crate cr1140_sdk

Crate cr1140_sdk 

Source
Expand description

CR1140 SDK — app-building conveniences layered on top of cr1140-hal.

This crate is deliberately UI-framework agnostic (no Slint, no rendering): it provides the “batteries” a native CR1140 application needs regardless of how it draws — keypad LED effects, system telemetry, and device/network info.

  • led — RGB keypad-LED animation modes and a led::LedDriver.
  • metrics — generic Linux telemetry (CPU, memory, load, uptime) plus a metrics::Telemetry collector returning an aggregated metrics::Snapshot.
  • device — device & OS identity and network state.
  • guardguard::ShutdownGuard: restore backlight/LED on exit (RAII), with opt-in SIGINT/SIGTERM handling for standalone binaries.
  • config — atomic config::Store persistence for the p2 overlay (/home/cds-apps); enabled by the default config feature.
  • retain — reflash-surviving retain::Store on the SPI EEPROM (A/B + CRC32, postcard); enabled by the default retain feature.
  • net — host network-config apply via nmcli (net::apply); off by default behind the net feature.

Errors from fallible operations surface as SdkError. This crate is a guest under host executors (ROS 2 / Apex / Taktora): it logs through the tracing facade without installing a subscriber, and never grabs signals by default.

Re-exports§

pub use config::Store;
pub use config::DEFAULT_APP_DIR;
pub use error::SdkError;
pub use error::SdkResult;
pub use guard::ShutdownFlag;
pub use guard::ShutdownGuard;
pub use metrics::MemInfo;
pub use metrics::Snapshot;
pub use metrics::Telemetry;
pub use retain::Store as RetainStore;

Modules§

config
Atomic config persistence for the writable p2 overlay (/home/cds-apps).
device
Device & OS identity and network state: things that describe this unit (model/firmware, hostname, onboard board sensor) and its links (eth0/can0).
error
Unified SDK error type. Mirrors cr1140_hal::HalError’s thiserror pattern so callers — including ROS 2 / Apex nodes — can match on the cause. Metrics parsers/readers stay Option; fallible hardware and config operations return SdkResult.
guard
Shutdown/restore for the keypad LED and display backlight.
led
Keypad-LED animation. Each LedMode is a pure brightness curve over time; LedDriver holds the current color + mode and writes the RGB hardware (via cr1140-hal) only when the computed value changes.
metrics
Generic Linux system telemetry from /proc. Not CR1140-specific — works on any Linux host. Pure parsers (host-testable) plus thin procfs readers.
net
Host network-config apply via nmcli (feature net, off by default).
retain
Reflash-surviving persistence on the SPI EEPROM.