Safe, idiomatic bindings to cFE and OSAL APIs for Rust

Overview

n2o4

The n2o4 crate provides safe, idiomatic Rust bindings to the APIs of cFE and OSAL, the libraries of the Core Flight System (cFS).

IMPORTANT NOTE

This is a work in progress. While enough has been written to allow some classes of cFS application to be written, bindings for many parts of the API don't currently exist.

If you need or want to use some part of the API for which a binding doesn't exist yet, consider helping to flesh out the crate!

Limitations

Currently, n2o4 only supports the following:

  • cFE tag v7.0.0-rc4
  • OSAL tag v6.0.0-rc4

Extending support to other versions is an open issue (#1).

Using this crate in your cFS app

See USING.md for how to set everything up to use n2o4 (and Rust in general) in your cFS application.

Also, take a look at a sample app demonstrating the use of n2o4.

Contributing

cfs-sys

Under the hood, n2o4 uses cfs-sys (not to be confused with the crate of the same name on crates.io), which provides mostly machine-generated, unsafe bindings to the cFS and OSAL APIs.

License

This crate is licensed under the Apache License version 2.0. This is the same license cFE and OSAL are released under.

About the name

N2O4 is the chemical formula for dinitrogen tetroxide (aka nitrogen tetroxide). As cFS is intended for spacecraft flight software, and the Rust community has a long history of oxidation-related names, it seems appropriate to give this crate the name of a rocket propellant—one that's an oxidizer.

Launch of the Gemini 3 spacecraft on a Titan II rocket, powered in part by N2O4 (the chemical, not the Rust crate)

Comments
  • Adding bindings for OSAL semaphores, basic ES child-task routines

    Adding bindings for OSAL semaphores, basic ES child-task routines

    This pull request includes BinSem, CountSem, and MutSem, wrappers for the three types of synchronization primitive provided by OSAL, as well as wrappers for CFE_ES_CreateChildTask and CFE_ES_ExitChildTask.

    Adding just the latter part was my original intent, but my desire for a more idiomatic interface to CFE_ES_CreateChildTask led to me needing the former.

    opened by zec 1
  • Changed `AsRef<CStr>` type bound to `AsRef<CStr> + ?Sized`

    Changed `AsRef` type bound to `AsRef + ?Sized`

    In the places we're using S: AsRef<CStr>, we only ever deal with references to S.

    The implicit Sized bound is thus unnecessarily restrictive (and in some contexts, actively obstructive), so this PR removes it.

    opened by zec 1
  • Switch to using C FFI types in `core` (Rust 1.64.0+)

    Switch to using C FFI types in `core` (Rust 1.64.0+)

    Now that Rust 1.64.0 has landed, the C FFI types we need in n2o4 and cfs-sys are available in core::ffi on stable Rust.

    This pull request has the following effects:

    • Switches from using libc::c_* to core::ffi::c_*, removing the need for the libc crate as a dependency
    • Genericizes (null-terminated) string parameters beyond just printf_wrap::NullString to any implementer of AsRef<CStr> (as CStr's available in #[no_std] land now)

    Resolves #3.

    opened by zec 1
  • Make string, C type-related changes upon Rust 1.64.0 release

    Make string, C type-related changes upon Rust 1.64.0 release

    Issue BlackCAT-CubeSat/printf-wrap#1 should make the printf-wrap crate unconditionally #[no_std] on Rust ≥1.64.0 and remove the dependency on the libc crate. Once that comes out, we should propagate those changes to n2o4 and cfs-sys.

    Relevant bits include Cargo.toml as well as stuff scattered throughout the Rust source (idea: change NullString arguments to be AsRef<CStr> instead?).

    enhancement 
    opened by zec 1
  • Additions to `CStrBuf`, TIME

    Additions to `CStrBuf`, TIME

    This PR includes three additions:

    • A consuming constructor for CStrBuf
    • Splitting the "absolute time" and "time delta" roles of cfe::time::SysTime into separate types (SysTime and DeltaTime, respectively)
    • Implementing operations on SysTime and DeltaTime

    The latter two are of use for current development of an internal app; the first should be useful for some future bindings work.

    opened by zec 0
  • Figure out scheme for in-build caching

    Figure out scheme for in-build caching

    Each Rust-based cFS app is compiled separately. Often, they have many of the same dependencies (n2o4, bindgen, etc.), and it would be nice to leverage that to speed up compilation.

    Need to find out how to do that safely.

    opened by zec 0
  • Add docs generation

    Add docs generation

    As a crate which isn't being released on crates.io currently, we don't just get online docs for free from docs.rs. Hand-maintaining generation is tedious and prone to errors of omission; as such, we should probably set up a GitHub workflow for building the docs upon an update of the main branch, generating the HTML and pushing it onto the gh-pages branch.

    opened by zec 0
  • Add ability to use Rust formatted strings with cFE syslog, events

    Add ability to use Rust formatted strings with cFE syslog, events

    Right now, with the use of printf-wrap, n2o4 has decent support for printf(3)-type formatting with syslog entries and events. However, Rust has its own string-formatting system. It would be good to support using that instead when making syslog entries or events for a more Rustic experience.

    Some things that may come in handy when creating that:

    core::write core::fmt::Write core::format_args

    In particular, implementing Write for a "[u8; N] plus index-into-buffer" type would allow all this to be done without heap allocations.

    opened by zec 0
  • Make this project work with multiple versions of cFE, OSAL

    Make this project work with multiple versions of cFE, OSAL

    Currently, the n2o4 and cfs-sys crates only support a specific version of cFE and OSAL:

    As these are the versions of the respective libraries we're using in the BlackCAT flight software, this has been OK for development so far. However, n2o4 should ideally be usable on as wide a range of setups as possible, and that means being able to support other versions of cFE and OSAL.

    Right now, it's not clear to me how to modify the current system to support multiple library versions. cfs-sys just tries to bindgen everything it can (with some manual additions), with no awareness of what versions of cFE and OSAL it's working with. n2o4 does no version detection whatsoever, and manually trying to track which APIs are available in which versions of {cFE, OSAL} (and with which signatures) sounds like it would be tedious and error-prone.

    So, are there good ways to automate or semi-automate this?

    enhancement 
    opened by zec 0
Owner
The BlackCAT X-ray astronomy mission
null
Rust-idiomatic, compliant, flexible and performant BIP21 crate

Rust implementation of BIP21 Rust-idiomatic, compliant, flexible and performant BIP21 crate. About Important: while lot of work went into polishing th

Martin Habovštiak 6 Dec 15, 2022
A peer-reviewed collection of articles/talks/repos which teach concise, idiomatic Rust.

This repository collects resources for writing clean, idiomatic Rust code. Please bring your own. ?? Idiomatic coding means following the conventions

Matthias 4.2k Dec 30, 2022
Idiomatic Rust implementations for various Windows string types (like UNICODE_STRING)

nt-string by Colin Finck <[email protected]> Provides idiomatic Rust implementations for various Windows string types: NtUnicodeString (with NtUnicode

Colin Finck 5 Jun 4, 2023
Safe, efficient, and ergonomic bindings to Wolfram LibraryLink and the Wolfram Language

wolfram-library-link Bindings to the Wolfram LibraryLink interface, making it possible to call Rust code from the Wolfram Language. This library is us

Wolfram Research, Inc. 28 Dec 6, 2022
Safe Rust bindings to the DynamoRIO dynamic binary instrumentation framework.

Introduction The dynamorio-rs crate provides safe Rust bindings to the DynamoRIO dynamic binary instrumentation framework, essentially allowing you to

S.J.R. van Schaik 17 Nov 21, 2022
A backend framework for building fast and flexible APIs rapidly.

Andromeda Andromeda is a backend framework for Rust, to simplify the development of the kinds of basic API services that we developers have to build s

Framesurge 7 Dec 28, 2022
Rust Library for controlling divoom devices that support REST APIs, such as pixoo-64.

Divoom Rust Library for controlling divoom devices that support REST APIs, such as pixoo-64 (and from how divoom's api/doc organizes, maybe more in th

Riff 16 Dec 23, 2022
A simple path traversal checker made with Rust. Useful for APIs that serve dynamic files.

Path trav A simple path traversal checker made with Rust. Useful for APIs that serve dynamic files. Note: this is a security tool. If you see somethin

Gátomo 3 Nov 21, 2022
Build database expression type checker and vectorized runtime executor in type-safe Rust

Typed Type Exercise in Rust Build database expression type checker and vectorized runtime executor in type-safe Rust. This project is highly inspired

Andy Lok 89 Dec 27, 2022
Simple, safe way to store and distribute tensors

safetensors Safetensors This repository implements a new simple format for storing tensors safely (as opposed to pickle) and that is still fast (zero-

Hugging Face 402 Dec 29, 2022
Thread-safe clone-on-write container for fast concurrent writing and reading.

sync_cow Thread-safe clone-on-write container for fast concurrent writing and reading. SyncCow is a container for concurrent writing and reading of da

null 40 Jan 16, 2023
A additional Rust compiler pass to detect memory safe bugs of Rust programs.

SafeDrop A additional Rust compiler pass to detect memory safe bugs of Rust programs. SafeDrop performs path-sensitive and field-sensitive inter-proce

Artisan-Lab  (Fn*) 5 Nov 25, 2022
Safe, comp time generated queries in rust

query_builder For each struct field following methods will be generated. All fields where_FIELDNAME_eq Numeric fields where_FIELDNAME_le where_FIELDNA

Amirreza Askarpour 2 Oct 31, 2021
Safe MMDeploy Rust wrapper.

Introduction Safe MMDeploy Rust wrapper. News (2022.9.29) This repo has been added into the OpenMMLab ecosystem. (2022.9.27) This repo has been added

Mengyang Liu 14 Dec 15, 2022
Blazing fast, memory safe & modern Linux package manager written in Rust.

paket Blazing fast, memory safe & modern Linux package manager written in Rust. Roadmap Version: 0.1 Paket.toml file parsing. (#1, #2) CLI handling (p

null 4 Oct 19, 2023
A type-safe, high speed programming language for scalable systems

A type-safe, high speed programming language for scalable systems! (featuring a cheesy logo!) note: the compiler is unfinished and probably buggy. if

Hail 0 Sep 14, 2022
Linked Atomic Random Insert Vector: a thread-safe, self-memory-managed vector with no guaranteed sequential insert.

Linked Atomic Random Insert Vector Lariv is a thread-safe, self-memory-managed vector with no guaranteed sequential insert. It internally uses a linke

Guillem Jara 8 Feb 1, 2023
Rust bindings to the Wolfram Symbolic Transport Protocol (WSTP)

wstp Bindings to the Wolfram Symbolic Transfer Protocol (WSTP) library. This crate provides a set of safe and ergonomic bindings to the WSTP library,

Wolfram Research, Inc. 10 Nov 1, 2022
Rust bindings to the dos-like framework

dos-like for Rust   This project provides access to Mattias Gustavsson's dos-like framework, so as to write DOS-like applications in Rust. How to use

Eduardo Pinho 9 Aug 25, 2022