SpaceWire (ECSS-E-ST-50-12C) and RMAP (ECSS-E-ST-50-52C)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

OCaml 70.4%
C 23.3%
PHP 1.9%
Dune 1.0%
Roff 0.9%
Other 2.6%
21 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-spacewire https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-spacewire
git@git.recoil.org:gazagnaire.org/ocaml-spacewire git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-spacewire

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

spacewire#

Pure OCaml implementation of SpaceWire (ECSS-E-ST-50-12C) and RMAP (ECSS-E-ST-50-52C).

Overview#

SpaceWire is a point-to-point serial data link standard used inside spacecraft for connecting sensors, processors, and mass-memory units. RMAP (Remote Memory Access Protocol) is layered on top of SpaceWire to provide standardised read/write access to memory on remote nodes.

This library implements the packet-level protocol (not the physical/character layer) and the RMAP command/reply encoding with CRC-8 integrity.

Features#

  • SpaceWire packet types: path addressing, cargo, EOP/EEP markers
  • RMAP command codes: read, write, write-with-verify, read-modify-write
  • RMAP reply encoding with status codes
  • RMAP CRC-8 (polynomial 0x07, per ECSS-E-ST-50-52C Annex A)
  • Encode/decode with CRC integrity verification

Installation#

Install with opam:

$ opam install spacewire

If opam cannot find the package, it may not yet be released in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install spacewire

Usage#

(* Create and encode a SpaceWire packet. *)
let pkt = Spacewire.packet_exn ~address:[ 1; 5 ] ~cargo:"sensor data" EOP
let bytes = Spacewire.encode_packet pkt

let () =
  match Spacewire.decode_packet bytes with
  | Ok decoded -> Fmt.pr "cargo: %s@." (Spacewire.cargo decoded)
  | Error _ -> Fmt.epr "decode error@."
(* RMAP read command. *)
let cmd =
  Spacewire.rmap_command_exn ~command:Read ~ack:Ack ~increment:Increment
    ~key:42 ~initiator_logical_address:0xFE ~transaction_id:1
    ~address:0x1000L ~data_length:256 ()

let encoded = Spacewire.encode_rmap_command ~target_logical_address:0x50 cmd

let () =
  match Spacewire.decode_rmap_command encoded with
  | Ok (target, decoded) ->
      Fmt.pr "target: 0x%02X, tid: %d@." target
        (Spacewire.rmap_cmd_transaction_id decoded)
  | Error _ -> Fmt.epr "decode error@."

Protocol Layers#

+------------------------------------------+
| RMAP (Remote Memory Access Protocol)     |
|   ECSS-E-ST-50-52C                       |
+------------------------------------------+
| SpaceWire Packet                         |
|   destination address + cargo + EOP/EEP  |
+------------------------------------------+
| SpaceWire Character (not modelled)       |
|   data char (8-bit + parity) | control   |
+------------------------------------------+
| SpaceWire Physical (not modelled)        |
|   LVDS, encoding, link state machine     |
+------------------------------------------+

References#

Licence#

ISC License. See LICENSE.md for details.