Merge pull request 'New CCSDS & ECSS Components' (#7) from workspace-spacepackets into main
Reviewed-on: rust/launchpad#7
This commit is contained in:
commit
a4234b90b8
@ -7,6 +7,7 @@
|
|||||||
<option name="allFeatures" value="false" />
|
<option name="allFeatures" value="false" />
|
||||||
<option name="emulateTerminal" value="false" />
|
<option name="emulateTerminal" value="false" />
|
||||||
<option name="withSudo" value="false" />
|
<option name="withSudo" value="false" />
|
||||||
|
<option name="buildTarget" value="REMOTE" />
|
||||||
<option name="backtrace" value="SHORT" />
|
<option name="backtrace" value="SHORT" />
|
||||||
<envs />
|
<envs />
|
||||||
<option name="isRedirectInput" value="false" />
|
<option name="isRedirectInput" value="false" />
|
||||||
|
538
Cargo.lock
generated
538
Cargo.lock
generated
@ -2,24 +2,81 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "0.7.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atomic-option"
|
name = "atomic-option"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0db678acb667b525ac40a324fc5f7d3390e29239b31c7327bb8157f5b4fff593"
|
checksum = "0db678acb667b525ac40a324fc5f7d3390e29239b31c7327bb8157f5b4fff593"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atomic-polyfill"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e14bf7b4f565e5e717d7a7a65b2a05c0b8c96e4db636d6f780f03b15108cdd1b"
|
||||||
|
dependencies = [
|
||||||
|
"critical-section",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bare-metal"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
|
||||||
|
dependencies = [
|
||||||
|
"rustc_version 0.2.3",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bare-metal"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bit_field"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitfield"
|
||||||
|
version = "0.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitvec"
|
||||||
|
version = "0.22.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5237f00a8c86130a0cc317830e558b966dd7850d48a953d998c813f01a41b527"
|
||||||
|
dependencies = [
|
||||||
|
"funty",
|
||||||
|
"radium",
|
||||||
|
"tap",
|
||||||
|
"wyz",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bus"
|
name = "bus"
|
||||||
version = "2.2.3"
|
version = "2.2.3"
|
||||||
@ -32,12 +89,24 @@ dependencies = [
|
|||||||
"parking_lot_core",
|
"parking_lot_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cloudabi"
|
name = "cloudabi"
|
||||||
version = "0.0.3"
|
version = "0.0.3"
|
||||||
@ -47,6 +116,45 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cortex-m"
|
||||||
|
version = "0.7.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cd20d4ac4aa86f4f75f239d59e542ef67de87cce2c282818dc6e84155d3ea126"
|
||||||
|
dependencies = [
|
||||||
|
"bare-metal 0.2.5",
|
||||||
|
"bitfield",
|
||||||
|
"embedded-hal",
|
||||||
|
"volatile-register",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crc"
|
||||||
|
version = "3.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3"
|
||||||
|
dependencies = [
|
||||||
|
"crc-catalog",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crc-catalog"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "critical-section"
|
||||||
|
version = "0.2.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95da181745b56d4bd339530ec393508910c909c784e8962d15d722bacf0bcbcd"
|
||||||
|
dependencies = [
|
||||||
|
"bare-metal 1.0.0",
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"cortex-m",
|
||||||
|
"riscv",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
@ -64,10 +172,127 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "darling"
|
||||||
|
version = "0.14.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4529658bdda7fd6769b8614be250cdcfc3aeb0ee72fe66f9e41e5e5eb73eac02"
|
||||||
|
dependencies = [
|
||||||
|
"darling_core",
|
||||||
|
"darling_macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "darling_core"
|
||||||
|
version = "0.14.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "649c91bc01e8b1eac09fb91e8dbc7d517684ca6be8ebc75bb9cafc894f9fdb6f"
|
||||||
|
dependencies = [
|
||||||
|
"fnv",
|
||||||
|
"ident_case",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"strsim",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "darling_macro"
|
||||||
|
version = "0.14.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ddfc69c5bfcbd2fc09a0f38451d2daf0e372e367986a83906d1b0dbc88134fb5"
|
||||||
|
dependencies = [
|
||||||
|
"darling_core",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deku"
|
||||||
|
version = "0.13.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "868ccf23869582b2d79279e402db457fe341da24a0c5a8927c6154a5b4733dc3"
|
||||||
|
dependencies = [
|
||||||
|
"bitvec",
|
||||||
|
"deku_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deku_derive"
|
||||||
|
version = "0.13.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4dfb4274ccd1c87a598e98b398b4b630aecb2e8a32fd7c88ffa190fb73870f72"
|
||||||
|
dependencies = [
|
||||||
|
"darling",
|
||||||
|
"proc-macro-crate",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-hal"
|
||||||
|
version = "0.2.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff"
|
||||||
|
dependencies = [
|
||||||
|
"nb 0.1.3",
|
||||||
|
"void",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fnv"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fsrc-core"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bus",
|
||||||
|
"deku",
|
||||||
|
"heapless",
|
||||||
|
"num",
|
||||||
|
"postcard",
|
||||||
|
"serde",
|
||||||
|
"thiserror",
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "funty"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hash32"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heapless"
|
||||||
|
version = "0.7.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "065681e99f9ef7e0e813702a0326aedbcbbde7db5e55f097aedd1bf50b9dca43"
|
||||||
|
dependencies = [
|
||||||
|
"atomic-polyfill",
|
||||||
|
"hash32",
|
||||||
|
"rustc_version 0.4.0",
|
||||||
|
"serde",
|
||||||
|
"spin",
|
||||||
|
"stable_deref_trait",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.19"
|
version = "0.1.19"
|
||||||
@ -78,13 +303,10 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "launchpad"
|
name = "ident_case"
|
||||||
version = "0.1.0"
|
version = "1.0.1"
|
||||||
dependencies = [
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"bus",
|
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||||
"num",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
@ -98,12 +320,43 @@ version = "0.2.126"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
|
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lock_api"
|
||||||
|
version = "0.4.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "maybe-uninit"
|
name = "maybe-uninit"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nb"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f"
|
||||||
|
dependencies = [
|
||||||
|
"nb 1.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nb"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num"
|
name = "num"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@ -196,7 +449,7 @@ version = "0.7.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
|
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"cloudabi",
|
"cloudabi",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
@ -205,12 +458,39 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "postcard"
|
||||||
version = "1.0.38"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa"
|
checksum = "a25c0b0ae06fcffe600ad392aabfa535696c8973f2253d9ac83171924c58a858"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid",
|
"heapless",
|
||||||
|
"postcard-cobs",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "postcard-cobs"
|
||||||
|
version = "0.1.5-pre"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c68cb38ed13fd7bc9dd5db8f165b7c8d9c1a315104083a2b10f11354c2af97f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-crate"
|
||||||
|
version = "1.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror",
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.39"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -222,12 +502,121 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "radium"
|
||||||
|
version = "0.6.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.1.57"
|
version = "0.1.57"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.5.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.6.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "riscv"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6907ccdd7a31012b70faf2af85cd9e5ba97657cc3987c4f13f8e4d2c2a088aba"
|
||||||
|
dependencies = [
|
||||||
|
"bare-metal 1.0.0",
|
||||||
|
"bit_field",
|
||||||
|
"riscv-target",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "riscv-target"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc_version"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||||
|
dependencies = [
|
||||||
|
"semver 0.9.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc_version"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
|
||||||
|
dependencies = [
|
||||||
|
"semver 1.0.10",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||||
|
dependencies = [
|
||||||
|
"semver-parser",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver"
|
||||||
|
version = "1.0.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver-parser"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.137"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.137"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
@ -235,16 +624,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "spacepackets"
|
||||||
version = "1.0.94"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"crc",
|
||||||
|
"deku",
|
||||||
|
"num",
|
||||||
|
"postcard",
|
||||||
|
"serde",
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spin"
|
||||||
|
version = "0.9.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a07e33e919ebcd69113d5be0e4d70c5707004ff45188910106854f38b960df4a"
|
checksum = "c530c2b0d0bf8b69304b39fe2001993e267461948b890cd037d8ad4293fa1a0d"
|
||||||
|
dependencies = [
|
||||||
|
"lock_api",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stable_deref_trait"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strsim"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.96"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "synstructure"
|
||||||
|
version = "0.12.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tap"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.31"
|
version = "1.0.31"
|
||||||
@ -265,12 +705,48 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml"
|
||||||
|
version = "0.5.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
|
checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vcell"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "void"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "volatile-register"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6"
|
||||||
|
dependencies = [
|
||||||
|
"vcell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@ -292,3 +768,33 @@ name = "winapi-x86_64-pc-windows-gnu"
|
|||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wyz"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "129e027ad65ce1453680623c3fb5163cbf7107bfe1aa32257e7d0e63f9ced188"
|
||||||
|
dependencies = [
|
||||||
|
"tap",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "332f188cc1bcf1fe1064b8c58d150f497e697f49774aa846f2dc949d9a25f236"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"zerocopy-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a0fbc82b82efe24da867ee52e015e58178684bd9dd64c34e66bdf21da2582a9f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"syn",
|
||||||
|
"synstructure",
|
||||||
|
]
|
||||||
|
15
Cargo.toml
15
Cargo.toml
@ -1,11 +1,6 @@
|
|||||||
[package]
|
[workspace]
|
||||||
name = "launchpad"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
members = [
|
||||||
|
"fsrc-core",
|
||||||
[dependencies]
|
"spacepackets",
|
||||||
thiserror = "1.0"
|
]
|
||||||
bus = "2.2.3"
|
|
||||||
num = "0.4"
|
|
||||||
|
82
archive.rs
Normal file
82
archive.rs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
pub mod deku {
|
||||||
|
pub use ccsds_spacepacket::PrimaryHeader as SpHeader;
|
||||||
|
use crate::sp::{self, PacketId, PacketSequenceCtrl};
|
||||||
|
use crate::sp::{CcsdsPrimaryHeader, PacketType, SequenceFlags};
|
||||||
|
|
||||||
|
impl CcsdsPrimaryHeader for SpHeader {
|
||||||
|
fn from_composite_fields(packet_id: PacketId, psc: PacketSequenceCtrl, data_len: u16, version: Option<u8>) -> Self {
|
||||||
|
let mut version_to_set = 0b000;
|
||||||
|
if let Some(version) = version {
|
||||||
|
version_to_set = version;
|
||||||
|
}
|
||||||
|
let packet_type = match packet_id.ptype {
|
||||||
|
PacketType::Tm => ccsds_spacepacket::types::PacketType::Data,
|
||||||
|
PacketType::Tc => ccsds_spacepacket::types::PacketType::Command
|
||||||
|
};
|
||||||
|
let sec_header_flag = match packet_id.sec_header_flag {
|
||||||
|
true => ccsds_spacepacket::types::SecondaryHeaderFlag::Present,
|
||||||
|
false => ccsds_spacepacket::types::SecondaryHeaderFlag::NotPresent
|
||||||
|
};
|
||||||
|
let sequence_flags = match psc.seq_flags {
|
||||||
|
SequenceFlags::ContinuationSegment => ccsds_spacepacket::types::SeqFlag::Continuation,
|
||||||
|
SequenceFlags::FirstSegment => ccsds_spacepacket::types::SeqFlag::FirstSegment,
|
||||||
|
SequenceFlags::LastSegment => ccsds_spacepacket::types::SeqFlag::LastSegment,
|
||||||
|
SequenceFlags::Unsegmented => ccsds_spacepacket::types::SeqFlag::Unsegmented
|
||||||
|
};
|
||||||
|
SpHeader {
|
||||||
|
version: version_to_set,
|
||||||
|
packet_type,
|
||||||
|
sec_header_flag,
|
||||||
|
app_proc_id: packet_id.apid,
|
||||||
|
sequence_flags,
|
||||||
|
sequence_count: psc.ssc,
|
||||||
|
data_length: data_len
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn version(&self) -> u8 {
|
||||||
|
self.version
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn packet_id(&self) -> PacketId {
|
||||||
|
PacketId {
|
||||||
|
ptype: PacketType::try_from(self.packet_type as u8).unwrap(),
|
||||||
|
apid: self.app_proc_id,
|
||||||
|
sec_header_flag: self.sec_header_flag as u8 != 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn psc(&self) -> PacketSequenceCtrl {
|
||||||
|
PacketSequenceCtrl {
|
||||||
|
seq_flags: SequenceFlags::try_from(self.sequence_flags as u8).unwrap(),
|
||||||
|
ssc: self.sequence_count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn data_len(&self) -> u16 {
|
||||||
|
self.data_length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sph_from_other!(SpHeader, sp::srd::SpHeader);
|
||||||
|
sph_from_other!(SpHeader, sp::zc::SpHeader);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
#[test]
|
||||||
|
fn test_deser_to_raw_packed_deku() {
|
||||||
|
let sp_header = SpHeader::tc(0x42, 12).expect("Error creating SP header");
|
||||||
|
// TODO: Wait with these tests until KubOS merged
|
||||||
|
// https://github.com/KubOS-Preservation-Group/ccsds-spacepacket/pull/14
|
||||||
|
let _deku_header =
|
||||||
|
deku::SpHeader::try_from(sp_header).expect("Error creating Deku Sp Header");
|
||||||
|
// deku_header.to_bytes().unwrap();
|
||||||
|
}
|
||||||
|
*/
|
16
fsrc-core/Cargo.toml
Normal file
16
fsrc-core/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[package]
|
||||||
|
name = "fsrc-core"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
thiserror = "1.0"
|
||||||
|
bus = "2.2.3"
|
||||||
|
num = "0.4"
|
||||||
|
heapless = "0.7.13"
|
||||||
|
postcard = { version = "0.7.3", features = ["use-std"] }
|
||||||
|
serde = "1.0.137"
|
||||||
|
deku = "0.13"
|
||||||
|
zerocopy = "0.6.1"
|
@ -1,5 +1,5 @@
|
|||||||
//! [Event][crate::core::events::Event] management and forwarding
|
//! [Event][crate::core::events::Event] management and forwarding
|
||||||
use crate::core::events::{Event, EventRaw, GroupId};
|
use crate::events::{Event, EventRaw, GroupId};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Copy, Clone)]
|
#[derive(PartialEq, Eq, Hash, Copy, Clone)]
|
||||||
@ -115,8 +115,8 @@ impl<E> EventManager<E> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{EventListener, HandlerResult, ReceivesAllEvent};
|
use super::{EventListener, HandlerResult, ReceivesAllEvent};
|
||||||
use crate::core::event_man::EventManager;
|
use crate::event_man::EventManager;
|
||||||
use crate::core::events::{Event, Severity};
|
use crate::events::{Event, Severity};
|
||||||
use std::sync::mpsc::{channel, Receiver, SendError, Sender};
|
use std::sync::mpsc::{channel, Receiver, SendError, Sender};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
@ -95,7 +95,7 @@ impl TryFrom<EventRaw> for Event {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::Event;
|
use super::Event;
|
||||||
use crate::core::events::Severity;
|
use crate::events::Severity;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_events() {
|
fn test_events() {
|
@ -10,7 +10,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//! use std::any::Any;
|
//! use std::any::Any;
|
||||||
//! use std::error::Error;
|
//! use std::error::Error;
|
||||||
//! use launchpad::core::objects::{ManagedSystemObject, ObjectId, ObjectManager, SystemObject};
|
//! use fsrc_core::objects::{ManagedSystemObject, ObjectId, ObjectManager, SystemObject};
|
||||||
//!
|
//!
|
||||||
//! struct ExampleSysObj {
|
//! struct ExampleSysObj {
|
||||||
//! id: ObjectId,
|
//! id: ObjectId,
|
||||||
@ -125,7 +125,7 @@ impl ObjectManager {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::core::objects::{ManagedSystemObject, ObjectId, ObjectManager, SystemObject};
|
use crate::objects::{ManagedSystemObject, ObjectId, ObjectManager, SystemObject};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
@ -13,7 +13,7 @@
|
|||||||
//! # Example
|
//! # Example
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use launchpad::core::pool::{LocalPool, PoolCfg};
|
//! use fsrc_core::pool::{LocalPool, PoolCfg};
|
||||||
//!
|
//!
|
||||||
//! // 4 buckets of 4 bytes, 2 of 8 bytes and 1 of 16 bytes
|
//! // 4 buckets of 4 bytes, 2 of 8 bytes and 1 of 16 bytes
|
||||||
//! let pool_cfg = PoolCfg::new(vec![(4, 4), (2, 8), (1, 16)]);
|
//! let pool_cfg = PoolCfg::new(vec![(4, 4), (2, 8), (1, 16)]);
|
||||||
@ -308,7 +308,7 @@ impl LocalPool {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::core::pool::{LocalPool, PoolCfg, StoreAddr, StoreError, StoreIdError};
|
use crate::pool::{LocalPool, PoolCfg, StoreAddr, StoreError, StoreIdError};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cfg() {
|
fn test_cfg() {
|
14
spacepackets/Cargo.toml
Normal file
14
spacepackets/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "spacepackets"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
num = "0.4"
|
||||||
|
postcard = { version = "0.7.3", features = ["use-std"] }
|
||||||
|
serde = "1.0.137"
|
||||||
|
deku = "0.13"
|
||||||
|
zerocopy = "0.6.1"
|
||||||
|
crc = "3.0.0"
|
13
spacepackets/src/ecss.rs
Normal file
13
spacepackets/src/ecss.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use crate::CcsdsPacket;
|
||||||
|
|
||||||
|
pub trait PusPacket: CcsdsPacket {
|
||||||
|
fn service(&self) -> u8;
|
||||||
|
fn subservice(&self) -> u8;
|
||||||
|
fn source_id(&self) -> u16;
|
||||||
|
fn ack_flags(&self) -> u8;
|
||||||
|
|
||||||
|
fn user_data(&self) -> Option<&[u8]>;
|
||||||
|
fn crc16(&self) -> Option<u16>;
|
||||||
|
/// Verify that the packet is valid. PUS packets have a CRC16 checksum to do this
|
||||||
|
fn verify(&mut self) -> bool;
|
||||||
|
}
|
539
spacepackets/src/lib.rs
Normal file
539
spacepackets/src/lib.rs
Normal file
@ -0,0 +1,539 @@
|
|||||||
|
//! # Space related components including CCSDS and ECSS packet standards
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
pub mod ecss;
|
||||||
|
pub mod tc;
|
||||||
|
pub mod tm;
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
|
pub enum PacketError {
|
||||||
|
/// The passed slice is too small. Returns the required size of the failed size chgeck
|
||||||
|
ToBytesSliceTooSmall(usize),
|
||||||
|
/// The [zerocopy] library failed to write to bytes
|
||||||
|
ToBytesZeroCopyError,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone)]
|
||||||
|
pub enum PacketType {
|
||||||
|
Tm = 0,
|
||||||
|
Tc = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<u8> for PacketType {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||||
|
match value {
|
||||||
|
x if x == PacketType::Tm as u8 => Ok(PacketType::Tm),
|
||||||
|
x if x == PacketType::Tc as u8 => Ok(PacketType::Tc),
|
||||||
|
_ => Err(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn type_from_packet_id(packet_id: u16) -> PacketType {
|
||||||
|
PacketType::try_from((packet_id >> 12) as u8 & 0b1).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone)]
|
||||||
|
pub enum SequenceFlags {
|
||||||
|
ContinuationSegment = 0b00,
|
||||||
|
FirstSegment = 0b01,
|
||||||
|
LastSegment = 0b10,
|
||||||
|
Unsegmented = 0b11,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<u8> for SequenceFlags {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||||
|
match value {
|
||||||
|
x if x == SequenceFlags::ContinuationSegment as u8 => {
|
||||||
|
Ok(SequenceFlags::ContinuationSegment)
|
||||||
|
}
|
||||||
|
x if x == SequenceFlags::FirstSegment as u8 => Ok(SequenceFlags::FirstSegment),
|
||||||
|
x if x == SequenceFlags::LastSegment as u8 => Ok(SequenceFlags::LastSegment),
|
||||||
|
x if x == SequenceFlags::Unsegmented as u8 => Ok(SequenceFlags::Unsegmented),
|
||||||
|
_ => Err(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone)]
|
||||||
|
pub struct PacketId {
|
||||||
|
pub ptype: PacketType,
|
||||||
|
pub sec_header_flag: bool,
|
||||||
|
apid: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PacketId {
|
||||||
|
pub fn new(ptype: PacketType, sec_header_flag: bool, apid: u16) -> Option<PacketId> {
|
||||||
|
if apid > num::pow(2, 11) - 1 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(PacketId {
|
||||||
|
ptype,
|
||||||
|
sec_header_flag,
|
||||||
|
apid,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_apid(&mut self, apid: u16) -> bool {
|
||||||
|
if apid > num::pow(2, 11) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
self.apid = apid;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn apid(&self) -> u16 {
|
||||||
|
self.apid
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn raw(&self) -> u16 {
|
||||||
|
((self.ptype as u16) << 12) | ((self.sec_header_flag as u16) << 11) | self.apid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<u16> for PacketId {
|
||||||
|
fn from(raw_id: u16) -> Self {
|
||||||
|
PacketId {
|
||||||
|
ptype: PacketType::try_from(((raw_id >> 12) & 0b1) as u8).unwrap(),
|
||||||
|
sec_header_flag: ((raw_id >> 11) & 0b1) != 0,
|
||||||
|
apid: raw_id & 0x7FF,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone)]
|
||||||
|
pub struct PacketSequenceCtrl {
|
||||||
|
pub seq_flags: SequenceFlags,
|
||||||
|
ssc: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PacketSequenceCtrl {
|
||||||
|
pub fn new(seq_flags: SequenceFlags, ssc: u16) -> Option<PacketSequenceCtrl> {
|
||||||
|
if ssc > num::pow(2, 14) - 1 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(PacketSequenceCtrl { seq_flags, ssc })
|
||||||
|
}
|
||||||
|
pub fn raw(&self) -> u16 {
|
||||||
|
((self.seq_flags as u16) << 14) | self.ssc
|
||||||
|
}
|
||||||
|
pub fn set_ssc(&mut self, ssc: u16) -> bool {
|
||||||
|
if ssc > num::pow(2, 14) - 1 {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
self.ssc = ssc;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ssc(&self) -> u16 {
|
||||||
|
self.ssc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<u16> for PacketSequenceCtrl {
|
||||||
|
fn from(raw_id: u16) -> Self {
|
||||||
|
PacketSequenceCtrl {
|
||||||
|
seq_flags: SequenceFlags::try_from(((raw_id >> 14) & 0b11) as u8).unwrap(),
|
||||||
|
ssc: raw_id & SSC_MASK,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! sph_from_other {
|
||||||
|
($Self: path, $other: path) => {
|
||||||
|
impl From<$other> for $Self {
|
||||||
|
fn from(other: $other) -> Self {
|
||||||
|
Self::from_composite_fields(
|
||||||
|
other.packet_id(),
|
||||||
|
other.psc(),
|
||||||
|
other.data_len(),
|
||||||
|
Some(other.version()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const SSC_MASK: u16 = 0x3FFF;
|
||||||
|
const VERSION_MASK: u16 = 0xE000;
|
||||||
|
|
||||||
|
/// Generic trait to access fields of a CCSDS space packet header according to CCSDS 133.0-B-2
|
||||||
|
pub trait CcsdsPacket {
|
||||||
|
fn version(&self) -> u8;
|
||||||
|
fn packet_id(&self) -> PacketId;
|
||||||
|
fn psc(&self) -> PacketSequenceCtrl;
|
||||||
|
|
||||||
|
/// Retrieve data length field
|
||||||
|
fn data_len(&self) -> u16;
|
||||||
|
|
||||||
|
/// Retrieve 13 bit Packet Identification field. Can usually be retrieved with a bitwise AND
|
||||||
|
/// of the first 2 bytes with 0x1FFF
|
||||||
|
#[inline]
|
||||||
|
fn packet_id_raw(&self) -> u16 {
|
||||||
|
self.packet_id().raw()
|
||||||
|
}
|
||||||
|
/// Retrieve Packet Sequence Count
|
||||||
|
#[inline]
|
||||||
|
fn psc_raw(&self) -> u16 {
|
||||||
|
self.psc().raw()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
/// Retrieve Packet Type (TM: 0, TC: 1)
|
||||||
|
fn ptype(&self) -> PacketType {
|
||||||
|
// This call should never fail because only 0 and 1 can be passed to the try_from call
|
||||||
|
self.packet_id().ptype
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn is_tm(&self) -> bool {
|
||||||
|
self.ptype() == PacketType::Tm
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn is_tc(&self) -> bool {
|
||||||
|
self.ptype() == PacketType::Tc
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieve the secondary header flag. Returns true if a secondary header is present
|
||||||
|
/// and false if it is not
|
||||||
|
#[inline]
|
||||||
|
fn sec_header_flag(&self) -> bool {
|
||||||
|
self.packet_id().sec_header_flag
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieve Application Process ID
|
||||||
|
#[inline]
|
||||||
|
fn apid(&self) -> u16 {
|
||||||
|
self.packet_id().apid
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn ssc(&self) -> u16 {
|
||||||
|
self.psc().ssc
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn sequence_flags(&self) -> SequenceFlags {
|
||||||
|
// This call should never fail because the mask ensures that only valid values are passed
|
||||||
|
// into the try_from function
|
||||||
|
self.psc().seq_flags
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait CcsdsPrimaryHeader {
|
||||||
|
fn from_composite_fields(
|
||||||
|
packet_id: PacketId,
|
||||||
|
psc: PacketSequenceCtrl,
|
||||||
|
data_len: u16,
|
||||||
|
version: Option<u8>,
|
||||||
|
) -> Self;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod srd {
|
||||||
|
use crate::{
|
||||||
|
CcsdsPacket, CcsdsPrimaryHeader, PacketId, PacketSequenceCtrl, PacketType,
|
||||||
|
SequenceFlags,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Space Packet Primary Header according to CCSDS 133.0-B-2
|
||||||
|
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Copy, Clone)]
|
||||||
|
pub struct SpHeader {
|
||||||
|
pub version: u8,
|
||||||
|
pub packet_id: PacketId,
|
||||||
|
pub psc: PacketSequenceCtrl,
|
||||||
|
pub data_len: u16,
|
||||||
|
}
|
||||||
|
impl Default for SpHeader {
|
||||||
|
fn default() -> Self {
|
||||||
|
SpHeader {
|
||||||
|
version: 0,
|
||||||
|
packet_id: PacketId {
|
||||||
|
ptype: PacketType::Tm,
|
||||||
|
apid: 0,
|
||||||
|
sec_header_flag: true,
|
||||||
|
},
|
||||||
|
psc: PacketSequenceCtrl {
|
||||||
|
seq_flags: SequenceFlags::Unsegmented,
|
||||||
|
ssc: 0,
|
||||||
|
},
|
||||||
|
data_len: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl SpHeader {
|
||||||
|
pub fn new(apid: u16, ptype: PacketType, ssc: u16) -> Option<Self> {
|
||||||
|
if ssc > num::pow(2, 14) || apid > num::pow(2, 11) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let mut header = SpHeader::default();
|
||||||
|
header.packet_id.apid = apid;
|
||||||
|
header.packet_id.ptype = ptype;
|
||||||
|
header.psc.ssc = ssc;
|
||||||
|
Some(header)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn tm(apid: u16, ssc: u16) -> Option<Self> {
|
||||||
|
Self::new(apid, PacketType::Tm, ssc)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn tc(apid: u16, ssc: u16) -> Option<Self> {
|
||||||
|
Self::new(apid, PacketType::Tc, ssc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CcsdsPacket for SpHeader {
|
||||||
|
#[inline]
|
||||||
|
fn version(&self) -> u8 {
|
||||||
|
self.version
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn packet_id(&self) -> PacketId {
|
||||||
|
self.packet_id
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn psc(&self) -> PacketSequenceCtrl {
|
||||||
|
self.psc
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn data_len(&self) -> u16 {
|
||||||
|
self.data_len
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CcsdsPrimaryHeader for SpHeader {
|
||||||
|
fn from_composite_fields(
|
||||||
|
packet_id: PacketId,
|
||||||
|
psc: PacketSequenceCtrl,
|
||||||
|
data_len: u16,
|
||||||
|
version: Option<u8>,
|
||||||
|
) -> Self {
|
||||||
|
let mut version_to_set = 0b000;
|
||||||
|
if let Some(version) = version {
|
||||||
|
version_to_set = version;
|
||||||
|
}
|
||||||
|
SpHeader {
|
||||||
|
version: version_to_set,
|
||||||
|
packet_id,
|
||||||
|
psc,
|
||||||
|
data_len,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sph_from_other!(SpHeader, crate::zc::SpHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod zc {
|
||||||
|
use crate::{
|
||||||
|
CcsdsPacket, CcsdsPrimaryHeader, PacketId, PacketSequenceCtrl, VERSION_MASK,
|
||||||
|
};
|
||||||
|
use zerocopy::byteorder::NetworkEndian;
|
||||||
|
use zerocopy::{AsBytes, FromBytes, Unaligned, U16};
|
||||||
|
|
||||||
|
#[derive(FromBytes, AsBytes, Unaligned, Debug)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct SpHeader {
|
||||||
|
version_packet_id: U16<NetworkEndian>,
|
||||||
|
psc: U16<NetworkEndian>,
|
||||||
|
data_len: U16<NetworkEndian>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SpHeader {
|
||||||
|
pub fn new(
|
||||||
|
packet_id: PacketId,
|
||||||
|
psc: PacketSequenceCtrl,
|
||||||
|
data_len: u16,
|
||||||
|
version: Option<u8>,
|
||||||
|
) -> Self {
|
||||||
|
let mut version_packet_id = packet_id.raw();
|
||||||
|
if let Some(version) = version {
|
||||||
|
version_packet_id = ((version as u16) << 13) | packet_id.raw()
|
||||||
|
}
|
||||||
|
SpHeader {
|
||||||
|
version_packet_id: U16::from(version_packet_id),
|
||||||
|
psc: U16::from(psc.raw()),
|
||||||
|
data_len: U16::from(data_len),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_bytes(slice: impl AsRef<[u8]>) -> Option<Self> {
|
||||||
|
SpHeader::read_from(slice.as_ref())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_bytes(&self, mut slice: impl AsMut<[u8]>) -> Option<()> {
|
||||||
|
self.write_to(slice.as_mut())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CcsdsPacket for SpHeader {
|
||||||
|
#[inline]
|
||||||
|
fn version(&self) -> u8 {
|
||||||
|
((self.version_packet_id.get() >> 13) as u8) & 0b111
|
||||||
|
}
|
||||||
|
|
||||||
|
fn packet_id_raw(&self) -> u16 {
|
||||||
|
self.version_packet_id.get() & (!VERSION_MASK)
|
||||||
|
}
|
||||||
|
fn packet_id(&self) -> PacketId {
|
||||||
|
PacketId::from(self.packet_id_raw())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn psc_raw(&self) -> u16 {
|
||||||
|
self.psc.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn psc(&self) -> PacketSequenceCtrl {
|
||||||
|
PacketSequenceCtrl::from(self.psc_raw())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn data_len(&self) -> u16 {
|
||||||
|
self.data_len.get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CcsdsPrimaryHeader for SpHeader {
|
||||||
|
fn from_composite_fields(
|
||||||
|
packet_id: PacketId,
|
||||||
|
psc: PacketSequenceCtrl,
|
||||||
|
data_len: u16,
|
||||||
|
version: Option<u8>,
|
||||||
|
) -> Self {
|
||||||
|
SpHeader::new(packet_id, psc, data_len, version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sph_from_other!(SpHeader, crate::srd::SpHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::srd::SpHeader;
|
||||||
|
use crate::{zc, CcsdsPacket, PacketId, PacketSequenceCtrl, PacketType, SequenceFlags};
|
||||||
|
use postcard::{from_bytes, to_stdvec};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_helpers() {
|
||||||
|
let packet_id = PacketId {
|
||||||
|
ptype: PacketType::Tm,
|
||||||
|
sec_header_flag: false,
|
||||||
|
apid: 0x42,
|
||||||
|
};
|
||||||
|
assert_eq!(packet_id.raw(), 0x42);
|
||||||
|
let packet_id_from_raw = PacketId::from(packet_id.raw());
|
||||||
|
assert_eq!(packet_id_from_raw, packet_id);
|
||||||
|
|
||||||
|
let packet_id_invalid = PacketId::new(PacketType::Tc, true, 0xFFFF);
|
||||||
|
assert!(packet_id_invalid.is_none());
|
||||||
|
let packet_id_from_new = PacketId::new(PacketType::Tm, false, 0x42).unwrap();
|
||||||
|
assert_eq!(packet_id_from_new, packet_id);
|
||||||
|
let psc = PacketSequenceCtrl {
|
||||||
|
seq_flags: SequenceFlags::ContinuationSegment,
|
||||||
|
ssc: 77,
|
||||||
|
};
|
||||||
|
assert_eq!(psc.raw(), 77);
|
||||||
|
let psc_from_raw = PacketSequenceCtrl::from(psc.raw());
|
||||||
|
assert_eq!(psc_from_raw, psc);
|
||||||
|
|
||||||
|
let psc_invalid = PacketSequenceCtrl::new(SequenceFlags::FirstSegment, 0xFFFF);
|
||||||
|
assert!(psc_invalid.is_none());
|
||||||
|
let psc_from_new = PacketSequenceCtrl::new(SequenceFlags::ContinuationSegment, 77).unwrap();
|
||||||
|
assert_eq!(psc_from_new, psc);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_deser_internally() {
|
||||||
|
let sp_header = SpHeader::tc(0x42, 12).expect("Error creating SP header");
|
||||||
|
assert_eq!(sp_header.version(), 0b000);
|
||||||
|
assert!(sp_header.is_tc());
|
||||||
|
assert!(sp_header.sec_header_flag());
|
||||||
|
assert_eq!(sp_header.ptype(), PacketType::Tc);
|
||||||
|
assert_eq!(sp_header.ssc(), 12);
|
||||||
|
assert_eq!(sp_header.apid(), 0x42);
|
||||||
|
assert_eq!(sp_header.sequence_flags(), SequenceFlags::Unsegmented);
|
||||||
|
assert_eq!(sp_header.data_len(), 0);
|
||||||
|
let output = to_stdvec(&sp_header).unwrap();
|
||||||
|
let sp_header: SpHeader = from_bytes(&output).unwrap();
|
||||||
|
assert_eq!(sp_header.version, 0b000);
|
||||||
|
assert!(sp_header.packet_id.sec_header_flag);
|
||||||
|
assert_eq!(sp_header.ptype(), PacketType::Tc);
|
||||||
|
assert_eq!(sp_header.ssc(), 12);
|
||||||
|
assert_eq!(sp_header.apid(), 0x42);
|
||||||
|
assert_eq!(sp_header.sequence_flags(), SequenceFlags::Unsegmented);
|
||||||
|
assert_eq!(sp_header.packet_id_raw(), 0x1842);
|
||||||
|
assert_eq!(sp_header.psc_raw(), 0xC00C);
|
||||||
|
assert_eq!(sp_header.version(), 0b000);
|
||||||
|
assert_eq!(sp_header.data_len, 0);
|
||||||
|
|
||||||
|
let mut sp_header = SpHeader::tm(0x7, 22).expect("Error creating SP header");
|
||||||
|
sp_header.data_len = 36;
|
||||||
|
assert_eq!(sp_header.version(), 0b000);
|
||||||
|
assert!(sp_header.is_tm());
|
||||||
|
assert!(sp_header.sec_header_flag());
|
||||||
|
assert_eq!(sp_header.ptype(), PacketType::Tm);
|
||||||
|
assert_eq!(sp_header.ssc(), 22);
|
||||||
|
assert_eq!(sp_header.apid(), 0x07);
|
||||||
|
assert_eq!(sp_header.sequence_flags(), SequenceFlags::Unsegmented);
|
||||||
|
assert_eq!(sp_header.packet_id_raw(), 0x0807);
|
||||||
|
assert_eq!(sp_header.psc_raw(), 0xC016);
|
||||||
|
assert_eq!(sp_header.data_len(), 36);
|
||||||
|
assert_eq!(sp_header.version(), 0b000);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_deser_zerocopy() {
|
||||||
|
use zerocopy::AsBytes;
|
||||||
|
|
||||||
|
let sp_header = SpHeader::tc(0x7FF, num::pow(2, 14) - 1).expect("Error creating SP header");
|
||||||
|
assert_eq!(sp_header.packet_id.ptype, PacketType::Tc);
|
||||||
|
assert!(sp_header.is_tc());
|
||||||
|
let sp_header_zc = zc::SpHeader::from(sp_header);
|
||||||
|
let slice = sp_header_zc.as_bytes();
|
||||||
|
assert_eq!(slice.len(), 6);
|
||||||
|
assert_eq!(slice[0], 0x1F);
|
||||||
|
assert_eq!(slice[1], 0xFF);
|
||||||
|
assert_eq!(slice[2], 0xFF);
|
||||||
|
assert_eq!(slice[3], 0xFF);
|
||||||
|
assert_eq!(slice[4], 0x00);
|
||||||
|
assert_eq!(slice[5], 0x00);
|
||||||
|
|
||||||
|
let mut slice = [0; 6];
|
||||||
|
sp_header_zc.write_to(slice.as_mut_slice());
|
||||||
|
assert_eq!(slice.len(), 6);
|
||||||
|
assert_eq!(slice[0], 0x1F);
|
||||||
|
assert_eq!(slice[1], 0xFF);
|
||||||
|
assert_eq!(slice[2], 0xFF);
|
||||||
|
assert_eq!(slice[3], 0xFF);
|
||||||
|
assert_eq!(slice[4], 0x00);
|
||||||
|
assert_eq!(slice[5], 0x00);
|
||||||
|
|
||||||
|
let mut test_vec = vec![0_u8; 6];
|
||||||
|
let slice = test_vec.as_mut_slice();
|
||||||
|
sp_header_zc.write_to(slice);
|
||||||
|
let slice = test_vec.as_slice();
|
||||||
|
assert_eq!(slice.len(), 6);
|
||||||
|
assert_eq!(slice[0], 0x1F);
|
||||||
|
assert_eq!(slice[1], 0xFF);
|
||||||
|
assert_eq!(slice[2], 0xFF);
|
||||||
|
assert_eq!(slice[3], 0xFF);
|
||||||
|
assert_eq!(slice[4], 0x00);
|
||||||
|
assert_eq!(slice[5], 0x00);
|
||||||
|
|
||||||
|
let sp_header = zc::SpHeader::from_bytes(slice);
|
||||||
|
assert!(sp_header.is_some());
|
||||||
|
let sp_header = sp_header.unwrap();
|
||||||
|
println!("Header: {:?}", sp_header);
|
||||||
|
assert_eq!(sp_header.version(), 0b000);
|
||||||
|
assert_eq!(sp_header.packet_id_raw(), 0x1FFF);
|
||||||
|
assert_eq!(sp_header.apid(), 0x7FF);
|
||||||
|
assert_eq!(sp_header.ptype(), PacketType::Tc);
|
||||||
|
assert_eq!(sp_header.data_len(), 0);
|
||||||
|
}
|
||||||
|
}
|
43
spacepackets/src/main.rs
Normal file
43
spacepackets/src/main.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
use postcard::to_stdvec;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use zerocopy::byteorder::{I32, U16};
|
||||||
|
use zerocopy::{AsBytes, FromBytes, NetworkEndian, Unaligned};
|
||||||
|
|
||||||
|
#[derive(AsBytes, FromBytes, Unaligned, Debug, Eq, PartialEq)]
|
||||||
|
#[repr(C, packed)]
|
||||||
|
struct ZeroCopyTest {
|
||||||
|
some_bool: u8,
|
||||||
|
some_u16: U16<NetworkEndian>,
|
||||||
|
some_i32: I32<NetworkEndian>,
|
||||||
|
some_float: [u8; 4],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||||
|
struct PostcardTest {
|
||||||
|
some_bool: u8,
|
||||||
|
some_u16: u16,
|
||||||
|
some_i32: i32,
|
||||||
|
some_float: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let pc_test = PostcardTest {
|
||||||
|
some_bool: true as u8,
|
||||||
|
some_u16: 0x42,
|
||||||
|
some_i32: -200,
|
||||||
|
some_float: 7.7_f32,
|
||||||
|
};
|
||||||
|
|
||||||
|
let out = to_stdvec(&pc_test).unwrap();
|
||||||
|
println!("{:#04x?}", out);
|
||||||
|
|
||||||
|
let sample_hk = ZeroCopyTest {
|
||||||
|
some_bool: true as u8,
|
||||||
|
some_u16: U16::from(0x42),
|
||||||
|
some_i32: I32::from(-200),
|
||||||
|
some_float: 7.7_f32.to_ne_bytes(),
|
||||||
|
};
|
||||||
|
let mut slice = [0; 11];
|
||||||
|
sample_hk.write_to(slice.as_mut_slice());
|
||||||
|
println!("{:#04x?}", slice);
|
||||||
|
}
|
163
spacepackets/src/tc.rs
Normal file
163
spacepackets/src/tc.rs
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
use crc::{Crc, CRC_16_IBM_3740};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// All PUS versions. Only PUS C is supported by this library
|
||||||
|
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]
|
||||||
|
pub enum PusVersion {
|
||||||
|
EsaPus = 0,
|
||||||
|
PusA = 1,
|
||||||
|
PusC = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const CRC_CCITT_FALSE: Crc<u16> = Crc::<u16>::new(&CRC_16_IBM_3740);
|
||||||
|
|
||||||
|
pub mod zc {
|
||||||
|
use zerocopy::{AsBytes, FromBytes, NetworkEndian, Unaligned, U16};
|
||||||
|
|
||||||
|
#[derive(FromBytes, AsBytes, Unaligned)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct PusTcDataFieldHeader {
|
||||||
|
version_ack: u8,
|
||||||
|
service: u8,
|
||||||
|
subservice: u8,
|
||||||
|
source_id: U16<NetworkEndian>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod srd {
|
||||||
|
use crate::ecss::PusPacket;
|
||||||
|
use crate::srd::SpHeader;
|
||||||
|
use crate::tc::{PusVersion, CRC_CCITT_FALSE};
|
||||||
|
use crate::{CcsdsPacket, PacketError, PacketId, PacketSequenceCtrl, PacketType};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct PusTcDataFieldHeader {
|
||||||
|
pub service: u8,
|
||||||
|
pub subservice: u8,
|
||||||
|
pub source_id: u16,
|
||||||
|
pub ack: u8,
|
||||||
|
pub version: PusVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PusTcDataFieldHeader {
|
||||||
|
pub fn new(service: u8, subservice: u8, ack: u8) -> Self {
|
||||||
|
PusTcDataFieldHeader {
|
||||||
|
service,
|
||||||
|
subservice,
|
||||||
|
ack,
|
||||||
|
source_id: 0,
|
||||||
|
version: PusVersion::PusC,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct PusTc<'slice> {
|
||||||
|
pub sph: SpHeader,
|
||||||
|
pub data_field_header: PusTcDataFieldHeader,
|
||||||
|
raw_data: Option<&'slice [u8]>,
|
||||||
|
app_data: Option<&'slice [u8]>,
|
||||||
|
crc16: Option<u16>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'slice> PusTc<'slice> {
|
||||||
|
pub fn new(
|
||||||
|
sph: &mut SpHeader,
|
||||||
|
service: u8,
|
||||||
|
subservice: u8,
|
||||||
|
app_data: Option<&'slice [u8]>,
|
||||||
|
) -> Self {
|
||||||
|
sph.packet_id.ptype = PacketType::Tc;
|
||||||
|
PusTc {
|
||||||
|
sph: *sph,
|
||||||
|
raw_data: None,
|
||||||
|
app_data,
|
||||||
|
data_field_header: PusTcDataFieldHeader::new(service, subservice, 0b1111),
|
||||||
|
crc16: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write(&mut self, mut slice: impl AsMut<[u8]>) -> Result<(), PacketError> {
|
||||||
|
let sph_zc = crate::zc::SpHeader::from(self.sph);
|
||||||
|
if slice.as_mut().len() < 6 {
|
||||||
|
return Err(PacketError::ToBytesSliceTooSmall(6));
|
||||||
|
}
|
||||||
|
sph_zc
|
||||||
|
.to_bytes(slice)
|
||||||
|
.ok_or(PacketError::ToBytesZeroCopyError)?;
|
||||||
|
// TODO: Finish impl
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl CcsdsPacket for PusTc<'_> {
|
||||||
|
fn version(&self) -> u8 {
|
||||||
|
self.sph.version
|
||||||
|
}
|
||||||
|
|
||||||
|
fn packet_id(&self) -> PacketId {
|
||||||
|
self.sph.packet_id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn psc(&self) -> PacketSequenceCtrl {
|
||||||
|
self.sph.psc
|
||||||
|
}
|
||||||
|
|
||||||
|
fn data_len(&self) -> u16 {
|
||||||
|
self.sph.data_len
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PusPacket for PusTc<'_> {
|
||||||
|
fn service(&self) -> u8 {
|
||||||
|
self.data_field_header.service
|
||||||
|
}
|
||||||
|
|
||||||
|
fn subservice(&self) -> u8 {
|
||||||
|
self.data_field_header.subservice
|
||||||
|
}
|
||||||
|
|
||||||
|
fn source_id(&self) -> u16 {
|
||||||
|
self.data_field_header.source_id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ack_flags(&self) -> u8 {
|
||||||
|
self.data_field_header.ack
|
||||||
|
}
|
||||||
|
|
||||||
|
fn user_data(&self) -> Option<&[u8]> {
|
||||||
|
self.app_data
|
||||||
|
}
|
||||||
|
|
||||||
|
fn crc16(&self) -> Option<u16> {
|
||||||
|
self.crc16
|
||||||
|
}
|
||||||
|
|
||||||
|
fn verify(&mut self) -> bool {
|
||||||
|
let mut digest = CRC_CCITT_FALSE.digest();
|
||||||
|
if self.raw_data.is_none() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
digest.update(self.raw_data.unwrap().as_ref());
|
||||||
|
if digest.finalize() == 0 {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::srd::SpHeader;
|
||||||
|
use crate::tc::srd::PusTc;
|
||||||
|
use postcard::to_stdvec;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tc() {
|
||||||
|
let mut sph = SpHeader::tc(0x42, 12).unwrap();
|
||||||
|
let pus_tc = PusTc::new(&mut sph, 1, 1, None);
|
||||||
|
let out = to_stdvec(&pus_tc).unwrap();
|
||||||
|
println!("Vector {:#04x?} with length {}", out, out.len());
|
||||||
|
}
|
||||||
|
}
|
1
spacepackets/src/tm.rs
Normal file
1
spacepackets/src/tm.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -1 +0,0 @@
|
|||||||
pub mod core;
|
|
@ -1 +0,0 @@
|
|||||||
fn main() {}
|
|
Loading…
Reference in New Issue
Block a user