Skip to content

Add libcsp Rust integration layer with Linux I2C support#34

Merged
OrenRotaru merged 4 commits into
mainfrom
Adding-libcsp-for-rust
May 20, 2026
Merged

Add libcsp Rust integration layer with Linux I2C support#34
OrenRotaru merged 4 commits into
mainfrom
Adding-libcsp-for-rust

Conversation

@OrenRotaru

@OrenRotaru OrenRotaru commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds vendor/libcsp and vendor/libcsp-rust as git submodules, brings the CubeSat Space Protocol C library and its Rust FFI bindings.
  • Introduces a new radsat-csp crate (kubos/libs/radsat-csp) that wraps libcsp behind an Rust API usable by device APIs and services.
  • Adds a vendor patch and helper script (scripts/apply-vendor-patches.sh) to fix libcsp-rust raw-pointer slice expressions rejected by current Rust compilers under dangerous_implicit_autorefs.

radsat-csp crate features

  • One-time initializationinitialize() backed by std::sync::Once; called automatically by RouterWorker and ReservedServiceWorker.
  • RouterWorker — spawns the libcsp routing thread and keeps it alive for the process lifetime.
  • ReservedServiceWorker — handles standard CSP reserved-port services (ping, etc.).
  • CspClient — helpers for ping, send, and request/reply transaction with configurable timeout and priority.
  • Linux I2C transport (--features i2c) — LinuxI2cCspInterface registers libcsp's C I2C interface and uses linux-embedded-hal::I2cdev for physical writes. Includes route_node_via_i2c_addr() for when a device's CSP node id differs from its 7-bit I2C address, and explicit read_frame_from() / inject_received_frame() helpers for master-driven receive polling.

Test plan

  • cargo build -p radsat-csp builds cleanly after git submodule update --init --recursive && sh scripts/apply-vendor-patches.sh
  • cargo build -p radsat-csp --features i2c builds with I2C support enabled
  • cargo test -p radsat-csp passes the loopback smoke test (ping + echo transaction over the CSP loopback interface)
  • cargo test -p radsat-csp --features i2c passes the I2C command/frame encoding tests

@OrenRotaru OrenRotaru merged commit b4923dc into main May 20, 2026
0 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant