Compare commits

...

7 Commits

Author SHA1 Message Date
Robin Mueller
e2fbc08545 continue updating embedded examples 2025-09-10 18:06:50 +02:00
2e58a311c8 Merge pull request 'CI fix and naming improvement' (#249) from example-ci-fix into main
Reviewed-on: #249
2025-09-06 19:40:17 +02:00
Robin Mueller
62d64e692a CI fix and naming improvement 2025-09-06 19:36:56 +02:00
3784f47b66 Merge pull request 'update heapless dependency' (#248) from update-deps into main
Reviewed-on: #248
2025-09-06 19:32:18 +02:00
Robin Mueller
e1911f1b6e update heapless dependency 2025-09-06 19:32:06 +02:00
2e53ce1871 Merge pull request 'update trait names' (#247) from update-trait-names into main
Reviewed-on: #247
2025-09-06 19:31:46 +02:00
Robin Mueller
a6c460129b update trait names 2025-09-06 19:26:39 +02:00
32 changed files with 1545 additions and 1065 deletions

View File

@@ -3,12 +3,21 @@
version = 4 version = 4
[[package]] [[package]]
name = "accelerometer" name = "aligned"
version = "0.12.0" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a4586d95cb0695e748760c9a751141eebb68265b1b20392a0f14db608679f7a" checksum = "377e4c0ba83e4431b10df45c1d4666f178ea9c552cac93e60c3a88bf32785923"
dependencies = [ dependencies = [
"micromath", "as-slice",
]
[[package]]
name = "as-slice"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516"
dependencies = [
"stable_deref_trait",
] ]
[[package]] [[package]]
@@ -23,7 +32,7 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
dependencies = [ dependencies = [
"rustc_version 0.2.3", "rustc_version",
] ]
[[package]] [[package]]
@@ -32,6 +41,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603"
[[package]]
name = "bit_field"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6"
[[package]] [[package]]
name = "bitfield" name = "bitfield"
version = "0.13.2" version = "0.13.2"
@@ -45,15 +60,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bxcan" name = "bitflags"
version = "0.7.0" version = "2.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40ac3d0c0a542d0ab5521211f873f62706a7136df415676f676d347e5a41dd80" checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
[[package]]
name = "block-device-driver"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c051592f59fe68053524b4c4935249b806f72c1f544cfb7abe4f57c3be258e"
dependencies = [ dependencies = [
"bitflags", "aligned",
"embedded-hal 0.2.7",
"nb 1.1.0",
"vcell",
] ]
[[package]] [[package]]
@@ -62,41 +80,17 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cast"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a"
dependencies = [
"rustc_version 0.4.1",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"
dependencies = [
"num-traits",
]
[[package]] [[package]]
name = "cobs" name = "cobs"
version = "0.2.3" 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 = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" checksum = "fea6d1b751c55bd9c0dda7d4ff752074e98f4765ae969664648bd193bb326d15"
[[package]]
name = "cobs"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
dependencies = [ dependencies = [
"thiserror", "thiserror",
] ]
@@ -200,29 +194,19 @@ dependencies = [
[[package]] [[package]]
name = "defmt" name = "defmt"
version = "0.3.10" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f6162c53f659f65d00619fe31f14556a6e9f8752ccc4a41bd177ffcf3d6130" checksum = "548d977b6da32fa1d1fda2876453da1e7df63ad0304c8b3dae4dbe7b96f39b78"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"defmt-macros", "defmt-macros",
] ]
[[package]]
name = "defmt-brtt"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2f0ac3635d0c89d12b8101fcb44a7625f5f030a1c0491124b74467eb5a58a78"
dependencies = [
"critical-section",
"defmt",
]
[[package]] [[package]]
name = "defmt-macros" name = "defmt-macros"
version = "0.4.0" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d135dd939bad62d7490b0002602d35b358dce5fd9233a709d3c1ef467d4bde6" checksum = "3d4fc12a85bcf441cfe44344c4b72d58493178ce635338a3f3b78943aceb258e"
dependencies = [ dependencies = [
"defmt-parser", "defmt-parser",
"proc-macro-error2", "proc-macro-error2",
@@ -233,18 +217,28 @@ dependencies = [
[[package]] [[package]]
name = "defmt-parser" name = "defmt-parser"
version = "0.4.1" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3983b127f13995e68c1e29071e5d115cd96f215ccb5e6812e3728cd6f92653b3" checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
dependencies = [ dependencies = [
"thiserror", "thiserror",
] ]
[[package]] [[package]]
name = "defmt-test" name = "defmt-rtt"
version = "0.3.2" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290966e8c38f94b11884877242de876280d0eab934900e9642d58868e77c5df1" checksum = "b2cac3b8a5644a9e02b75085ebad3b6deafdbdbdec04bb25086523828aa4dfd1"
dependencies = [
"critical-section",
"defmt",
]
[[package]]
name = "defmt-test"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24076cc7203c365e7febfcec15d6667a9ef780bd2c5fd3b2a197400df78f299b"
dependencies = [ dependencies = [
"cortex-m-rt", "cortex-m-rt",
"cortex-m-semihosting", "cortex-m-semihosting",
@@ -254,9 +248,9 @@ dependencies = [
[[package]] [[package]]
name = "defmt-test-macros" name = "defmt-test-macros"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "984bc6eca246389726ac2826acc2488ca0fe5fcd6b8d9b48797021951d76a125" checksum = "fe5520fd36862f281c026abeaab153ebbc001717c29a9b8e5ba9704d8f3a879d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -286,12 +280,140 @@ dependencies = [
] ]
[[package]] [[package]]
name = "embedded-dma" name = "document-features"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d"
dependencies = [
"litrs",
]
[[package]]
name = "embassy-embedded-hal"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "554e3e840696f54b4c9afcf28a0f24da431c927f4151040020416e7393d6d0d8"
dependencies = [
"embassy-futures",
"embassy-hal-internal",
"embassy-sync",
"embedded-hal 0.2.7",
"embedded-hal 1.0.0",
"embedded-hal-async",
"embedded-storage",
"embedded-storage-async",
"nb 1.1.0",
]
[[package]]
name = "embassy-futures"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc2d050bdc5c21e0862a89256ed8029ae6c290a93aecefc73084b3002cdebb01"
[[package]]
name = "embassy-hal-internal"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95285007a91b619dc9f26ea8f55452aa6c60f7115a4edc05085cd2bd3127cd7a"
dependencies = [
"cortex-m",
"critical-section",
"num-traits",
]
[[package]]
name = "embassy-net-driver"
version = "0.2.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "994f7e5b5cb23521c22304927195f236813053eb9c065dd2226a32ba64695446" checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d"
[[package]]
name = "embassy-stm32"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d972eab325cc96afee98f80a91ca6b00249b6356dc0fdbff68b70c200df9fae"
dependencies = [ dependencies = [
"stable_deref_trait", "aligned",
"bit_field",
"bitflags 2.9.4",
"block-device-driver",
"cfg-if",
"cortex-m",
"cortex-m-rt",
"critical-section",
"document-features",
"embassy-embedded-hal",
"embassy-futures",
"embassy-hal-internal",
"embassy-net-driver",
"embassy-sync",
"embassy-usb-driver",
"embassy-usb-synopsys-otg",
"embedded-can",
"embedded-hal 0.2.7",
"embedded-hal 1.0.0",
"embedded-hal-async",
"embedded-hal-nb",
"embedded-io",
"embedded-io-async",
"embedded-storage",
"embedded-storage-async",
"futures-util",
"nb 1.1.0",
"proc-macro2",
"quote",
"rand_core 0.6.4",
"rand_core 0.9.3",
"sdio-host",
"static_assertions",
"stm32-fmc",
"stm32-metapac",
"vcell",
"volatile-register",
]
[[package]]
name = "embassy-sync"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73974a3edbd0bd286759b3d483540f0ebef705919a5f56f4fc7709066f71689b"
dependencies = [
"cfg-if",
"critical-section",
"embedded-io-async",
"futures-core",
"futures-sink",
"heapless 0.8.0",
]
[[package]]
name = "embassy-usb-driver"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17119855ccc2d1f7470a39756b12068454ae27a3eabb037d940b5c03d9c77b7a"
dependencies = [
"embedded-io-async",
]
[[package]]
name = "embassy-usb-synopsys-otg"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "288751f8eaa44a5cf2613f13cee0ca8e06e6638cb96e897e6834702c79084b23"
dependencies = [
"critical-section",
"embassy-sync",
"embassy-usb-driver",
]
[[package]]
name = "embedded-can"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438"
dependencies = [
"nb 1.1.0",
] ]
[[package]] [[package]]
@@ -320,12 +442,43 @@ dependencies = [
] ]
[[package]] [[package]]
name = "embedded-time" name = "embedded-hal-nb"
version = "0.12.1" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7a4b4d10ac48d08bfe3db7688c402baadb244721f30a77ce360bd24c3dffe58" checksum = "fba4268c14288c828995299e59b12babdbe170f6c6d73731af1b4648142e8605"
dependencies = [ dependencies = [
"num", "embedded-hal 1.0.0",
"nb 1.1.0",
]
[[package]]
name = "embedded-io"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
[[package]]
name = "embedded-io-async"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f"
dependencies = [
"embedded-io",
]
[[package]]
name = "embedded-storage"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a21dea9854beb860f3062d10228ce9b976da520a73474aed3171ec276bc0c032"
[[package]]
name = "embedded-storage-async"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1763775e2323b7d5f0aa6090657f5e21cfa02ede71f5dc40eead06d64dcd15cc"
dependencies = [
"embedded-storage",
] ]
[[package]] [[package]]
@@ -376,6 +529,12 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
[[package]]
name = "futures-sink"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.31" version = "0.3.31"
@@ -400,25 +559,6 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a"
[[package]]
name = "generic-array"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "667f6ea017b297ec65b8a108c6e9ad6879460721fb3b6b23abf690970147fc28"
dependencies = [
"typenum",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]] [[package]]
name = "hash32" name = "hash32"
version = "0.3.1" version = "0.3.1"
@@ -444,6 +584,16 @@ dependencies = [
"stable_deref_trait", "stable_deref_trait",
] ]
[[package]]
name = "heapless"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1edcd5a338e64688fbdcb7531a846cfd3476a54784dcb918a0844682bc7ada5"
dependencies = [
"hash32",
"stable_deref_trait",
]
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"
@@ -461,24 +611,10 @@ dependencies = [
] ]
[[package]] [[package]]
name = "lsm303dlhc" name = "litrs"
version = "0.2.0" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e5d1a5c290951321d1b0d4a40edd828537de9889134a0e67c5146542ae57706" checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed"
dependencies = [
"cast",
"embedded-hal 0.2.7",
"generic-array 0.11.2",
]
[[package]]
name = "micromath"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc4010833aea396656c2f91ee704d51a6f1329ec2ab56ffd00bfd56f7481ea94"
dependencies = [
"generic-array 0.14.7",
]
[[package]] [[package]]
name = "nb" name = "nb"
@@ -495,59 +631,6 @@ 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 = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d"
[[package]]
name = "num"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f"
dependencies = [
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5"
dependencies = [
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
dependencies = [
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.19" version = "0.2.19"
@@ -579,9 +662,9 @@ dependencies = [
[[package]] [[package]]
name = "panic-probe" name = "panic-probe"
version = "0.3.2" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4047d9235d1423d66cc97da7d07eddb54d4f154d6c13805c6d0793956f4f25b0" checksum = "fd402d00b0fb94c5aee000029204a46884b1262e0c443f166d86d2c0747e1a1a"
dependencies = [ dependencies = [
"cortex-m", "cortex-m",
"defmt", "defmt",
@@ -652,13 +735,16 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rtcc" name = "rand_core"
version = "0.3.2" version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95973c3a0274adc4f3c5b70d2b5b85618d6de9559a6737d3293ecae9a2fc0839" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"chrono", [[package]]
] name = "rand_core"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
[[package]] [[package]]
name = "rtic" name = "rtic"
@@ -735,42 +821,27 @@ 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 = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [ dependencies = [
"semver 0.9.0", "semver",
]
[[package]]
name = "rustc_version"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
dependencies = [
"semver 1.0.25",
] ]
[[package]] [[package]]
name = "satrs" name = "satrs"
version = "0.2.1" version = "0.3.0-alpha.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "866fcae3b683ccc37b5ad77982483a0ee01d5dc408dea5aad2117ad404b60fe1"
dependencies = [ dependencies = [
"cobs 0.2.3", "cobs",
"crc",
"defmt", "defmt",
"delegate", "delegate",
"derive-new", "derive-new",
"num-traits",
"num_enum", "num_enum",
"paste", "paste",
"satrs-shared", "satrs-shared",
"smallvec",
"spacepackets", "spacepackets",
"thiserror",
] ]
[[package]] [[package]]
name = "satrs-shared" name = "satrs-shared"
version = "0.1.4" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6042477018c2d43fffccaaa5099bc299a58485139b4d31c5b276889311e474f1"
dependencies = [ dependencies = [
"spacepackets", "spacepackets",
] ]
@@ -779,24 +850,31 @@ dependencies = [
name = "satrs-stm32f3-disco-rtic" name = "satrs-stm32f3-disco-rtic"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cobs 0.3.0", "cobs",
"cortex-m", "cortex-m",
"cortex-m-rt", "cortex-m-rt",
"cortex-m-semihosting", "cortex-m-semihosting",
"defmt", "defmt",
"defmt-brtt", "defmt-rtt",
"defmt-test", "defmt-test",
"embedded-hal 0.2.7", "embassy-stm32",
"embedded-hal 1.0.0",
"enumset", "enumset",
"heapless", "heapless 0.9.1",
"panic-probe", "panic-probe",
"rtic", "rtic",
"rtic-monotonics", "rtic-monotonics",
"satrs", "satrs",
"stm32f3-discovery", "spacepackets",
"stm32f3xx-hal", "static_cell",
] ]
[[package]]
name = "sdio-host"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b328e2cb950eeccd55b7f55c3a963691455dcd044cfb5354f0c5e68d2c2d6ee2"
[[package]] [[package]]
name = "semver" name = "semver"
version = "0.9.0" version = "0.9.0"
@@ -806,41 +884,25 @@ dependencies = [
"semver-parser", "semver-parser",
] ]
[[package]]
name = "semver"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03"
[[package]] [[package]]
name = "semver-parser" name = "semver-parser"
version = "0.7.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "slice-group-by"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7"
[[package]]
name = "smallvec"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]] [[package]]
name = "spacepackets" name = "spacepackets"
version = "0.11.2" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e85574d113a06312010c0ba51aadccd4ba2806231ebe9a49fc6473d0534d8696" checksum = "95ca19d2a251259686f6fffb094a8e32824098f387cd613ae81bfe4216524d02"
dependencies = [ dependencies = [
"crc", "crc",
"defmt", "defmt",
"delegate", "delegate",
"num-traits", "num-traits",
"num_enum", "num_enum",
"paste",
"thiserror",
"zerocopy", "zerocopy",
] ]
@@ -851,74 +913,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]] [[package]]
name = "stm32-usbd" name = "static_assertions"
version = "0.6.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 = "c6c94998f166d66b210a164648a0b7866428d8f1e0740bf8a4c5edd89d4750c1" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
dependencies = [
"cortex-m",
"usb-device",
"vcell",
]
[[package]] [[package]]
name = "stm32f3" name = "static_cell"
version = "0.15.1" version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b28b37228ef3fa47956af38c6abd756e912f244c1657f14e66d42fc8d74ea96f" checksum = "0530892bb4fa575ee0da4b86f86c667132a94b74bb72160f58ee5a4afec74c23"
dependencies = [ dependencies = [
"bare-metal 1.0.0", "portable-atomic",
"cortex-m",
"cortex-m-rt",
"vcell",
] ]
[[package]] [[package]]
name = "stm32f3-discovery" name = "stm32-fmc"
version = "0.8.0-alpha.0" version = "0.3.2"
source = "git+https://github.com/robamu/stm32f3-discovery?branch=complete-dma-update-hal#5ccacae07ceff02d7d3649df67a6a0ba2a144752"
dependencies = [
"accelerometer",
"cortex-m",
"cortex-m-rt",
"lsm303dlhc",
"stm32f3xx-hal",
"switch-hal",
]
[[package]]
name = "stm32f3xx-hal"
version = "0.11.0-alpha.0"
source = "git+https://github.com/robamu/stm32f3xx-hal?branch=complete-dma-update#04fc76b7912649c84b57bd0ab803ea3ccf2aadae"
dependencies = [
"bxcan",
"cfg-if",
"cortex-m",
"cortex-m-rt",
"critical-section",
"embedded-dma",
"embedded-hal 0.2.7",
"embedded-time",
"enumset",
"nb 1.1.0",
"num-traits",
"paste",
"rtcc",
"slice-group-by",
"stm32-usbd",
"stm32f3",
"void",
]
[[package]]
name = "switch-hal"
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 = "90a4adc8cbd1726249b161898e48e0f3f1ce74d34dc784cbbc98fba4ed283fbf" checksum = "c7f0639399e2307c2446c54d91d4f1596343a1e1d5cab605b9cce11d0ab3858c"
dependencies = [ dependencies = [
"embedded-hal 0.2.7", "embedded-hal 0.2.7",
] ]
[[package]]
name = "stm32-metapac"
version = "18.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fd8ec3a292a0d9fc4798416a61b21da5ae50341b2e7b8d12e662bf305366097"
dependencies = [
"cortex-m",
"cortex-m-rt",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "1.0.109"
@@ -961,36 +988,18 @@ dependencies = [
"syn 2.0.96", "syn 2.0.96",
] ]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.16" version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034"
[[package]]
name = "usb-device"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508"
[[package]] [[package]]
name = "vcell" name = "vcell"
version = "0.1.3" version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]] [[package]]
name = "void" name = "void"
version = "1.0.2" version = "1.0.2"
@@ -1008,19 +1017,18 @@ dependencies = [
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.35" version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
dependencies = [ dependencies = [
"byteorder",
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.7.35" version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@@ -9,13 +9,16 @@ default-run = "satrs-stm32f3-disco-rtic"
[dependencies] [dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"] } cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7" cortex-m-rt = "0.7"
defmt = "0.3" defmt = "1"
defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] } defmt-rtt = { version = "1" }
panic-probe = { version = "0.3", features = ["print-defmt"] } panic-probe = { version = "1", features = ["print-defmt"] }
embedded-hal = "0.2.7" embedded-hal = "1"
cortex-m-semihosting = "0.5.0" cortex-m-semihosting = "0.5.0"
embassy-stm32 = { version = "0.4", features = ["stm32f303vc", "unstable-pac"] }
enumset = "1" enumset = "1"
heapless = "0.8" heapless = "0.9"
spacepackets = { version = "0.15", default-features = false, features = ["defmt"] }
static_cell = "2"
[dependencies.rtic] [dependencies.rtic]
version = "2" version = "2"
@@ -26,32 +29,32 @@ version = "2"
features = ["cortex-m-systick"] features = ["cortex-m-systick"]
[dependencies.cobs] [dependencies.cobs]
version = "0.3" version = "0.4"
default-features = false default-features = false
[dependencies.stm32f3xx-hal] # [dependencies.stm32f3xx-hal]
git = "https://github.com/robamu/stm32f3xx-hal" # git = "https://github.com/robamu/stm32f3xx-hal"
version = "0.11.0-alpha.0" # version = "0.11.0-alpha.0"
features = ["stm32f303xc", "rt", "enumset"] # features = ["stm32f303xc", "rt", "enumset"]
branch = "complete-dma-update" # branch = "complete-dma-update"
# Can be used in workspace to develop and update HAL # Can be used in workspace to develop and update HAL
# path = "../stm32f3xx-hal" # path = "../stm32f3xx-hal"
[dependencies.stm32f3-discovery] # [dependencies.stm32f3-discovery]
git = "https://github.com/robamu/stm32f3-discovery" # git = "https://github.com/robamu/stm32f3-discovery"
version = "0.8.0-alpha.0" # version = "0.8.0-alpha.0"
branch = "complete-dma-update-hal" # branch = "complete-dma-update-hal"
# Can be used in workspace to develop and update BSP # Can be used in workspace to develop and update BSP
# path = "../stm32f3-discovery" # path = "../stm32f3-discovery"
[dependencies.satrs] [dependencies.satrs]
# path = "satrs" # version = "0.2"
version = "0.2" path = "../../satrs"
default-features = false default-features = false
features = ["defmt"] features = ["defmt"]
[dev-dependencies] [dev-dependencies]
defmt-test = "0.3" defmt-test = "0.4"
# cargo test # cargo test
[profile.test] [profile.test]

View File

@@ -1,76 +1,61 @@
#![no_std]
#![no_main] #![no_main]
use satrs_stm32f3_disco_rtic as _; #![no_std]
use stm32f3_discovery::leds::Leds; use panic_probe as _;
use stm32f3_discovery::stm32f3xx_hal::delay::Delay; use rtic::app;
use stm32f3_discovery::stm32f3xx_hal::{pac, prelude::*};
use stm32f3_discovery::switch_hal::{OutputSwitch, ToggleableOutputSwitch};
#[cortex_m_rt::entry] #[app(device = embassy_stm32)]
fn main() -> ! { mod app {
defmt::println!("STM32F3 Discovery Blinky"); use rtic_monotonics::fugit::ExtU32;
let dp = pac::Peripherals::take().unwrap(); use rtic_monotonics::Monotonic as _;
let mut rcc = dp.RCC.constrain(); use satrs_stm32f3_disco_rtic::{Direction, LedPinSet, Leds};
let cp = cortex_m::Peripherals::take().unwrap();
let mut flash = dp.FLASH.constrain();
let clocks = rcc.cfgr.freeze(&mut flash.acr);
let mut delay = Delay::new(cp.SYST, clocks);
let mut gpioe = dp.GPIOE.split(&mut rcc.ahb); rtic_monotonics::systick_monotonic!(Mono, 1000);
let mut leds = Leds::new(
gpioe.pe8,
gpioe.pe9,
gpioe.pe10,
gpioe.pe11,
gpioe.pe12,
gpioe.pe13,
gpioe.pe14,
gpioe.pe15,
&mut gpioe.moder,
&mut gpioe.otyper,
);
let delay_ms = 200u16;
loop {
leds.ld3_n.toggle().ok();
delay.delay_ms(delay_ms);
leds.ld3_n.toggle().ok();
delay.delay_ms(delay_ms);
//explicit on/off #[shared]
leds.ld4_nw.on().ok(); struct Shared {}
delay.delay_ms(delay_ms);
leds.ld4_nw.off().ok();
delay.delay_ms(delay_ms);
leds.ld5_ne.on().ok(); #[local]
delay.delay_ms(delay_ms); struct Local {
leds.ld5_ne.off().ok(); leds: Leds,
delay.delay_ms(delay_ms); current_dir: Direction,
}
leds.ld6_w.on().ok(); #[init]
delay.delay_ms(delay_ms); fn init(cx: init::Context) -> (Shared, Local) {
leds.ld6_w.off().ok(); let p = embassy_stm32::init(Default::default());
delay.delay_ms(delay_ms);
leds.ld7_e.on().ok(); defmt::info!("Starting sat-rs demo application for the STM32F3-Discovery using RTICv2");
delay.delay_ms(delay_ms);
leds.ld7_e.off().ok();
delay.delay_ms(delay_ms);
leds.ld8_sw.on().ok(); let led_pin_set = LedPinSet {
delay.delay_ms(delay_ms); pin_n: p.PE8,
leds.ld8_sw.off().ok(); pin_ne: p.PE9,
delay.delay_ms(delay_ms); pin_e: p.PE10,
pin_se: p.PE11,
pin_s: p.PE12,
pin_sw: p.PE13,
pin_w: p.PE14,
pin_nw: p.PE15,
};
let leds = Leds::new(led_pin_set);
leds.ld9_se.on().ok(); // Initialize the systick interrupt & obtain the token to prove that we did
delay.delay_ms(delay_ms); Mono::start(cx.core.SYST, 8_000_000);
leds.ld9_se.off().ok(); blinky::spawn().expect("failed to spawn blinky task");
delay.delay_ms(delay_ms); (
Shared {},
Local {
leds,
current_dir: Direction::North,
},
)
}
leds.ld10_s.on().ok(); #[task(local = [leds, current_dir])]
delay.delay_ms(delay_ms); async fn blinky(cx: blinky::Context) {
leds.ld10_s.off().ok(); loop {
delay.delay_ms(delay_ms); cx.local.leds.blink_next(cx.local.current_dir);
Mono::delay(200.millis()).await;
}
} }
} }

View File

@@ -3,12 +3,147 @@
use cortex_m_semihosting::debug; use cortex_m_semihosting::debug;
use defmt_brtt as _; // global logger use defmt_rtt as _; // global logger
use stm32f3xx_hal as _; // memory layout
use panic_probe as _; use panic_probe as _;
use embassy_stm32::gpio::Output;
#[derive(defmt::Format, PartialEq, Eq, Clone, Copy)]
pub enum Direction {
North,
NorthEast,
East,
SouthEast,
South,
SouthWest,
West,
NorthWest,
}
impl Direction {
pub fn switch_to_next(&mut self) -> (Self, Self) {
let curr = *self;
*self = match self {
Direction::North => Direction::NorthEast,
Direction::NorthEast => Direction::East,
Direction::East => Direction::SouthEast,
Direction::SouthEast => Direction::South,
Direction::South => Direction::SouthWest,
Direction::SouthWest => Direction::West,
Direction::West => Direction::NorthWest,
Direction::NorthWest => Direction::North,
};
(curr, *self)
}
}
pub struct Leds {
pub north: Output<'static>,
pub north_east: Output<'static>,
pub east: Output<'static>,
pub south_east: Output<'static>,
pub south: Output<'static>,
pub south_west: Output<'static>,
pub west: Output<'static>,
pub north_west: Output<'static>,
}
impl Leds {
pub fn blink_next(&mut self, current_dir: &mut Direction) {
let (prev, curr) = current_dir.switch_to_next();
self.set_dir_low(prev);
self.set_dir_high(curr);
}
pub fn set_dir(&mut self, dir: Direction, level: embassy_stm32::gpio::Level) {
match dir {
Direction::North => self.north.set_level(level),
Direction::NorthEast => self.north_east.set_level(level),
Direction::East => self.east.set_level(level),
Direction::SouthEast => self.south_east.set_level(level),
Direction::South => self.south.set_level(level),
Direction::SouthWest => self.south_west.set_level(level),
Direction::West => self.west.set_level(level),
Direction::NorthWest => self.north_west.set_level(level),
}
}
pub fn set_dir_low(&mut self, dir: Direction) {
self.set_dir(dir, embassy_stm32::gpio::Level::Low);
}
pub fn set_dir_high(&mut self, dir: Direction) {
self.set_dir(dir, embassy_stm32::gpio::Level::High);
}
}
pub struct LedPinSet {
pub pin_n: embassy_stm32::Peri<'static, embassy_stm32::peripherals::PE8>,
pub pin_ne: embassy_stm32::Peri<'static, embassy_stm32::peripherals::PE9>,
pub pin_e: embassy_stm32::Peri<'static, embassy_stm32::peripherals::PE10>,
pub pin_se: embassy_stm32::Peri<'static, embassy_stm32::peripherals::PE11>,
pub pin_s: embassy_stm32::Peri<'static, embassy_stm32::peripherals::PE12>,
pub pin_sw: embassy_stm32::Peri<'static, embassy_stm32::peripherals::PE13>,
pub pin_w: embassy_stm32::Peri<'static, embassy_stm32::peripherals::PE14>,
pub pin_nw: embassy_stm32::Peri<'static, embassy_stm32::peripherals::PE15>,
}
impl Leds {
pub fn new(pin_set: LedPinSet) -> Self {
let led_n = Output::new(
pin_set.pin_n,
embassy_stm32::gpio::Level::Low,
embassy_stm32::gpio::Speed::Medium,
);
let led_ne = Output::new(
pin_set.pin_ne,
embassy_stm32::gpio::Level::Low,
embassy_stm32::gpio::Speed::Medium,
);
let led_e = Output::new(
pin_set.pin_e,
embassy_stm32::gpio::Level::Low,
embassy_stm32::gpio::Speed::Medium,
);
let led_se = Output::new(
pin_set.pin_se,
embassy_stm32::gpio::Level::Low,
embassy_stm32::gpio::Speed::Medium,
);
let led_s = Output::new(
pin_set.pin_s,
embassy_stm32::gpio::Level::Low,
embassy_stm32::gpio::Speed::Medium,
);
let led_sw = Output::new(
pin_set.pin_sw,
embassy_stm32::gpio::Level::Low,
embassy_stm32::gpio::Speed::Medium,
);
let led_w = Output::new(
pin_set.pin_w,
embassy_stm32::gpio::Level::Low,
embassy_stm32::gpio::Speed::Medium,
);
let led_nw = Output::new(
pin_set.pin_nw,
embassy_stm32::gpio::Level::Low,
embassy_stm32::gpio::Speed::Medium,
);
Self {
north: led_n,
north_east: led_ne,
east: led_e,
south_east: led_se,
south: led_s,
south_west: led_sw,
west: led_w,
north_west: led_nw,
}
}
}
// same panicking *behavior* as `panic-probe` but doesn't print a panic message // same panicking *behavior* as `panic-probe` but doesn't print a panic message
// this prevents the panic message being printed *twice* when `defmt::panic` is invoked // this prevents the panic message being printed *twice* when `defmt::panic` is invoked
#[defmt::panic_handler] #[defmt::panic_handler]

View File

@@ -1,8 +1,6 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use satrs::pus::verification::{ use satrs::pus::verification::{FailParams, VerificationReportCreator};
FailParams, TcStateAccepted, VerificationReportCreator, VerificationToken,
};
use satrs::spacepackets::ecss::tc::PusTcReader; use satrs::spacepackets::ecss::tc::PusTcReader;
use satrs::spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader}; use satrs::spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
use satrs::spacepackets::ecss::EcssEnumU16; use satrs::spacepackets::ecss::EcssEnumU16;
@@ -13,16 +11,12 @@ use satrs_stm32f3_disco_rtic as _;
use rtic::app; use rtic::app;
use heapless::{mpmc::Q8, Vec}; use heapless::Vec;
#[allow(unused_imports)] #[allow(unused_imports)]
use rtic_monotonics::fugit::{MillisDurationU32, TimerInstantU32}; use rtic_monotonics::fugit::{MillisDurationU32, TimerInstantU32};
use rtic_monotonics::systick::prelude::*; use rtic_monotonics::systick::prelude::*;
use satrs::seq_count::SequenceCountProviderCore;
use satrs::spacepackets::{ecss::PusPacket, ecss::WritablePusPacket}; use satrs::spacepackets::{ecss::PusPacket, ecss::WritablePusPacket};
use stm32f3xx_hal::dma::dma1; use spacepackets::seq_count::SequenceCountProvider;
use stm32f3xx_hal::gpio::{PushPull, AF7, PA2, PA3};
use stm32f3xx_hal::pac::USART2;
use stm32f3xx_hal::serial::{Rx, RxEvent, Serial, SerialDmaRx, SerialDmaTx, Tx, TxEvent};
const UART_BAUD: u32 = 115200; const UART_BAUD: u32 = 115200;
const DEFAULT_BLINK_FREQ_MS: u32 = 1000; const DEFAULT_BLINK_FREQ_MS: u32 = 1000;
@@ -30,33 +24,24 @@ const TX_HANDLER_FREQ_MS: u32 = 20;
const MIN_DELAY_BETWEEN_TX_PACKETS_MS: u32 = 5; const MIN_DELAY_BETWEEN_TX_PACKETS_MS: u32 = 5;
const MAX_TC_LEN: usize = 128; const MAX_TC_LEN: usize = 128;
const MAX_TM_LEN: usize = 128; const MAX_TM_LEN: usize = 128;
pub const PUS_APID: u16 = 0x02;
type TxType = Tx<USART2, PA2<AF7<PushPull>>>; pub const PUS_APID: u16 = 0x02;
type RxType = Rx<USART2, PA3<AF7<PushPull>>>;
type InstantFugit = TimerInstantU32<1000>;
type TxDmaTransferType = SerialDmaTx<&'static [u8], dma1::C7, TxType>;
type RxDmaTransferType = SerialDmaRx<&'static mut [u8], dma1::C6, RxType>;
// This is the predictable maximum overhead of the COBS encoding scheme. // This is the predictable maximum overhead of the COBS encoding scheme.
// It is simply the maximum packet lenght dividied by 254 rounded up. // It is simply the maximum packet lenght dividied by 254 rounded up.
const COBS_TC_OVERHEAD: usize = (MAX_TC_LEN + 254 - 1) / 254; const COBS_TC_OVERHEAD: usize = cobs::max_encoding_overhead(MAX_TC_LEN);
const COBS_TM_OVERHEAD: usize = (MAX_TM_LEN + 254 - 1) / 254; const COBS_TM_OVERHEAD: usize = cobs::max_encoding_overhead(MAX_TM_LEN);
const TC_BUF_LEN: usize = MAX_TC_LEN + COBS_TC_OVERHEAD; const TC_BUF_LEN: usize = MAX_TC_LEN + COBS_TC_OVERHEAD;
const TM_BUF_LEN: usize = MAX_TC_LEN + COBS_TM_OVERHEAD; const TM_BUF_LEN: usize = MAX_TC_LEN + COBS_TM_OVERHEAD;
// This is a static buffer which should ONLY (!) be used as the TX DMA const TC_DMA_BUF_LEN: usize = 512;
// transfer buffer.
static mut DMA_TX_BUF: [u8; TM_BUF_LEN] = [0; TM_BUF_LEN];
// This is a static buffer which should ONLY (!) be used as the RX DMA
// transfer buffer.
static mut DMA_RX_BUF: [u8; TC_BUF_LEN] = [0; TC_BUF_LEN];
type TmPacket = Vec<u8, MAX_TM_LEN>; type TmPacket = heapless::Vec<u8, MAX_TM_LEN>;
type TcPacket = Vec<u8, MAX_TC_LEN>; type TcPacket = heapless::Vec<u8, MAX_TC_LEN>;
static TM_REQUESTS: Q8<TmPacket> = Q8::new(); static TM_REQUESTS: static_cell::ConstStaticCell<heapless::spsc::Queue<TmPacket, 8>> =
static_cell::ConstStaticCell::new(heapless::spsc::Queue::new());
use core::sync::atomic::{AtomicU16, Ordering}; use core::sync::atomic::{AtomicU16, Ordering};
@@ -74,7 +59,10 @@ impl SeqCountProviderAtomicRef {
} }
} }
impl SequenceCountProviderCore<u16> for SeqCountProviderAtomicRef { impl SequenceCountProvider for SeqCountProviderAtomicRef {
type Raw = u16;
const MAX_BIT_WIDTH: usize = 16;
fn get(&self) -> u16 { fn get(&self) -> u16 {
self.atomic.load(self.ordering) self.atomic.load(self.ordering)
} }
@@ -92,8 +80,8 @@ static SEQ_COUNT_PROVIDER: SeqCountProviderAtomicRef =
SeqCountProviderAtomicRef::new(Ordering::Relaxed); SeqCountProviderAtomicRef::new(Ordering::Relaxed);
pub struct TxIdle { pub struct TxIdle {
tx: TxType, //tx: TxType,
dma_channel: dma1::C7, //dma_channel: dma1::C7,
} }
#[derive(Debug, defmt::Format)] #[derive(Debug, defmt::Format)]
@@ -108,49 +96,8 @@ impl From<ByteConversionError> for TmSendError {
} }
} }
fn send_tm(tm_creator: PusTmCreator) -> Result<(), TmSendError> {
if tm_creator.len_written() > MAX_TM_LEN {
return Err(ByteConversionError::ToSliceTooSmall {
expected: tm_creator.len_written(),
found: MAX_TM_LEN,
}
.into());
}
let mut tm_vec = TmPacket::new();
tm_vec
.resize(tm_creator.len_written(), 0)
.expect("vec resize failed");
tm_creator.write_to_bytes(tm_vec.as_mut_slice())?;
defmt::info!(
"Sending TM[{},{}] with size {}",
tm_creator.service(),
tm_creator.subservice(),
tm_creator.len_written()
);
TM_REQUESTS
.enqueue(tm_vec)
.map_err(|_| TmSendError::Queue)?;
Ok(())
}
fn handle_tm_send_error(error: TmSendError) {
defmt::warn!("sending tm failed with error {}", error);
}
pub enum UartTxState {
// Wrapped in an option because we need an owned type later.
Idle(Option<TxIdle>),
// Same as above
Transmitting(Option<TxDmaTransferType>),
}
pub struct UartTxShared {
last_completed: Option<InstantFugit>,
state: UartTxState,
}
pub struct RequestWithToken { pub struct RequestWithToken {
token: VerificationToken<TcStateAccepted>, request_id: satrs::pus::verification::RequestId,
request: Request, request: Request,
} }
@@ -168,147 +115,69 @@ pub enum RequestError {
NotEnoughAppData = 4, NotEnoughAppData = 4,
} }
pub fn convert_pus_tc_to_request( #[app(device = embassy_stm32)]
tc: &PusTcReader,
verif_reporter: &mut VerificationReportCreator,
src_data_buf: &mut [u8],
timestamp: &[u8],
) -> Result<RequestWithToken, RequestError> {
defmt::info!(
"Found PUS TC [{},{}] with length {}",
tc.service(),
tc.subservice(),
tc.len_packed()
);
let token = verif_reporter.add_tc(tc);
if tc.apid() != PUS_APID {
defmt::warn!("Received tc with unknown APID {}", tc.apid());
let result = send_tm(
verif_reporter
.acceptance_failure(
src_data_buf,
token,
SEQ_COUNT_PROVIDER.get_and_increment(),
0,
FailParams::new(timestamp, &EcssEnumU16::new(0), &[]),
)
.unwrap(),
);
if let Err(e) = result {
handle_tm_send_error(e);
}
return Err(RequestError::InvalidApid);
}
let (tm_creator, accepted_token) = verif_reporter
.acceptance_success(
src_data_buf,
token,
SEQ_COUNT_PROVIDER.get_and_increment(),
0,
timestamp,
)
.unwrap();
if let Err(e) = send_tm(tm_creator) {
handle_tm_send_error(e);
}
if tc.service() == 17 && tc.subservice() == 1 {
if tc.subservice() == 1 {
return Ok(RequestWithToken {
request: Request::Ping,
token: accepted_token,
});
} else {
return Err(RequestError::InvalidSubservice);
}
} else if tc.service() == 8 {
if tc.subservice() == 1 {
if tc.user_data().len() < 4 {
return Err(RequestError::NotEnoughAppData);
}
let new_freq_ms = u32::from_be_bytes(tc.user_data()[0..4].try_into().unwrap());
return Ok(RequestWithToken {
request: Request::ChangeBlinkFrequency(new_freq_ms),
token: accepted_token,
});
} else {
return Err(RequestError::InvalidSubservice);
}
} else {
return Err(RequestError::InvalidService);
}
}
#[app(device = stm32f3xx_hal::pac, peripherals = true)]
mod app { mod app {
use super::*; use super::*;
use core::slice::Iter; use satrs::pus::verification::VerificationReportCreator;
use satrs::pus::verification::{TcStateStarted, VerificationReportCreator};
use satrs::spacepackets::{ecss::tc::PusTcReader, time::cds::P_FIELD_BASE}; use satrs::spacepackets::{ecss::tc::PusTcReader, time::cds::P_FIELD_BASE};
#[allow(unused_imports)] use satrs_stm32f3_disco_rtic::LedPinSet;
use stm32f3_discovery::leds::Direction;
use stm32f3_discovery::leds::Leds;
use stm32f3xx_hal::prelude::*;
use stm32f3_discovery::switch_hal::OutputSwitch;
use stm32f3xx_hal::Switch;
#[allow(dead_code)]
type SerialType = Serial<USART2, (PA2<AF7<PushPull>>, PA3<AF7<PushPull>>)>;
systick_monotonic!(Mono, 1000); systick_monotonic!(Mono, 1000);
embassy_stm32::bind_interrupts!(struct Irqs {
USART2 => embassy_stm32::usart::InterruptHandler<embassy_stm32::peripherals::USART2>;
});
#[shared] #[shared]
struct Shared { struct Shared {
blink_freq: MillisDurationU32, blink_freq: MillisDurationU32,
tx_shared: UartTxShared,
rx_transfer: Option<RxDmaTransferType>,
} }
#[local] #[local]
struct Local { struct Local {
verif_reporter: VerificationReportCreator, verif_reporter: VerificationReportCreator,
leds: Leds, leds: satrs_stm32f3_disco_rtic::Leds,
last_dir: Direction, current_dir: satrs_stm32f3_disco_rtic::Direction,
curr_dir: Iter<'static, Direction>, tm_prod: heapless::spsc::Producer<'static, TmPacket>,
tm_cons: heapless::spsc::Consumer<'static, TmPacket>,
tx: embassy_stm32::usart::UartTx<'static, embassy_stm32::mode::Async>,
rx: embassy_stm32::usart::RingBufferedUartRx<'static>,
} }
#[init] #[init]
fn init(cx: init::Context) -> (Shared, Local) { fn init(cx: init::Context) -> (Shared, Local) {
let mut rcc = cx.device.RCC.constrain(); static DMA_BUF: static_cell::ConstStaticCell<[u8; TC_DMA_BUF_LEN]> = static_cell::ConstStaticCell::new([0; TC_DMA_BUF_LEN]);
let p = embassy_stm32::init(Default::default());
// Initialize the systick interrupt & obtain the token to prove that we did // Initialize the systick interrupt & obtain the token to prove that we did
Mono::start(cx.core.SYST, 8_000_000); Mono::start(cx.core.SYST, 8_000_000);
let mut flash = cx.device.FLASH.constrain(); defmt::info!("Starting sat-rs demo application for the STM32F3-Discovery with RTICv2");
let clocks = rcc let led_pin_set = LedPinSet {
.cfgr pin_n: p.PE8,
.use_hse(8.MHz()) pin_ne: p.PE9,
.sysclk(8.MHz()) pin_e: p.PE10,
.pclk1(8.MHz()) pin_se: p.PE11,
.freeze(&mut flash.acr); pin_s: p.PE12,
pin_sw: p.PE13,
pin_w: p.PE14,
pin_nw: p.PE15,
};
let leds = satrs_stm32f3_disco_rtic::Leds::new(led_pin_set);
// Set up monotonic timer. let config = embassy_stm32::usart::Config::default();
//let mono_timer = MonoTimer::new(cx.core.DWT, clocks, &mut cx.core.DCB); let uart = embassy_stm32::usart::Uart::new(
p.USART2, p.PA3, p.PA2, Irqs, p.DMA1_CH7, p.DMA1_CH6, config,
)
.unwrap();
defmt::info!("Starting sat-rs demo application for the STM32F3-Discovery"); let (tx, rx) = uart.split();
let mut gpioe = cx.device.GPIOE.split(&mut rcc.ahb); let tm_queue = TM_REQUESTS.take();
let (tm_prod, tm_cons) = tm_queue.split();
let leds = Leds::new( //let mut gpioa = cx.device.GPIOA.split(&mut rcc.ahb);
gpioe.pe8,
gpioe.pe9,
gpioe.pe10,
gpioe.pe11,
gpioe.pe12,
gpioe.pe13,
gpioe.pe14,
gpioe.pe15,
&mut gpioe.moder,
&mut gpioe.otyper,
);
let mut gpioa = cx.device.GPIOA.split(&mut rcc.ahb);
// USART2 pins // USART2 pins
/*
let mut pins = ( let mut pins = (
// TX pin: PA2 // TX pin: PA2
gpioa gpioa
@@ -319,29 +188,32 @@ mod app {
.pa3 .pa3
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrl), .into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrl),
); );
pins.1.internal_pull_up(&mut gpioa.pupdr, true); */
let mut usart2 = Serial::new( //pins.1.internal_pull_up(&mut gpioa.pupdr, true);
cx.device.USART2, /*
pins, let mut usart2 = Serial::new(
UART_BAUD.Bd(), cx.device.USART2,
clocks, pins,
&mut rcc.apb1, UART_BAUD.Bd(),
); clocks,
usart2.configure_rx_interrupt(RxEvent::Idle, Switch::On); &mut rcc.apb1,
// This interrupt is enabled to re-schedule new transfers in the interrupt handler immediately. );
usart2.configure_tx_interrupt(TxEvent::TransmissionComplete, Switch::On); usart2.configure_rx_interrupt(RxEvent::Idle, Switch::On);
// This interrupt is enabled to re-schedule new transfers in the interrupt handler immediately.
usart2.configure_tx_interrupt(TxEvent::TransmissionComplete, Switch::On);
*/
let dma1 = cx.device.DMA1.split(&mut rcc.ahb); //let dma1 = cx.device.DMA1.split(&mut rcc.ahb);
let (mut tx_serial, mut rx_serial) = usart2.split(); //let (mut tx_serial, mut rx_serial) = usart2.split();
// This interrupt is immediately triggered, clear it. It will only be reset // This interrupt is immediately triggered, clear it. It will only be reset
// by the hardware when data is received on RX (RXNE event) // by the hardware when data is received on RX (RXNE event)
rx_serial.clear_event(RxEvent::Idle); //rx_serial.clear_event(RxEvent::Idle);
// For some reason, this is also immediately triggered.. // For some reason, this is also immediately triggered..
tx_serial.clear_event(TxEvent::TransmissionComplete); //tx_serial.clear_event(TxEvent::TransmissionComplete);
let rx_transfer = rx_serial.read_exact(unsafe { DMA_RX_BUF.as_mut_slice() }, dma1.ch6); //let rx_transfer = rx_serial.read_exact(unsafe { DMA_RX_BUF.as_mut_slice() }, dma1.ch6);
defmt::info!("Spawning tasks"); defmt::info!("Spawning tasks");
blink::spawn().unwrap(); blinky::spawn().unwrap();
serial_tx_handler::spawn().unwrap(); serial_tx_handler::spawn().unwrap();
let verif_reporter = VerificationReportCreator::new(PUS_APID).unwrap(); let verif_reporter = VerificationReportCreator::new(PUS_APID).unwrap();
@@ -349,118 +221,49 @@ mod app {
( (
Shared { Shared {
blink_freq: MillisDurationU32::from_ticks(DEFAULT_BLINK_FREQ_MS), blink_freq: MillisDurationU32::from_ticks(DEFAULT_BLINK_FREQ_MS),
tx_shared: UartTxShared {
last_completed: None,
state: UartTxState::Idle(Some(TxIdle {
tx: tx_serial,
dma_channel: dma1.ch7,
})),
},
rx_transfer: Some(rx_transfer),
}, },
Local { Local {
verif_reporter, verif_reporter,
leds, leds,
last_dir: Direction::North, tm_prod,
curr_dir: Direction::iter(), tm_cons,
tx,
rx: rx.into_ring_buffered(DMA_BUF.take()),
current_dir: satrs_stm32f3_disco_rtic::Direction::North,
}, },
) )
} }
#[task(local = [leds, curr_dir, last_dir], shared=[blink_freq])] #[task(local = [leds, current_dir], shared=[blink_freq])]
async fn blink(mut cx: blink::Context) { async fn blinky(mut cx: blinky::Context) {
let blink::LocalResources {
leds,
curr_dir,
last_dir,
..
} = cx.local;
let mut toggle_leds = |dir: &Direction| {
let last_led = leds.for_direction(*last_dir);
last_led.off().ok();
let led = leds.for_direction(*dir);
led.on().ok();
*last_dir = *dir;
};
loop { loop {
match curr_dir.next() { cx.local.leds.blink_next(cx.local.current_dir);
Some(dir) => {
toggle_leds(dir);
}
None => {
*curr_dir = Direction::iter();
toggle_leds(curr_dir.next().unwrap());
}
}
let current_blink_freq = cx.shared.blink_freq.lock(|current| *current); let current_blink_freq = cx.shared.blink_freq.lock(|current| *current);
Mono::delay(current_blink_freq).await; Mono::delay(current_blink_freq).await;
} }
} }
#[task( #[task(
shared = [tx_shared], local = [
tm_cons,
tx,
dma_buf: [u8; TM_BUF_LEN] = [0; TM_BUF_LEN]
],
shared = [],
)] )]
async fn serial_tx_handler(mut cx: serial_tx_handler::Context) { async fn serial_tx_handler(cx: serial_tx_handler::Context) {
loop { loop {
let is_idle = cx.shared.tx_shared.lock(|tx_shared| { while let Some(vec) = cx.local.tm_cons.dequeue() {
if let UartTxState::Idle(_) = tx_shared.state { cx.local.dma_buf[0] = 0;
return true; let encoded_len = cobs::encode(&vec[0..vec.len()], &mut cx.local.dma_buf[1..]);
} // Should never panic, we accounted for the overhead.
false // Write into transfer buffer directly, no need for intermediate
}); // encoding buffer.
if is_idle { // 0 end marker
let last_completed = cx.shared.tx_shared.lock(|shared| shared.last_completed); cx.local.dma_buf[encoded_len + 1] = 0;
if let Some(last_completed) = last_completed { cx.local.tx.write(&vec[0..encoded_len + 2]).await.unwrap();
let elapsed_ms = (Mono::now() - last_completed).to_millis();
if elapsed_ms < MIN_DELAY_BETWEEN_TX_PACKETS_MS {
Mono::delay((MIN_DELAY_BETWEEN_TX_PACKETS_MS - elapsed_ms).millis()).await;
}
}
} else {
// Check for completion after 1 ms
Mono::delay(1.millis()).await;
continue; continue;
} }
if let Some(vec) = TM_REQUESTS.dequeue() {
cx.shared
.tx_shared
.lock(|tx_shared| match &mut tx_shared.state {
UartTxState::Idle(tx) => {
let encoded_len;
//debug!(target: "serial_tx_handler", "bytes: {:x?}", &buf[0..len]);
// Safety: We only copy the data into the TX DMA buffer in this task.
// If the DMA is active, another branch will be taken.
unsafe {
// 0 sentinel value as start marker
DMA_TX_BUF[0] = 0;
encoded_len =
cobs::encode(&vec[0..vec.len()], &mut DMA_TX_BUF[1..]);
// Should never panic, we accounted for the overhead.
// Write into transfer buffer directly, no need for intermediate
// encoding buffer.
// 0 end marker
DMA_TX_BUF[encoded_len + 1] = 0;
}
//debug!(target: "serial_tx_handler", "Sending {} bytes", encoded_len + 2);
//debug!("sent: {:x?}", &mut_tx_dma_buf[0..encoded_len + 2]);
let tx_idle = tx.take().unwrap();
// Transfer completion and re-scheduling of new TX transfers will be done
// by the IRQ handler.
// SAFETY: The DMA is the exclusive writer to the DMA buffer now.
let transfer = tx_idle.tx.write_all(
unsafe { &DMA_TX_BUF[0..encoded_len + 2] },
tx_idle.dma_channel,
);
tx_shared.state = UartTxState::Transmitting(Some(transfer));
// The memory block is automatically returned to the pool when it is dropped.
}
UartTxState::Transmitting(_) => (),
});
// Check for completion after 1 ms
Mono::delay(1.millis()).await;
continue;
}
// Nothing to do, and we are idle.
Mono::delay(TX_HANDLER_FREQ_MS.millis()).await; Mono::delay(TX_HANDLER_FREQ_MS.millis()).await;
} }
} }
@@ -468,6 +271,9 @@ mod app {
#[task( #[task(
local = [ local = [
verif_reporter, verif_reporter,
tm_prod,
rx,
read_buf: [u8; 128] = [0; 128],
decode_buf: [u8; MAX_TC_LEN] = [0; MAX_TC_LEN], decode_buf: [u8; MAX_TC_LEN] = [0; MAX_TC_LEN],
src_data_buf: [u8; MAX_TM_LEN] = [0; MAX_TM_LEN], src_data_buf: [u8; MAX_TM_LEN] = [0; MAX_TM_LEN],
timestamp: [u8; 7] = [0; 7], timestamp: [u8; 7] = [0; 7],
@@ -478,6 +284,18 @@ mod app {
mut cx: serial_rx_handler::Context, mut cx: serial_rx_handler::Context,
received_packet: Vec<u8, MAX_TC_LEN>, received_packet: Vec<u8, MAX_TC_LEN>,
) { ) {
let decoder = cobs::CobsDecoder::new(cx.local.decode_buf);
loop {
let read_bytes = cx.local.rx.read(cx.local.read_buf).await;
match decoder.push(&cx.local.read_buf[0..read_bytes]) {
Ok(None) => (),
Ok(Some(report)) => {
}
Err(_) => {},
}
}
cx.local.timestamp[0] = P_FIELD_BASE; cx.local.timestamp[0] = P_FIELD_BASE;
defmt::info!("Received packet with {} bytes", received_packet.len()); defmt::info!("Received packet with {} bytes", received_packet.len());
let decode_buf = cx.local.decode_buf; let decode_buf = cx.local.decode_buf;
@@ -494,21 +312,24 @@ mod app {
return; return;
} }
let start_idx = start_idx.unwrap(); let start_idx = start_idx.unwrap();
decoder.push(data)
match cobs::decode(&received_packet.as_slice()[start_idx..], decode_buf) { match cobs::decode(&received_packet.as_slice()[start_idx..], decode_buf) {
Ok(len) => { Ok(decode_report) => {
defmt::info!("Decoded packet length: {}", len); defmt::info!("Decoded packet length: {}", decode_report.frame_size());
let pus_tc = PusTcReader::new(decode_buf); let pus_tc = PusTcReader::new(decode_buf);
match pus_tc { match pus_tc {
Ok((tc, _tc_len)) => { Ok(tc) => {
match convert_pus_tc_to_request( match convert_pus_tc_to_request(
&tc, &tc,
cx.local.verif_reporter, cx.local.verif_reporter,
cx.local.tm_prod,
cx.local.src_data_buf, cx.local.src_data_buf,
cx.local.timestamp, cx.local.timestamp,
) { ) {
Ok(request_with_token) => { Ok(request_with_token) => {
let started_token = handle_start_verification( handle_start_verification(
request_with_token.token, request_with_token.request_id,
cx.local.tm_prod,
cx.local.verif_reporter, cx.local.verif_reporter,
cx.local.src_data_buf, cx.local.src_data_buf,
cx.local.timestamp, cx.local.timestamp,
@@ -516,7 +337,7 @@ mod app {
match request_with_token.request { match request_with_token.request {
Request::Ping => { Request::Ping => {
handle_ping_request(cx.local.timestamp); handle_ping_request(cx.local.tm_prod, cx.local.timestamp);
} }
Request::ChangeBlinkFrequency(new_freq_ms) => { Request::ChangeBlinkFrequency(new_freq_ms) => {
defmt::info!("Received blink frequency change request with new frequncy {}", new_freq_ms); defmt::info!("Received blink frequency change request with new frequncy {}", new_freq_ms);
@@ -527,7 +348,8 @@ mod app {
} }
} }
handle_completion_verification( handle_completion_verification(
started_token, request_with_token.request_id,
cx.local.tm_prod,
cx.local.verif_reporter, cx.local.verif_reporter,
cx.local.src_data_buf, cx.local.src_data_buf,
cx.local.timestamp, cx.local.timestamp,
@@ -550,7 +372,10 @@ mod app {
} }
} }
fn handle_ping_request(timestamp: &[u8]) { fn handle_ping_request(
tm_prod: &mut heapless::spsc::Producer<'static, TmPacket>,
timestamp: &[u8],
) {
defmt::info!("Received PUS ping telecommand, sending ping reply TM[17,2]"); defmt::info!("Received PUS ping telecommand, sending ping reply TM[17,2]");
let sp_header = let sp_header =
SpHeader::new_for_unseg_tc(PUS_APID, SEQ_COUNT_PROVIDER.get_and_increment(), 0); SpHeader::new_for_unseg_tc(PUS_APID, SEQ_COUNT_PROVIDER.get_and_increment(), 0);
@@ -561,36 +386,36 @@ mod app {
.resize(ping_reply.len_written(), 0) .resize(ping_reply.len_written(), 0)
.expect("vec resize failed"); .expect("vec resize failed");
ping_reply.write_to_bytes(&mut tm_packet).unwrap(); ping_reply.write_to_bytes(&mut tm_packet).unwrap();
if TM_REQUESTS.enqueue(tm_packet).is_err() { if tm_prod.enqueue(tm_packet).is_err() {
defmt::warn!("TC queue full"); defmt::warn!("TC queue full");
return;
} }
} }
fn handle_start_verification( fn handle_start_verification(
accepted_token: VerificationToken<TcStateAccepted>, request_id: satrs::pus::verification::RequestId,
tm_prod: &mut heapless::spsc::Producer<TmPacket>,
verif_reporter: &mut VerificationReportCreator, verif_reporter: &mut VerificationReportCreator,
src_data_buf: &mut [u8], src_data_buf: &mut [u8],
timestamp: &[u8], timestamp: &[u8],
) -> VerificationToken<TcStateStarted> { ) {
let (tm_creator, started_token) = verif_reporter let tm_creator = verif_reporter
.start_success( .start_success(
src_data_buf, src_data_buf,
accepted_token, &request_id,
SEQ_COUNT_PROVIDER.get(), SEQ_COUNT_PROVIDER.get(),
0, 0,
&timestamp, timestamp,
) )
.unwrap(); .unwrap();
let result = send_tm(tm_creator); let result = send_tm(tm_creator, tm_prod);
if let Err(e) = result { if let Err(e) = result {
handle_tm_send_error(e); handle_tm_send_error(e);
} }
started_token
} }
fn handle_completion_verification( fn handle_completion_verification(
started_token: VerificationToken<TcStateStarted>, request_id: satrs::pus::verification::RequestId,
tm_prod: &mut heapless::spsc::Producer<TmPacket>,
verif_reporter: &mut VerificationReportCreator, verif_reporter: &mut VerificationReportCreator,
src_data_buf: &mut [u8], src_data_buf: &mut [u8],
timestamp: &[u8], timestamp: &[u8],
@@ -599,20 +424,23 @@ mod app {
verif_reporter verif_reporter
.completion_success( .completion_success(
src_data_buf, src_data_buf,
started_token, &request_id,
SEQ_COUNT_PROVIDER.get(), SEQ_COUNT_PROVIDER.get(),
0, 0,
timestamp, timestamp,
) )
.unwrap(), .unwrap(),
tm_prod,
); );
if let Err(e) = result { if let Err(e) = result {
handle_tm_send_error(e); handle_tm_send_error(e);
} }
} }
#[task(binds = DMA1_CH6, shared = [rx_transfer])] /*
fn rx_dma_isr(mut cx: rx_dma_isr::Context) { #[task(binds = DMA1_CH6, shared = [])]
fn rx_dma_isr(cx: rx_dma_isr::Context) {
/*
let mut tc_packet = TcPacket::new(); let mut tc_packet = TcPacket::new();
cx.shared.rx_transfer.lock(|rx_transfer| { cx.shared.rx_transfer.lock(|rx_transfer| {
let rx_ref = rx_transfer.as_ref().unwrap(); let rx_ref = rx_transfer.as_ref().unwrap();
@@ -638,45 +466,156 @@ mod app {
); );
} }
}); });
*/
}
*/
/*
#[task(binds = USART2_EXTI26, shared = [])]
fn serial_isr(mut cx: serial_isr::Context) {
/*
cx.shared
.tx_shared
.lock(|tx_shared| match &mut tx_shared.state {
UartTxState::Idle(_) => (),
UartTxState::Transmitting(transfer) => {
let transfer_ref = transfer.as_ref().unwrap();
if transfer_ref.is_complete() {
let transfer = transfer.take().unwrap();
let (_, dma_channel, mut tx) = transfer.stop();
tx.clear_event(TxEvent::TransmissionComplete);
tx_shared.state = UartTxState::Idle(Some(TxIdle { tx, dma_channel }));
// We cache the last completed time to ensure that there is a minimum delay between consecutive
// transferred packets.
tx_shared.last_completed = Some(Mono::now());
}
}
});
let mut tc_packet = TcPacket::new();
cx.shared.rx_transfer.lock(|rx_transfer| {
let rx_transfer_ref = rx_transfer.as_ref().unwrap();
// Received a partial packet.
if rx_transfer_ref.is_event_triggered(RxEvent::Idle) {
let rx_transfer_owned = rx_transfer.take().unwrap();
let (buf, ch, mut rx, rx_len) = rx_transfer_owned.stop_and_return_received_bytes();
// The received data is transferred to another task now to avoid any processing overhead
// during the interrupt. There are multiple ways to do this, we use a stack
// allocated vector to do this.
tc_packet
.resize(rx_len as usize, 0)
.expect("vec resize failed");
tc_packet[0..rx_len as usize].copy_from_slice(&buf[0..rx_len as usize]);
rx.clear_event(RxEvent::Idle);
serial_rx_handler::spawn(tc_packet).expect("spawning rx handler failed");
*rx_transfer = Some(rx.read_exact(buf, ch));
}
});
*/
}
*/
}
fn send_tm(
tm_creator: PusTmCreator,
tm_prod: &mut heapless::spsc::Producer<TmPacket>,
) -> Result<(), TmSendError> {
if tm_creator.len_written() > MAX_TM_LEN {
return Err(ByteConversionError::ToSliceTooSmall {
expected: tm_creator.len_written(),
found: MAX_TM_LEN,
}
.into());
}
let mut tm_vec = TmPacket::new();
tm_vec
.resize(tm_creator.len_written(), 0)
.expect("vec resize failed");
tm_creator.write_to_bytes(tm_vec.as_mut_slice())?;
defmt::info!(
"Sending TM[{},{}] with size {}",
tm_creator.service(),
tm_creator.subservice(),
tm_creator.len_written()
);
tm_prod.enqueue(tm_vec).map_err(|_| TmSendError::Queue)?;
Ok(())
}
fn handle_tm_send_error(error: TmSendError) {
defmt::warn!("sending tm failed with error {}", error);
}
pub fn convert_pus_tc_to_request(
tc: &PusTcReader,
verif_reporter: &mut VerificationReportCreator,
tm_prod: &mut heapless::spsc::Producer<'static, TmPacket>,
src_data_buf: &mut [u8],
timestamp: &[u8],
) -> Result<RequestWithToken, RequestError> {
defmt::info!(
"Found PUS TC [{},{}] with length {}",
tc.service(),
tc.subservice(),
tc.len_packed()
);
let request_id = verif_reporter.read_request_id(tc);
if tc.apid() != PUS_APID {
defmt::warn!("Received tc with unknown APID {}", tc.apid());
let result = send_tm(
verif_reporter
.acceptance_failure(
src_data_buf,
&request_id,
SEQ_COUNT_PROVIDER.get_and_increment(),
0,
FailParams::new(timestamp, &EcssEnumU16::new(0), &[]),
)
.unwrap(),
tm_prod,
);
if let Err(e) = result {
handle_tm_send_error(e);
}
return Err(RequestError::InvalidApid);
}
let tm_creator = verif_reporter
.acceptance_success(
src_data_buf,
&request_id,
SEQ_COUNT_PROVIDER.get_and_increment(),
0,
timestamp,
)
.unwrap();
if let Err(e) = send_tm(tm_creator, tm_prod) {
handle_tm_send_error(e);
} }
#[task(binds = USART2_EXTI26, shared = [rx_transfer, tx_shared])] if tc.service() == 17 && tc.subservice() == 1 {
fn serial_isr(mut cx: serial_isr::Context) { if tc.subservice() == 1 {
cx.shared Ok(RequestWithToken {
.tx_shared request_id,
.lock(|tx_shared| match &mut tx_shared.state { request: Request::Ping,
UartTxState::Idle(_) => (), })
UartTxState::Transmitting(transfer) => { } else {
let transfer_ref = transfer.as_ref().unwrap(); Err(RequestError::InvalidSubservice)
if transfer_ref.is_complete() { }
let transfer = transfer.take().unwrap(); } else if tc.service() == 8 {
let (_, dma_channel, mut tx) = transfer.stop(); if tc.subservice() == 1 {
tx.clear_event(TxEvent::TransmissionComplete); if tc.user_data().len() < 4 {
tx_shared.state = UartTxState::Idle(Some(TxIdle { tx, dma_channel })); return Err(RequestError::NotEnoughAppData);
// We cache the last completed time to ensure that there is a minimum delay between consecutive
// transferred packets.
tx_shared.last_completed = Some(Mono::now());
}
}
});
let mut tc_packet = TcPacket::new();
cx.shared.rx_transfer.lock(|rx_transfer| {
let rx_transfer_ref = rx_transfer.as_ref().unwrap();
// Received a partial packet.
if rx_transfer_ref.is_event_triggered(RxEvent::Idle) {
let rx_transfer_owned = rx_transfer.take().unwrap();
let (buf, ch, mut rx, rx_len) = rx_transfer_owned.stop_and_return_received_bytes();
// The received data is transferred to another task now to avoid any processing overhead
// during the interrupt. There are multiple ways to do this, we use a stack
// allocated vector to do this.
tc_packet
.resize(rx_len as usize, 0)
.expect("vec resize failed");
tc_packet[0..rx_len as usize].copy_from_slice(&buf[0..rx_len as usize]);
rx.clear_event(RxEvent::Idle);
serial_rx_handler::spawn(tc_packet).expect("spawning rx handler failed");
*rx_transfer = Some(rx.read_exact(buf, ch));
} }
}); let new_freq_ms = u32::from_be_bytes(tc.user_data()[0..4].try_into().unwrap());
Ok(RequestWithToken {
request_id,
request: Request::ChangeBlinkFrequency(new_freq_ms),
})
} else {
Err(RequestError::InvalidSubservice)
}
} else {
Err(RequestError::InvalidService)
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -16,16 +16,17 @@ harness = false
[dependencies] [dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"] } cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7" cortex-m-rt = "0.7"
defmt = "0.3" defmt = "1"
defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] } defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] }
panic-probe = { version = "0.3", features = ["print-defmt"] } panic-probe = { version = "1", features = ["print-defmt"] }
cortex-m-semihosting = "0.5.0" cortex-m-semihosting = "0.5.0"
# TODO: Replace with embassy-hal.
stm32h7xx-hal = { version="0.16", features= ["stm32h743v", "ethernet"] } stm32h7xx-hal = { version="0.16", features= ["stm32h743v", "ethernet"] }
embedded-alloc = "0.6" embedded-alloc = "0.6"
rtic-sync = { version = "1", features = ["defmt-03"] } rtic-sync = { version = "1", features = ["defmt-03"] }
[dependencies.smoltcp] [dependencies.smoltcp]
version = "0.11" version = "0.12"
default-features = false default-features = false
features = ["medium-ethernet", "proto-ipv4", "socket-raw", "socket-dhcpv4", "socket-udp", "defmt"] features = ["medium-ethernet", "proto-ipv4", "socket-raw", "socket-dhcpv4", "socket-udp", "defmt"]
@@ -39,12 +40,12 @@ features = ["cortex-m-systick"]
[dependencies.satrs] [dependencies.satrs]
path = "../../satrs" path = "../../satrs"
version = "0.2" # version = "0.2"
default-features = false default-features = false
features = ["defmt", "heapless"] features = ["defmt", "heapless"]
[dev-dependencies] [dev-dependencies]
defmt-test = "0.3" defmt-test = "0.4"
# cargo build/run # cargo build/run
[profile.dev] [profile.dev]

View File

@@ -2,7 +2,7 @@ use std::sync::mpsc::{self};
use crate::pus::create_verification_reporter; use crate::pus::create_verification_reporter;
use satrs::event_man::{EventMessageU32, EventRoutingError}; use satrs::event_man::{EventMessageU32, EventRoutingError};
use satrs::pus::event::EventTmHookProvider; use satrs::pus::event::EventTmHook;
use satrs::pus::verification::VerificationReporter; use satrs::pus::verification::VerificationReporter;
use satrs::pus::EcssTmSender; use satrs::pus::EcssTmSender;
use satrs::request::UniqueApidTargetId; use satrs::request::UniqueApidTargetId;
@@ -26,7 +26,7 @@ pub struct EventApidSetter {
pub next_apid: u16, pub next_apid: u16,
} }
impl EventTmHookProvider for EventApidSetter { impl EventTmHook for EventApidSetter {
fn modify_tm(&self, tm: &mut satrs::spacepackets::ecss::tm::PusTmCreator) { fn modify_tm(&self, tm: &mut satrs::spacepackets::ecss::tm::PusTmCreator) {
tm.set_apid(self.next_apid); tm.set_apid(self.next_apid);
} }
@@ -219,7 +219,7 @@ impl<TmSender: EcssTmSender> EventHandler<TmSender> {
mod tests { mod tests {
use satrs::{ use satrs::{
events::EventU32, events::EventU32,
pus::verification::VerificationReporterCfg, pus::verification::VerificationReporterConfig,
spacepackets::{ spacepackets::{
ecss::{tm::PusTmReader, PusPacket}, ecss::{tm::PusTmReader, PusPacket},
CcsdsPacket, CcsdsPacket,
@@ -244,7 +244,7 @@ mod tests {
let (event_tx, event_rx) = mpsc::sync_channel(10); let (event_tx, event_rx) = mpsc::sync_channel(10);
let (_event_req_tx, event_req_rx) = mpsc::sync_channel(10); let (_event_req_tx, event_req_rx) = mpsc::sync_channel(10);
let (tm_sender, tm_receiver) = mpsc::channel(); let (tm_sender, tm_receiver) = mpsc::channel();
let verif_reporter_cfg = VerificationReporterCfg::new(0x05, 2, 2, 128).unwrap(); let verif_reporter_cfg = VerificationReporterConfig::new(0x05, 2, 2, 128).unwrap();
let verif_reporter = let verif_reporter =
VerificationReporter::new(PUS_EVENT_MANAGEMENT.id(), &verif_reporter_cfg); VerificationReporter::new(PUS_EVENT_MANAGEMENT.id(), &verif_reporter_cfg);
let mut event_manager = EventManagerWithBoundedMpsc::new(event_rx); let mut event_manager = EventManagerWithBoundedMpsc::new(event_rx);

View File

@@ -33,7 +33,7 @@ use satrs::{
hal::std::{tcp_server::ServerConfig, udp_server::UdpTcServer}, hal::std::{tcp_server::ServerConfig, udp_server::UdpTcServer},
mode::{Mode, ModeAndSubmode, ModeRequest, ModeRequestHandlerMpscBounded}, mode::{Mode, ModeAndSubmode, ModeRequest, ModeRequestHandlerMpscBounded},
mode_tree::connect_mode_nodes, mode_tree::connect_mode_nodes,
pus::{event_man::EventRequestWithToken, EcssTcInMemConverter, HandlingStatus}, pus::{event_man::EventRequestWithToken, EcssTcCacher, HandlingStatus},
request::{GenericMessage, MessageMetadata}, request::{GenericMessage, MessageMetadata},
spacepackets::time::{cds::CdsTime, TimeWriter}, spacepackets::time::{cds::CdsTime, TimeWriter},
}; };
@@ -57,12 +57,12 @@ use tmtc::{tc_source::TcSourceTask, tm_sink::TmSink};
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "heap_tmtc")] { if #[cfg(feature = "heap_tmtc")] {
use interface::udp::DynamicUdpTmHandler; use interface::udp::DynamicUdpTmHandler;
use satrs::pus::EcssTcInVecConverter; use satrs::pus::EcssTcVecCacher;
use tmtc::{tc_source::TcSourceTaskDynamic, tm_sink::TmSinkDynamic}; use tmtc::{tc_source::TcSourceTaskDynamic, tm_sink::TmSinkDynamic};
} else { } else {
use std::sync::RwLock; use std::sync::RwLock;
use interface::udp::StaticUdpTmHandler; use interface::udp::StaticUdpTmHandler;
use satrs::pus::EcssTcInSharedPoolConverter; use satrs::pus::EcssTcInSharedPoolCacher;
use satrs::tmtc::{PacketSenderWithSharedPool, SharedPacketPool}; use satrs::tmtc::{PacketSenderWithSharedPool, SharedPacketPool};
use satrs_example::config::pool::create_static_pools; use satrs_example::config::pool::create_static_pools;
use tmtc::{ use tmtc::{
@@ -143,9 +143,9 @@ fn main() {
let tc_sender_with_shared_pool = let tc_sender_with_shared_pool =
PacketSenderWithSharedPool::new(tc_source_tx, shared_tc_pool_wrapper.clone()); PacketSenderWithSharedPool::new(tc_source_tx, shared_tc_pool_wrapper.clone());
let tc_in_mem_converter = let tc_in_mem_converter =
EcssTcInMemConverter::Static(EcssTcInSharedPoolConverter::new(shared_tc_pool, 4096)); EcssTcCacher::Static(EcssTcInSharedPoolCacher::new(shared_tc_pool, 4096));
} else if #[cfg(feature = "heap_tmtc")] { } else if #[cfg(feature = "heap_tmtc")] {
let tc_in_mem_converter = EcssTcInMemConverter::Heap(EcssTcInVecConverter::default()); let tc_in_mem_converter = EcssTcCacher::Heap(EcssTcVecCacher::default());
} }
} }

View File

@@ -9,7 +9,7 @@ use satrs::pus::verification::{
VerificationReportingProvider, VerificationToken, VerificationReportingProvider, VerificationToken,
}; };
use satrs::pus::{ use satrs::pus::{
ActiveRequestProvider, EcssTcAndToken, EcssTcInMemConverter, EcssTmSender, EcssTmtcError, ActiveRequest, EcssTcAndToken, EcssTcCacher, EcssTmSender, EcssTmtcError,
GenericConversionError, MpscTcReceiver, PusPacketHandlingError, PusReplyHandler, GenericConversionError, MpscTcReceiver, PusPacketHandlingError, PusReplyHandler,
PusServiceHelper, PusTcToRequestConverter, PusServiceHelper, PusTcToRequestConverter,
}; };
@@ -208,7 +208,7 @@ impl PusTcToRequestConverter<ActivePusActionRequestStd, ActionRequest> for Actio
pub fn create_action_service( pub fn create_action_service(
tm_sender: TmTcSender, tm_sender: TmTcSender,
tc_in_mem_converter: EcssTcInMemConverter, tc_in_mem_converter: EcssTcCacher,
pus_action_rx: mpsc::Receiver<EcssTcAndToken>, pus_action_rx: mpsc::Receiver<EcssTcAndToken>,
action_router: GenericRequestRouter, action_router: GenericRequestRouter,
reply_receiver: mpsc::Receiver<GenericMessage<ActionReplyPus>>, reply_receiver: mpsc::Receiver<GenericMessage<ActionReplyPus>>,
@@ -274,7 +274,7 @@ mod tests {
TEST_APID, TEST_COMPONENT_ID_0, TEST_COMPONENT_ID_1, TEST_UNIQUE_ID_0, TEST_UNIQUE_ID_1, TEST_APID, TEST_COMPONENT_ID_0, TEST_COMPONENT_ID_1, TEST_UNIQUE_ID_0, TEST_UNIQUE_ID_1,
}; };
use satrs::pus::verification::test_util::TestVerificationReporter; use satrs::pus::verification::test_util::TestVerificationReporter;
use satrs::pus::{verification, EcssTcInVecConverter}; use satrs::pus::{verification, EcssTcVecCacher};
use satrs::request::MessageMetadata; use satrs::request::MessageMetadata;
use satrs::tmtc::PacketAsVec; use satrs::tmtc::PacketAsVec;
use satrs::ComponentId; use satrs::ComponentId;
@@ -325,7 +325,7 @@ mod tests {
pus_action_rx, pus_action_rx,
TmTcSender::Heap(tm_funnel_tx.clone()), TmTcSender::Heap(tm_funnel_tx.clone()),
verif_reporter, verif_reporter,
EcssTcInMemConverter::Heap(EcssTcInVecConverter::default()), EcssTcCacher::Heap(EcssTcVecCacher::default()),
), ),
ActionRequestConverter::default(), ActionRequestConverter::default(),
DefaultActiveActionRequestMap::default(), DefaultActiveActionRequestMap::default(),

View File

@@ -6,7 +6,7 @@ use satrs::pus::event_man::EventRequestWithToken;
use satrs::pus::event_srv::PusEventServiceHandler; use satrs::pus::event_srv::PusEventServiceHandler;
use satrs::pus::verification::VerificationReporter; use satrs::pus::verification::VerificationReporter;
use satrs::pus::{ use satrs::pus::{
DirectPusPacketHandlerResult, EcssTcAndToken, EcssTcInMemConverter, MpscTcReceiver, DirectPusPacketHandlerResult, EcssTcAndToken, EcssTcCacher, MpscTcReceiver,
PartialPusHandlingError, PusServiceHelper, PartialPusHandlingError, PusServiceHelper,
}; };
use satrs::spacepackets::ecss::PusServiceId; use satrs::spacepackets::ecss::PusServiceId;
@@ -16,7 +16,7 @@ use super::{DirectPusService, HandlingStatus};
pub fn create_event_service( pub fn create_event_service(
tm_sender: TmTcSender, tm_sender: TmTcSender,
tm_in_pool_converter: EcssTcInMemConverter, tm_in_pool_converter: EcssTcCacher,
pus_event_rx: mpsc::Receiver<EcssTcAndToken>, pus_event_rx: mpsc::Receiver<EcssTcAndToken>,
event_request_tx: mpsc::Sender<EventRequestWithToken>, event_request_tx: mpsc::Sender<EventRequestWithToken>,
) -> EventServiceWrapper { ) -> EventServiceWrapper {
@@ -36,12 +36,8 @@ pub fn create_event_service(
} }
pub struct EventServiceWrapper { pub struct EventServiceWrapper {
pub handler: PusEventServiceHandler< pub handler:
MpscTcReceiver, PusEventServiceHandler<MpscTcReceiver, TmTcSender, EcssTcCacher, VerificationReporter>,
TmTcSender,
EcssTcInMemConverter,
VerificationReporter,
>,
} }
impl DirectPusService for EventServiceWrapper { impl DirectPusService for EventServiceWrapper {

View File

@@ -5,9 +5,9 @@ use satrs::pus::verification::{
VerificationReportingProvider, VerificationToken, VerificationReportingProvider, VerificationToken,
}; };
use satrs::pus::{ use satrs::pus::{
ActivePusRequestStd, ActiveRequestProvider, DefaultActiveRequestMap, EcssTcAndToken, ActivePusRequestStd, ActiveRequest, DefaultActiveRequestMap, EcssTcAndToken, EcssTcCacher,
EcssTcInMemConverter, EcssTmSender, EcssTmtcError, GenericConversionError, MpscTcReceiver, EcssTmSender, EcssTmtcError, GenericConversionError, MpscTcReceiver, PusPacketHandlingError,
PusPacketHandlingError, PusReplyHandler, PusServiceHelper, PusTcToRequestConverter, PusReplyHandler, PusServiceHelper, PusTcToRequestConverter,
}; };
use satrs::request::{GenericMessage, UniqueApidTargetId}; use satrs::request::{GenericMessage, UniqueApidTargetId};
use satrs::res_code::ResultU16; use satrs::res_code::ResultU16;
@@ -242,7 +242,7 @@ impl PusTcToRequestConverter<ActivePusRequestStd, HkRequest> for HkRequestConver
pub fn create_hk_service( pub fn create_hk_service(
tm_sender: TmTcSender, tm_sender: TmTcSender,
tc_in_mem_converter: EcssTcInMemConverter, tc_in_mem_converter: EcssTcCacher,
pus_hk_rx: mpsc::Receiver<EcssTcAndToken>, pus_hk_rx: mpsc::Receiver<EcssTcAndToken>,
request_router: GenericRequestRouter, request_router: GenericRequestRouter,
reply_receiver: mpsc::Receiver<GenericMessage<HkReply>>, reply_receiver: mpsc::Receiver<GenericMessage<HkReply>>,

View File

@@ -4,13 +4,13 @@ use log::warn;
use satrs::pool::PoolAddr; use satrs::pool::PoolAddr;
use satrs::pus::verification::{ use satrs::pus::verification::{
self, FailParams, TcStateAccepted, TcStateStarted, VerificationReporter, self, FailParams, TcStateAccepted, TcStateStarted, VerificationReporter,
VerificationReporterCfg, VerificationReportingProvider, VerificationToken, VerificationReporterConfig, VerificationReportingProvider, VerificationToken,
}; };
use satrs::pus::{ use satrs::pus::{
ActiveRequestMapProvider, ActiveRequestProvider, EcssTcAndToken, EcssTcInMemConversionProvider, ActiveRequest, ActiveRequestStore, CacheAndReadRawEcssTc, EcssTcAndToken, EcssTcCacher,
EcssTcInMemConverter, EcssTcReceiver, EcssTmSender, EcssTmtcError, GenericConversionError, EcssTcReceiver, EcssTmSender, EcssTmtcError, GenericConversionError, GenericRoutingError,
GenericRoutingError, HandlingStatus, PusPacketHandlingError, PusReplyHandler, PusRequestRouter, HandlingStatus, PusPacketHandlingError, PusReplyHandler, PusRequestRouter, PusServiceHelper,
PusServiceHelper, PusTcToRequestConverter, TcInMemory, PusTcToRequestConverter, TcInMemory,
}; };
use satrs::queue::{GenericReceiveError, GenericSendError}; use satrs::queue::{GenericReceiveError, GenericSendError};
use satrs::request::{Apid, GenericMessage, MessageMetadata}; use satrs::request::{Apid, GenericMessage, MessageMetadata};
@@ -33,7 +33,7 @@ pub mod stack;
pub mod test; pub mod test;
pub fn create_verification_reporter(owner_id: ComponentId, apid: Apid) -> VerificationReporter { pub fn create_verification_reporter(owner_id: ComponentId, apid: Apid) -> VerificationReporter {
let verif_cfg = VerificationReporterCfg::new(apid, 1, 2, 8).unwrap(); let verif_cfg = VerificationReporterConfig::new(apid, 1, 2, 8).unwrap();
// Every software component which needs to generate verification telemetry, gets a cloned // Every software component which needs to generate verification telemetry, gets a cloned
// verification reporter. // verification reporter.
VerificationReporter::new(owner_id, &verif_cfg) VerificationReporter::new(owner_id, &verif_cfg)
@@ -269,16 +269,16 @@ pub struct PusTargetedRequestService<
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
RequestConverter: PusTcToRequestConverter<ActiveRequestInfo, RequestType, Error = GenericConversionError>, RequestConverter: PusTcToRequestConverter<ActiveRequestInfo, RequestType, Error = GenericConversionError>,
ReplyHandler: PusReplyHandler<ActiveRequestInfo, ReplyType, Error = EcssTmtcError>, ReplyHandler: PusReplyHandler<ActiveRequestInfo, ReplyType, Error = EcssTmtcError>,
ActiveRequestMap: ActiveRequestMapProvider<ActiveRequestInfo>, ActiveRequestMapInstance: ActiveRequestStore<ActiveRequestInfo>,
ActiveRequestInfo: ActiveRequestProvider, ActiveRequestInfo: ActiveRequest,
RequestType, RequestType,
ReplyType, ReplyType,
> { > {
pub service_helper: pub service_helper:
PusServiceHelper<TcReceiver, TmTcSender, EcssTcInMemConverter, VerificationReporter>, PusServiceHelper<TcReceiver, TmTcSender, EcssTcCacher, VerificationReporter>,
pub request_router: GenericRequestRouter, pub request_router: GenericRequestRouter,
pub request_converter: RequestConverter, pub request_converter: RequestConverter,
pub active_request_map: ActiveRequestMap, pub active_request_map: ActiveRequestMapInstance,
pub reply_handler: ReplyHandler, pub reply_handler: ReplyHandler,
pub reply_receiver: mpsc::Receiver<GenericMessage<ReplyType>>, pub reply_receiver: mpsc::Receiver<GenericMessage<ReplyType>>,
phantom: std::marker::PhantomData<(RequestType, ActiveRequestInfo, ReplyType)>, phantom: std::marker::PhantomData<(RequestType, ActiveRequestInfo, ReplyType)>,
@@ -289,8 +289,8 @@ impl<
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
RequestConverter: PusTcToRequestConverter<ActiveRequestInfo, RequestType, Error = GenericConversionError>, RequestConverter: PusTcToRequestConverter<ActiveRequestInfo, RequestType, Error = GenericConversionError>,
ReplyHandler: PusReplyHandler<ActiveRequestInfo, ReplyType, Error = EcssTmtcError>, ReplyHandler: PusReplyHandler<ActiveRequestInfo, ReplyType, Error = EcssTmtcError>,
ActiveRequestMap: ActiveRequestMapProvider<ActiveRequestInfo>, ActiveRequestMapInstance: ActiveRequestStore<ActiveRequestInfo>,
ActiveRequestInfo: ActiveRequestProvider, ActiveRequestInfo: ActiveRequest,
RequestType, RequestType,
ReplyType, ReplyType,
> >
@@ -299,7 +299,7 @@ impl<
VerificationReporter, VerificationReporter,
RequestConverter, RequestConverter,
ReplyHandler, ReplyHandler,
ActiveRequestMap, ActiveRequestMapInstance,
ActiveRequestInfo, ActiveRequestInfo,
RequestType, RequestType,
ReplyType, ReplyType,
@@ -311,11 +311,11 @@ where
service_helper: PusServiceHelper< service_helper: PusServiceHelper<
TcReceiver, TcReceiver,
TmTcSender, TmTcSender,
EcssTcInMemConverter, EcssTcCacher,
VerificationReporter, VerificationReporter,
>, >,
request_converter: RequestConverter, request_converter: RequestConverter,
active_request_map: ActiveRequestMap, active_request_map: ActiveRequestMapInstance,
reply_hook: ReplyHandler, reply_hook: ReplyHandler,
request_router: GenericRequestRouter, request_router: GenericRequestRouter,
reply_receiver: mpsc::Receiver<GenericMessage<ReplyType>>, reply_receiver: mpsc::Receiver<GenericMessage<ReplyType>>,
@@ -509,7 +509,7 @@ where
/// and also log the error. /// and also log the error.
pub fn generic_pus_request_timeout_handler( pub fn generic_pus_request_timeout_handler(
sender: &(impl EcssTmSender + ?Sized), sender: &(impl EcssTmSender + ?Sized),
active_request: &(impl ActiveRequestProvider + Debug), active_request: &(impl ActiveRequest + Debug),
verification_handler: &impl VerificationReportingProvider, verification_handler: &impl VerificationReportingProvider,
time_stamp: &[u8], time_stamp: &[u8],
service_str: &'static str, service_str: &'static str,
@@ -537,7 +537,7 @@ pub(crate) mod tests {
use satrs::{ use satrs::{
pus::{ pus::{
verification::test_util::TestVerificationReporter, ActivePusRequestStd, verification::test_util::TestVerificationReporter, ActivePusRequestStd,
ActiveRequestMapProvider, MpscTcReceiver, ActiveRequestStore, MpscTcReceiver,
}, },
request::UniqueApidTargetId, request::UniqueApidTargetId,
spacepackets::{ spacepackets::{
@@ -556,7 +556,7 @@ pub(crate) mod tests {
// Testbench dedicated to the testing of [PusReplyHandler]s // Testbench dedicated to the testing of [PusReplyHandler]s
pub struct ReplyHandlerTestbench< pub struct ReplyHandlerTestbench<
ReplyHandler: PusReplyHandler<ActiveRequestInfo, Reply, Error = EcssTmtcError>, ReplyHandler: PusReplyHandler<ActiveRequestInfo, Reply, Error = EcssTmtcError>,
ActiveRequestInfo: ActiveRequestProvider, ActiveRequestInfo: ActiveRequest,
Reply, Reply,
> { > {
pub id: ComponentId, pub id: ComponentId,
@@ -570,7 +570,7 @@ pub(crate) mod tests {
impl< impl<
ReplyHandler: PusReplyHandler<ActiveRequestInfo, Reply, Error = EcssTmtcError>, ReplyHandler: PusReplyHandler<ActiveRequestInfo, Reply, Error = EcssTmtcError>,
ActiveRequestInfo: ActiveRequestProvider, ActiveRequestInfo: ActiveRequest,
Reply, Reply,
> ReplyHandlerTestbench<ReplyHandler, ActiveRequestInfo, Reply> > ReplyHandlerTestbench<ReplyHandler, ActiveRequestInfo, Reply>
{ {
@@ -671,7 +671,7 @@ pub(crate) mod tests {
// Testbench dedicated to the testing of [PusTcToRequestConverter]s // Testbench dedicated to the testing of [PusTcToRequestConverter]s
pub struct PusConverterTestbench< pub struct PusConverterTestbench<
Converter: PusTcToRequestConverter<ActiveRequestInfo, Request, Error = GenericConversionError>, Converter: PusTcToRequestConverter<ActiveRequestInfo, Request, Error = GenericConversionError>,
ActiveRequestInfo: ActiveRequestProvider, ActiveRequestInfo: ActiveRequest,
Request, Request,
> { > {
pub id: ComponentId, pub id: ComponentId,
@@ -685,7 +685,7 @@ pub(crate) mod tests {
impl< impl<
Converter: PusTcToRequestConverter<ActiveRequestInfo, Request, Error = GenericConversionError>, Converter: PusTcToRequestConverter<ActiveRequestInfo, Request, Error = GenericConversionError>,
ActiveRequestInfo: ActiveRequestProvider, ActiveRequestInfo: ActiveRequest,
Request, Request,
> PusConverterTestbench<Converter, ActiveRequestInfo, Request> > PusConverterTestbench<Converter, ActiveRequestInfo, Request>
{ {
@@ -751,8 +751,8 @@ pub(crate) mod tests {
pub struct TargetedPusRequestTestbench< pub struct TargetedPusRequestTestbench<
RequestConverter: PusTcToRequestConverter<ActiveRequestInfo, RequestType, Error = GenericConversionError>, RequestConverter: PusTcToRequestConverter<ActiveRequestInfo, RequestType, Error = GenericConversionError>,
ReplyHandler: PusReplyHandler<ActiveRequestInfo, ReplyType, Error = EcssTmtcError>, ReplyHandler: PusReplyHandler<ActiveRequestInfo, ReplyType, Error = EcssTmtcError>,
ActiveRequestMap: ActiveRequestMapProvider<ActiveRequestInfo>, ActiveRequestMapInstance: ActiveRequestStore<ActiveRequestInfo>,
ActiveRequestInfo: ActiveRequestProvider, ActiveRequestInfo: ActiveRequest,
RequestType, RequestType,
ReplyType, ReplyType,
> { > {
@@ -761,7 +761,7 @@ pub(crate) mod tests {
TestVerificationReporter, TestVerificationReporter,
RequestConverter, RequestConverter,
ReplyHandler, ReplyHandler,
ActiveRequestMap, ActiveRequestMapInstance,
ActiveRequestInfo, ActiveRequestInfo,
RequestType, RequestType,
ReplyType, ReplyType,

View File

@@ -8,8 +8,8 @@ use crate::requests::GenericRequestRouter;
use crate::tmtc::sender::TmTcSender; use crate::tmtc::sender::TmTcSender;
use satrs::pus::verification::VerificationReporter; use satrs::pus::verification::VerificationReporter;
use satrs::pus::{ use satrs::pus::{
DefaultActiveRequestMap, EcssTcAndToken, EcssTcInMemConverter, MpscTcReceiver, DefaultActiveRequestMap, EcssTcAndToken, EcssTcCacher, MpscTcReceiver, PusPacketHandlingError,
PusPacketHandlingError, PusServiceHelper, PusServiceHelper,
}; };
use satrs::request::GenericMessage; use satrs::request::GenericMessage;
use satrs::{ use satrs::{
@@ -20,8 +20,8 @@ use satrs::{
self, FailParams, TcStateAccepted, TcStateStarted, VerificationReportingProvider, self, FailParams, TcStateAccepted, TcStateStarted, VerificationReportingProvider,
VerificationToken, VerificationToken,
}, },
ActivePusRequestStd, ActiveRequestProvider, EcssTmSender, EcssTmtcError, ActivePusRequestStd, ActiveRequest, EcssTmSender, EcssTmtcError, GenericConversionError,
GenericConversionError, PusReplyHandler, PusTcToRequestConverter, PusTmVariant, PusReplyHandler, PusTcToRequestConverter, PusTmVariant,
}, },
request::UniqueApidTargetId, request::UniqueApidTargetId,
spacepackets::{ spacepackets::{
@@ -210,7 +210,7 @@ impl PusTcToRequestConverter<ActivePusRequestStd, ModeRequest> for ModeRequestCo
pub fn create_mode_service( pub fn create_mode_service(
tm_sender: TmTcSender, tm_sender: TmTcSender,
tc_in_mem_converter: EcssTcInMemConverter, tc_in_mem_converter: EcssTcCacher,
pus_action_rx: mpsc::Receiver<EcssTcAndToken>, pus_action_rx: mpsc::Receiver<EcssTcAndToken>,
mode_router: GenericRequestRouter, mode_router: GenericRequestRouter,
reply_receiver: mpsc::Receiver<GenericMessage<ModeReply>>, reply_receiver: mpsc::Receiver<GenericMessage<ModeReply>>,

View File

@@ -9,7 +9,7 @@ use satrs::pus::scheduler::{PusScheduler, TcInfo};
use satrs::pus::scheduler_srv::PusSchedServiceHandler; use satrs::pus::scheduler_srv::PusSchedServiceHandler;
use satrs::pus::verification::VerificationReporter; use satrs::pus::verification::VerificationReporter;
use satrs::pus::{ use satrs::pus::{
DirectPusPacketHandlerResult, EcssTcAndToken, EcssTcInMemConverter, MpscTcReceiver, DirectPusPacketHandlerResult, EcssTcAndToken, EcssTcCacher, MpscTcReceiver,
PartialPusHandlingError, PusServiceHelper, PartialPusHandlingError, PusServiceHelper,
}; };
use satrs::spacepackets::ecss::PusServiceId; use satrs::spacepackets::ecss::PusServiceId;
@@ -84,7 +84,7 @@ pub struct SchedulingServiceWrapper {
pub pus_11_handler: PusSchedServiceHandler< pub pus_11_handler: PusSchedServiceHandler<
MpscTcReceiver, MpscTcReceiver,
TmTcSender, TmTcSender,
EcssTcInMemConverter, EcssTcCacher,
VerificationReporter, VerificationReporter,
PusScheduler, PusScheduler,
>, >,
@@ -174,7 +174,7 @@ impl SchedulingServiceWrapper {
pub fn create_scheduler_service( pub fn create_scheduler_service(
tm_sender: TmTcSender, tm_sender: TmTcSender,
tc_in_mem_converter: EcssTcInMemConverter, tc_in_mem_converter: EcssTcCacher,
tc_releaser: TcReleaser, tc_releaser: TcReleaser,
pus_sched_rx: mpsc::Receiver<EcssTcAndToken>, pus_sched_rx: mpsc::Receiver<EcssTcAndToken>,
sched_tc_pool: StaticMemoryPool, sched_tc_pool: StaticMemoryPool,

View File

@@ -6,8 +6,8 @@ use satrs::pus::test::PusService17TestHandler;
use satrs::pus::verification::{FailParams, VerificationReporter, VerificationReportingProvider}; use satrs::pus::verification::{FailParams, VerificationReporter, VerificationReportingProvider};
use satrs::pus::PartialPusHandlingError; use satrs::pus::PartialPusHandlingError;
use satrs::pus::{ use satrs::pus::{
DirectPusPacketHandlerResult, EcssTcAndToken, EcssTcInMemConversionProvider, CacheAndReadRawEcssTc, DirectPusPacketHandlerResult, EcssTcAndToken, EcssTcCacher,
EcssTcInMemConverter, MpscTcReceiver, PusServiceHelper, MpscTcReceiver, PusServiceHelper,
}; };
use satrs::spacepackets::ecss::tc::PusTcReader; use satrs::spacepackets::ecss::tc::PusTcReader;
use satrs::spacepackets::ecss::{PusPacket, PusServiceId}; use satrs::spacepackets::ecss::{PusPacket, PusServiceId};
@@ -19,7 +19,7 @@ use super::{DirectPusService, HandlingStatus};
pub fn create_test_service( pub fn create_test_service(
tm_sender: TmTcSender, tm_sender: TmTcSender,
tc_in_mem_converter: EcssTcInMemConverter, tc_in_mem_converter: EcssTcCacher,
event_sender: mpsc::SyncSender<EventMessageU32>, event_sender: mpsc::SyncSender<EventMessageU32>,
pus_test_rx: mpsc::Receiver<EcssTcAndToken>, pus_test_rx: mpsc::Receiver<EcssTcAndToken>,
) -> TestCustomServiceWrapper { ) -> TestCustomServiceWrapper {
@@ -37,12 +37,8 @@ pub fn create_test_service(
} }
pub struct TestCustomServiceWrapper { pub struct TestCustomServiceWrapper {
pub handler: PusService17TestHandler< pub handler:
MpscTcReceiver, PusService17TestHandler<MpscTcReceiver, TmTcSender, EcssTcCacher, VerificationReporter>,
TmTcSender,
EcssTcInMemConverter,
VerificationReporter,
>,
pub event_tx: mpsc::SyncSender<EventMessageU32>, pub event_tx: mpsc::SyncSender<EventMessageU32>,
} }

View File

@@ -8,7 +8,7 @@ use satrs::mode::ModeRequest;
use satrs::pus::verification::{ use satrs::pus::verification::{
FailParams, TcStateAccepted, VerificationReportingProvider, VerificationToken, FailParams, TcStateAccepted, VerificationReportingProvider, VerificationToken,
}; };
use satrs::pus::{ActiveRequestProvider, EcssTmSender, GenericRoutingError, PusRequestRouter}; use satrs::pus::{ActiveRequest, EcssTmSender, GenericRoutingError, PusRequestRouter};
use satrs::queue::GenericSendError; use satrs::queue::GenericSendError;
use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId}; use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId};
use satrs::spacepackets::ecss::tc::PusTcReader; use satrs::spacepackets::ecss::tc::PusTcReader;
@@ -46,7 +46,7 @@ impl Default for GenericRequestRouter {
impl GenericRequestRouter { impl GenericRequestRouter {
pub(crate) fn handle_error_generic( pub(crate) fn handle_error_generic(
&self, &self,
active_request: &impl ActiveRequestProvider, active_request: &impl ActiveRequest,
tc: &PusTcReader, tc: &PusTcReader,
error: GenericRoutingError, error: GenericRoutingError,
tm_sender: &(impl EcssTmSender + ?Sized), tm_sender: &(impl EcssTmSender + ?Sized),

View File

@@ -10,6 +10,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Bump `sat-rs` edition to 2024. - Bump `sat-rs` edition to 2024.
## Changed
Some trait renaming to be more in-line with Rust naming conventions.
- `EventTmHookProvider` -> `EventTmHook`
- `ActiveRequestProvider` -> `ActiveRequest`
- `EcssTcInMemConversionProvider` -> `CacheAndReadRawEcssTc`
- `ActiveRequestMapProvider` -> `ActiveRequestStore`
- `CountdownProvider` -> `Countdown`
# [v0.3.0-alpha.2] 2025-07-22 # [v0.3.0-alpha.2] 2025-07-22
`satrs-shared` update `satrs-shared` update

View File

@@ -26,7 +26,7 @@ thiserror = { version = "2", default-features = false }
hashbrown = { version = ">=0.14, <=0.15", optional = true } hashbrown = { version = ">=0.14, <=0.15", optional = true }
static_cell = { version = "2", optional = true } static_cell = { version = "2", optional = true }
dyn-clone = { version = "1", optional = true } dyn-clone = { version = "1", optional = true }
heapless = { version = "0.8", optional = true } heapless = { version = "0.9", optional = true }
downcast-rs = { version = "2", default-features = false, optional = true } downcast-rs = { version = "2", default-features = false, optional = true }
bus = { version = "2.2", optional = true } bus = { version = "2.2", optional = true }
crossbeam-channel = { version = "0.5", default-features = false, optional = true } crossbeam-channel = { version = "0.5", default-features = false, optional = true }

View File

@@ -71,18 +71,14 @@ pub enum ListenerKey {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct EventMessage<Event: GenericEvent, ParamProvider: Debug = Params> { pub struct EventMessage<Event: GenericEvent, Parameters: Debug = Params> {
sender_id: ComponentId, sender_id: ComponentId,
event: Event, event: Event,
params: Option<ParamProvider>, params: Option<Parameters>,
} }
impl<Event: GenericEvent, ParamProvider: Debug + Clone> EventMessage<Event, ParamProvider> { impl<Event: GenericEvent, Parameters: Debug + Clone> EventMessage<Event, Parameters> {
pub fn new_generic( pub fn new_generic(sender_id: ComponentId, event: Event, params: Option<&Parameters>) -> Self {
sender_id: ComponentId,
event: Event,
params: Option<&ParamProvider>,
) -> Self {
Self { Self {
sender_id, sender_id,
event, event,
@@ -98,7 +94,7 @@ impl<Event: GenericEvent, ParamProvider: Debug + Clone> EventMessage<Event, Para
self.event self.event
} }
pub fn params(&self) -> Option<&ParamProvider> { pub fn params(&self) -> Option<&Parameters> {
self.params.as_ref() self.params.as_ref()
} }
@@ -106,7 +102,7 @@ impl<Event: GenericEvent, ParamProvider: Debug + Clone> EventMessage<Event, Para
Self::new_generic(sender_id, event, None) Self::new_generic(sender_id, event, None)
} }
pub fn new_with_params(sender_id: ComponentId, event: Event, params: &ParamProvider) -> Self { pub fn new_with_params(sender_id: ComponentId, event: Event, params: &Parameters) -> Self {
Self::new_generic(sender_id, event, Some(params)) Self::new_generic(sender_id, event, Some(params))
} }
} }

View File

@@ -222,7 +222,7 @@ impl Error for PoolError {
} }
} }
/// Generic trait for pool providers which provide memory pools for variable sized data. /// Generic trait for pool providers which provide memory pools for variable sized packet data.
/// ///
/// It specifies a basic API to [Self::add], [Self::modify], [Self::read] and [Self::delete] data /// It specifies a basic API to [Self::add], [Self::modify], [Self::read] and [Self::delete] data
/// in the store at its core. The API was designed so internal optimizations can be performed /// in the store at its core. The API was designed so internal optimizations can be performed

View File

@@ -143,7 +143,7 @@ pub mod std_mod {
use crate::{ use crate::{
ComponentId, ComponentId,
pus::{ pus::{
ActivePusRequestStd, ActiveRequestProvider, DefaultActiveRequestMap, ActivePusRequestStd, ActiveRequest, DefaultActiveRequestMap,
verification::{self, TcStateToken}, verification::{self, TcStateToken},
}, },
request::{MessageSenderMap, OneMessageSender}, request::{MessageSenderMap, OneMessageSender},
@@ -157,7 +157,7 @@ pub mod std_mod {
common: ActivePusRequestStd, common: ActivePusRequestStd,
} }
impl ActiveRequestProvider for ActivePusActionRequestStd { impl ActiveRequest for ActivePusActionRequestStd {
delegate::delegate! { delegate::delegate! {
to self.common { to self.common {
fn target_id(&self) -> ComponentId; fn target_id(&self) -> ComponentId;

View File

@@ -139,24 +139,24 @@ mod alloc_mod {
use core::cell::RefCell; use core::cell::RefCell;
use spacepackets::ecss::PusError; use spacepackets::ecss::PusError;
pub trait EventTmHookProvider { pub trait EventTmHook {
fn modify_tm(&self, tm: &mut PusTmCreator); fn modify_tm(&self, tm: &mut PusTmCreator);
} }
#[derive(Default)] #[derive(Default)]
pub struct DummyEventHook {} pub struct DummyEventHook {}
impl EventTmHookProvider for DummyEventHook { impl EventTmHook for DummyEventHook {
fn modify_tm(&self, _tm: &mut PusTmCreator) {} fn modify_tm(&self, _tm: &mut PusTmCreator) {}
} }
pub struct EventReporter<EventTmHook: EventTmHookProvider = DummyEventHook> { pub struct EventReporter<EventTmHookInstance: EventTmHook = DummyEventHook> {
id: ComponentId, id: ComponentId,
// Use interior mutability pattern here. This is just an intermediate buffer to the PUS event packet // Use interior mutability pattern here. This is just an intermediate buffer to the PUS event packet
// generation. // generation.
source_data_buf: RefCell<Vec<u8>>, source_data_buf: RefCell<Vec<u8>>,
pub report_creator: EventReportCreator, pub report_creator: EventReportCreator,
pub tm_hook: EventTmHook, pub tm_hook: EventTmHookInstance,
} }
impl EventReporter<DummyEventHook> { impl EventReporter<DummyEventHook> {
@@ -175,13 +175,13 @@ mod alloc_mod {
}) })
} }
} }
impl<EventTmHook: EventTmHookProvider> EventReporter<EventTmHook> { impl<EventTmHookInstance: EventTmHook> EventReporter<EventTmHookInstance> {
pub fn new_with_hook( pub fn new_with_hook(
id: ComponentId, id: ComponentId,
default_apid: u16, default_apid: u16,
default_dest_id: u16, default_dest_id: u16,
max_event_id_and_aux_data_size: usize, max_event_id_and_aux_data_size: usize,
tm_hook: EventTmHook, tm_hook: EventTmHookInstance,
) -> Option<Self> { ) -> Option<Self> {
let reporter = EventReportCreator::new(default_apid, default_dest_id)?; let reporter = EventReportCreator::new(default_apid, default_dest_id)?;
Some(Self { Some(Self {

View File

@@ -46,7 +46,7 @@ pub mod heapless_mod {
// regular Event type again. // regular Event type again.
#[derive(Default)] #[derive(Default)]
pub struct HeaplessPusMgmtBackendProvider<const N: usize, Provider: GenericEvent> { pub struct HeaplessPusMgmtBackendProvider<const N: usize, Provider: GenericEvent> {
disabled: heapless::FnvIndexSet<LargestEventRaw, N>, disabled: heapless::index_set::FnvIndexSet<LargestEventRaw, N>,
phantom: PhantomData<Provider>, phantom: PhantomData<Provider>,
} }
@@ -102,7 +102,7 @@ pub mod alloc_mod {
use crate::{ use crate::{
events::EventU16, events::EventU16,
params::{Params, WritableToBeBytes}, params::{Params, WritableToBeBytes},
pus::event::{DummyEventHook, EventTmHookProvider}, pus::event::{DummyEventHook, EventTmHook},
}; };
use super::*; use super::*;
@@ -151,9 +151,9 @@ pub mod alloc_mod {
pub struct PusEventTmCreatorWithMap< pub struct PusEventTmCreatorWithMap<
ReportingMap: PusEventReportingMapProvider<Event>, ReportingMap: PusEventReportingMapProvider<Event>,
Event: GenericEvent, Event: GenericEvent,
EventTmHook: EventTmHookProvider = DummyEventHook, EventTmHookInstance: EventTmHook = DummyEventHook,
> { > {
pub reporter: EventReporter<EventTmHook>, pub reporter: EventReporter<EventTmHookInstance>,
reporting_map: ReportingMap, reporting_map: ReportingMap,
phantom: PhantomData<Event>, phantom: PhantomData<Event>,
} }
@@ -161,10 +161,10 @@ pub mod alloc_mod {
impl< impl<
ReportingMap: PusEventReportingMapProvider<Event>, ReportingMap: PusEventReportingMapProvider<Event>,
Event: GenericEvent, Event: GenericEvent,
EventTmHook: EventTmHookProvider, EventTmHookInstance: EventTmHook,
> PusEventTmCreatorWithMap<ReportingMap, Event, EventTmHook> > PusEventTmCreatorWithMap<ReportingMap, Event, EventTmHookInstance>
{ {
pub fn new(reporter: EventReporter<EventTmHook>, backend: ReportingMap) -> Self { pub fn new(reporter: EventReporter<EventTmHookInstance>, backend: ReportingMap) -> Self {
Self { Self {
reporter, reporter,
reporting_map: backend, reporting_map: backend,
@@ -262,10 +262,10 @@ pub mod alloc_mod {
} }
} }
impl<Event: GenericEvent + Copy + PartialEq + Eq + Hash, EventTmHook: EventTmHookProvider> impl<Event: GenericEvent + Copy + PartialEq + Eq + Hash, EventTmHookInstance: EventTmHook>
PusEventTmCreatorWithMap<DefaultPusEventReportingMap<Event>, Event, EventTmHook> PusEventTmCreatorWithMap<DefaultPusEventReportingMap<Event>, Event, EventTmHookInstance>
{ {
pub fn new_with_default_backend(reporter: EventReporter<EventTmHook>) -> Self { pub fn new_with_default_backend(reporter: EventReporter<EventTmHookInstance>) -> Self {
Self { Self {
reporter, reporter,
reporting_map: DefaultPusEventReportingMap::default(), reporting_map: DefaultPusEventReportingMap::default(),

View File

@@ -9,14 +9,14 @@ use std::sync::mpsc::Sender;
use super::verification::VerificationReportingProvider; use super::verification::VerificationReportingProvider;
use super::{ use super::{
EcssTcInMemConversionProvider, EcssTcReceiver, EcssTmSender, GenericConversionError, CacheAndReadRawEcssTc, EcssTcReceiver, EcssTmSender, GenericConversionError,
GenericRoutingError, HandlingStatus, PusServiceHelper, GenericRoutingError, HandlingStatus, PusServiceHelper,
}; };
pub struct PusEventServiceHandler< pub struct PusEventServiceHandler<
TcReceiver: EcssTcReceiver, TcReceiver: EcssTcReceiver,
TmSender: EcssTmSender, TmSender: EcssTmSender,
TcInMemConverter: EcssTcInMemConversionProvider, TcInMemConverter: CacheAndReadRawEcssTc,
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
> { > {
pub service_helper: pub service_helper:
@@ -27,7 +27,7 @@ pub struct PusEventServiceHandler<
impl< impl<
TcReceiver: EcssTcReceiver, TcReceiver: EcssTcReceiver,
TmSender: EcssTmSender, TmSender: EcssTmSender,
TcInMemConverter: EcssTcInMemConversionProvider, TcInMemConverter: CacheAndReadRawEcssTc,
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
> PusEventServiceHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter> > PusEventServiceHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
{ {
@@ -167,7 +167,7 @@ mod tests {
use crate::{ use crate::{
events::EventU32, events::EventU32,
pus::{ pus::{
DirectPusPacketHandlerResult, EcssTcInSharedPoolConverter, PusPacketHandlingError, DirectPusPacketHandlerResult, EcssTcInSharedPoolCacher, PusPacketHandlingError,
event_man::EventRequestWithToken, event_man::EventRequestWithToken,
tests::PusServiceHandlerWithSharedStoreCommon, tests::PusServiceHandlerWithSharedStoreCommon,
verification::{TcStateAccepted, VerificationToken}, verification::{TcStateAccepted, VerificationToken},
@@ -183,7 +183,7 @@ mod tests {
handler: PusEventServiceHandler< handler: PusEventServiceHandler<
MpscTcReceiver, MpscTcReceiver,
PacketSenderWithSharedPool, PacketSenderWithSharedPool,
EcssTcInSharedPoolConverter, EcssTcInSharedPoolCacher,
VerificationReporter, VerificationReporter,
>, >,
} }

View File

@@ -296,7 +296,7 @@ pub trait PacketSenderPusTc: Send {
) -> Result<(), Self::Error>; ) -> Result<(), Self::Error>;
} }
pub trait ActiveRequestMapProvider<V>: Sized { pub trait ActiveRequestStore<V>: Sized {
fn insert(&mut self, request_id: &RequestId, request_info: V); fn insert(&mut self, request_id: &RequestId, request_info: V);
fn get(&self, request_id: RequestId) -> Option<&V>; fn get(&self, request_id: RequestId) -> Option<&V>;
fn get_mut(&mut self, request_id: RequestId) -> Option<&mut V>; fn get_mut(&mut self, request_id: RequestId) -> Option<&mut V>;
@@ -309,7 +309,7 @@ pub trait ActiveRequestMapProvider<V>: Sized {
fn for_each_mut<F: FnMut(&RequestId, &mut V)>(&mut self, f: F); fn for_each_mut<F: FnMut(&RequestId, &mut V)>(&mut self, f: F);
} }
pub trait ActiveRequestProvider { pub trait ActiveRequest {
fn target_id(&self) -> ComponentId; fn target_id(&self) -> ComponentId;
fn token(&self) -> TcStateToken; fn token(&self) -> TcStateToken;
fn set_token(&mut self, token: TcStateToken); fn set_token(&mut self, token: TcStateToken);
@@ -330,7 +330,7 @@ pub trait PusRequestRouter<Request> {
) -> Result<(), Self::Error>; ) -> Result<(), Self::Error>;
} }
pub trait PusReplyHandler<ActiveRequestInfo: ActiveRequestProvider, ReplyType> { pub trait PusReplyHandler<ActiveRequestInfo: ActiveRequest, ReplyType> {
type Error; type Error;
/// This function handles a reply for a given PUS request and returns whether that request /// This function handles a reply for a given PUS request and returns whether that request
@@ -459,7 +459,7 @@ pub mod alloc_mod {
/// ///
/// A [VerificationReportingProvider] instance is passed to the user to also allow handling /// A [VerificationReportingProvider] instance is passed to the user to also allow handling
/// of the verification process as part of the PUS standard requirements. /// of the verification process as part of the PUS standard requirements.
pub trait PusTcToRequestConverter<ActiveRequestInfo: ActiveRequestProvider, Request> { pub trait PusTcToRequestConverter<ActiveRequestInfo: ActiveRequest, Request> {
type Error; type Error;
fn convert( fn convert(
&mut self, &mut self,
@@ -480,7 +480,7 @@ pub mod alloc_mod {
} }
} }
impl<V> ActiveRequestMapProvider<V> for DefaultActiveRequestMap<V> { impl<V> ActiveRequestStore<V> for DefaultActiveRequestMap<V> {
fn insert(&mut self, request_id: &RequestId, request: V) { fn insert(&mut self, request_id: &RequestId, request: V) {
self.0.insert(*request_id, request); self.0.insert(*request_id, request);
} }
@@ -680,7 +680,7 @@ pub mod std_mod {
pub use cb_mod::*; pub use cb_mod::*;
use super::verification::{TcStateToken, VerificationReportingProvider}; use super::verification::{TcStateToken, VerificationReportingProvider};
use super::{AcceptedEcssTcAndToken, ActiveRequestProvider, TcInMemory}; use super::{AcceptedEcssTcAndToken, ActiveRequest, TcInMemory};
use crate::tmtc::PacketInPool; use crate::tmtc::PacketInPool;
impl From<mpsc::SendError<PoolAddr>> for EcssTmtcError { impl From<mpsc::SendError<PoolAddr>> for EcssTmtcError {
@@ -845,7 +845,7 @@ pub mod std_mod {
} }
} }
impl ActiveRequestProvider for ActivePusRequestStd { impl ActiveRequest for ActivePusRequestStd {
fn target_id(&self) -> ComponentId { fn target_id(&self) -> ComponentId {
self.target_id self.target_id
} }
@@ -947,7 +947,9 @@ pub mod std_mod {
} }
} }
pub trait EcssTcInMemConversionProvider { /// This trait provides an abstraction for caching a raw ECSS telecommand and then
/// providing the [PusTcReader] abstraction to read the cache raw telecommand.
pub trait CacheAndReadRawEcssTc {
fn cache(&mut self, possible_packet: &TcInMemory) -> Result<(), PusTcFromMemError>; fn cache(&mut self, possible_packet: &TcInMemory) -> Result<(), PusTcFromMemError>;
fn tc_slice_raw(&self) -> &[u8]; fn tc_slice_raw(&self) -> &[u8];
@@ -971,12 +973,12 @@ pub mod std_mod {
/// Please note that this structure is not able to convert TCs which are stored inside a /// Please note that this structure is not able to convert TCs which are stored inside a
/// [SharedStaticMemoryPool]. /// [SharedStaticMemoryPool].
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct EcssTcInVecConverter { pub struct EcssTcVecCacher {
sender_id: Option<ComponentId>, sender_id: Option<ComponentId>,
pub pus_tc_raw: Option<Vec<u8>>, pub pus_tc_raw: Option<Vec<u8>>,
} }
impl EcssTcInMemConversionProvider for EcssTcInVecConverter { impl CacheAndReadRawEcssTc for EcssTcVecCacher {
fn cache(&mut self, tc_in_memory: &TcInMemory) -> Result<(), PusTcFromMemError> { fn cache(&mut self, tc_in_memory: &TcInMemory) -> Result<(), PusTcFromMemError> {
self.pus_tc_raw = None; self.pus_tc_raw = None;
match tc_in_memory { match tc_in_memory {
@@ -1008,13 +1010,13 @@ pub mod std_mod {
/// packets should be avoided. Please note that this structure is not able to convert TCs which /// packets should be avoided. Please note that this structure is not able to convert TCs which
/// are stored as a `Vec<u8>`. /// are stored as a `Vec<u8>`.
#[derive(Clone)] #[derive(Clone)]
pub struct EcssTcInSharedPoolConverter { pub struct EcssTcInSharedPoolCacher {
sender_id: Option<ComponentId>, sender_id: Option<ComponentId>,
shared_tc_pool: SharedStaticMemoryPool, shared_tc_pool: SharedStaticMemoryPool,
pus_buf: Vec<u8>, pus_buf: Vec<u8>,
} }
impl EcssTcInSharedPoolConverter { impl EcssTcInSharedPoolCacher {
pub fn new(shared_tc_store: SharedStaticMemoryPool, max_expected_tc_size: usize) -> Self { pub fn new(shared_tc_store: SharedStaticMemoryPool, max_expected_tc_size: usize) -> Self {
Self { Self {
sender_id: None, sender_id: None,
@@ -1045,7 +1047,7 @@ pub mod std_mod {
} }
} }
impl EcssTcInMemConversionProvider for EcssTcInSharedPoolConverter { impl CacheAndReadRawEcssTc for EcssTcInSharedPoolCacher {
fn cache(&mut self, tc_in_memory: &TcInMemory) -> Result<(), PusTcFromMemError> { fn cache(&mut self, tc_in_memory: &TcInMemory) -> Result<(), PusTcFromMemError> {
match tc_in_memory { match tc_in_memory {
super::TcInMemory::Pool(packet_in_pool) => { super::TcInMemory::Pool(packet_in_pool) => {
@@ -1070,38 +1072,38 @@ pub mod std_mod {
// TODO: alloc feature flag? // TODO: alloc feature flag?
#[derive(Clone)] #[derive(Clone)]
pub enum EcssTcInMemConverter { pub enum EcssTcCacher {
Static(EcssTcInSharedPoolConverter), Static(EcssTcInSharedPoolCacher),
Heap(EcssTcInVecConverter), Heap(EcssTcVecCacher),
} }
impl EcssTcInMemConverter { impl EcssTcCacher {
pub fn new_static(static_store_converter: EcssTcInSharedPoolConverter) -> Self { pub fn new_static(static_store_converter: EcssTcInSharedPoolCacher) -> Self {
EcssTcInMemConverter::Static(static_store_converter) Self::Static(static_store_converter)
} }
pub fn new_heap(heap_converter: EcssTcInVecConverter) -> Self { pub fn new_heap(heap_converter: EcssTcVecCacher) -> Self {
EcssTcInMemConverter::Heap(heap_converter) Self::Heap(heap_converter)
} }
} }
impl EcssTcInMemConversionProvider for EcssTcInMemConverter { impl CacheAndReadRawEcssTc for EcssTcCacher {
fn cache(&mut self, tc_in_memory: &TcInMemory) -> Result<(), PusTcFromMemError> { fn cache(&mut self, tc_in_memory: &TcInMemory) -> Result<(), PusTcFromMemError> {
match self { match self {
EcssTcInMemConverter::Static(converter) => converter.cache(tc_in_memory), Self::Static(converter) => converter.cache(tc_in_memory),
EcssTcInMemConverter::Heap(converter) => converter.cache(tc_in_memory), Self::Heap(converter) => converter.cache(tc_in_memory),
} }
} }
fn tc_slice_raw(&self) -> &[u8] { fn tc_slice_raw(&self) -> &[u8] {
match self { match self {
EcssTcInMemConverter::Static(converter) => converter.tc_slice_raw(), Self::Static(converter) => converter.tc_slice_raw(),
EcssTcInMemConverter::Heap(converter) => converter.tc_slice_raw(), Self::Heap(converter) => converter.tc_slice_raw(),
} }
} }
fn sender_id(&self) -> Option<ComponentId> { fn sender_id(&self) -> Option<ComponentId> {
match self { match self {
EcssTcInMemConverter::Static(converter) => converter.sender_id(), Self::Static(converter) => converter.sender_id(),
EcssTcInMemConverter::Heap(converter) => converter.sender_id(), Self::Heap(converter) => converter.sender_id(),
} }
} }
} }
@@ -1129,7 +1131,7 @@ pub mod std_mod {
pub struct PusServiceHelper< pub struct PusServiceHelper<
TcReceiver: EcssTcReceiver, TcReceiver: EcssTcReceiver,
TmSender: EcssTmSender, TmSender: EcssTmSender,
TcInMemConverter: EcssTcInMemConversionProvider, TcInMemConverter: CacheAndReadRawEcssTc,
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
> { > {
pub common: PusServiceBase<TcReceiver, TmSender, VerificationReporter>, pub common: PusServiceBase<TcReceiver, TmSender, VerificationReporter>,
@@ -1139,7 +1141,7 @@ pub mod std_mod {
impl< impl<
TcReceiver: EcssTcReceiver, TcReceiver: EcssTcReceiver,
TmSender: EcssTmSender, TmSender: EcssTmSender,
TcInMemConverter: EcssTcInMemConversionProvider, TcInMemConverter: CacheAndReadRawEcssTc,
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
> PusServiceHelper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter> > PusServiceHelper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
{ {
@@ -1314,7 +1316,8 @@ pub mod tests {
use super::verification::test_util::TestVerificationReporter; use super::verification::test_util::TestVerificationReporter;
use super::verification::{ use super::verification::{
TcStateAccepted, VerificationReporterCfg, VerificationReportingProvider, VerificationToken, TcStateAccepted, VerificationReporterConfig, VerificationReportingProvider,
VerificationToken,
}; };
use super::*; use super::*;
@@ -1382,7 +1385,7 @@ pub mod tests {
pub type PusServiceHelperStatic = PusServiceHelper< pub type PusServiceHelperStatic = PusServiceHelper<
MpscTcReceiver, MpscTcReceiver,
PacketSenderWithSharedPool, PacketSenderWithSharedPool,
EcssTcInSharedPoolConverter, EcssTcInSharedPoolCacher,
VerificationReporter, VerificationReporter,
>; >;
@@ -1404,12 +1407,12 @@ pub mod tests {
let (test_srv_tc_tx, test_srv_tc_rx) = mpsc::sync_channel(10); let (test_srv_tc_tx, test_srv_tc_rx) = mpsc::sync_channel(10);
let (tm_tx, tm_rx) = mpsc::sync_channel(10); let (tm_tx, tm_rx) = mpsc::sync_channel(10);
let verif_cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap(); let verif_cfg = VerificationReporterConfig::new(TEST_APID, 1, 2, 8).unwrap();
let verification_handler = let verification_handler =
VerificationReporter::new(TEST_COMPONENT_ID_0.id(), &verif_cfg); VerificationReporter::new(TEST_COMPONENT_ID_0.id(), &verif_cfg);
let test_srv_tm_sender = let test_srv_tm_sender =
PacketSenderWithSharedPool::new(tm_tx, shared_tm_pool_wrapper.clone()); PacketSenderWithSharedPool::new(tm_tx, shared_tm_pool_wrapper.clone());
let in_store_converter = EcssTcInSharedPoolConverter::new(shared_tc_pool.clone(), 2048); let in_store_converter = EcssTcInSharedPoolCacher::new(shared_tc_pool.clone(), 2048);
( (
Self { Self {
pus_buf: RefCell::new([0; 2048]), pus_buf: RefCell::new([0; 2048]),
@@ -1487,12 +1490,8 @@ pub mod tests {
tc_sender: mpsc::Sender<EcssTcAndToken>, tc_sender: mpsc::Sender<EcssTcAndToken>,
tm_receiver: mpsc::Receiver<PacketAsVec>, tm_receiver: mpsc::Receiver<PacketAsVec>,
} }
pub type PusServiceHelperDynamic = PusServiceHelper< pub type PusServiceHelperDynamic =
MpscTcReceiver, PusServiceHelper<MpscTcReceiver, MpscTmAsVecSender, EcssTcVecCacher, VerificationReporter>;
MpscTmAsVecSender,
EcssTcInVecConverter,
VerificationReporter,
>;
impl PusServiceHandlerWithVecCommon { impl PusServiceHandlerWithVecCommon {
pub fn new_with_standard_verif_reporter( pub fn new_with_standard_verif_reporter(
@@ -1501,10 +1500,10 @@ pub mod tests {
let (test_srv_tc_tx, test_srv_tc_rx) = mpsc::channel(); let (test_srv_tc_tx, test_srv_tc_rx) = mpsc::channel();
let (tm_tx, tm_rx) = mpsc::channel(); let (tm_tx, tm_rx) = mpsc::channel();
let verif_cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap(); let verif_cfg = VerificationReporterConfig::new(TEST_APID, 1, 2, 8).unwrap();
let verification_handler = let verification_handler =
VerificationReporter::new(TEST_COMPONENT_ID_0.id(), &verif_cfg); VerificationReporter::new(TEST_COMPONENT_ID_0.id(), &verif_cfg);
let in_store_converter = EcssTcInVecConverter::default(); let in_store_converter = EcssTcVecCacher::default();
( (
Self { Self {
current_tm: None, current_tm: None,
@@ -1530,14 +1529,14 @@ pub mod tests {
PusServiceHelper< PusServiceHelper<
MpscTcReceiver, MpscTcReceiver,
MpscTmAsVecSender, MpscTmAsVecSender,
EcssTcInVecConverter, EcssTcVecCacher,
TestVerificationReporter, TestVerificationReporter,
>, >,
) { ) {
let (test_srv_tc_tx, test_srv_tc_rx) = mpsc::channel(); let (test_srv_tc_tx, test_srv_tc_rx) = mpsc::channel();
let (tm_tx, tm_rx) = mpsc::channel(); let (tm_tx, tm_rx) = mpsc::channel();
let in_store_converter = EcssTcInVecConverter::default(); let in_store_converter = EcssTcVecCacher::default();
let verification_handler = TestVerificationReporter::new(id); let verification_handler = TestVerificationReporter::new(id);
( (
Self { Self {

View File

@@ -878,22 +878,22 @@ mod tests {
) )
} }
fn scheduled_tc(timestamp: UnixTime, buf: &mut [u8]) -> PusTcCreator { fn scheduled_tc(timestamp: UnixTime, buf: &mut [u8]) -> PusTcCreator<'_> {
let (sph, len_app_data) = pus_tc_base(timestamp, buf); let (sph, len_app_data) = pus_tc_base(timestamp, buf);
PusTcCreator::new_simple(sph, 11, 4, &buf[..len_app_data], true) PusTcCreator::new_simple(sph, 11, 4, &buf[..len_app_data], true)
} }
fn wrong_tc_service(timestamp: UnixTime, buf: &mut [u8]) -> PusTcCreator { fn wrong_tc_service(timestamp: UnixTime, buf: &mut [u8]) -> PusTcCreator<'_> {
let (sph, len_app_data) = pus_tc_base(timestamp, buf); let (sph, len_app_data) = pus_tc_base(timestamp, buf);
PusTcCreator::new_simple(sph, 12, 4, &buf[..len_app_data], true) PusTcCreator::new_simple(sph, 12, 4, &buf[..len_app_data], true)
} }
fn wrong_tc_subservice(timestamp: UnixTime, buf: &mut [u8]) -> PusTcCreator { fn wrong_tc_subservice(timestamp: UnixTime, buf: &mut [u8]) -> PusTcCreator<'_> {
let (sph, len_app_data) = pus_tc_base(timestamp, buf); let (sph, len_app_data) = pus_tc_base(timestamp, buf);
PusTcCreator::new_simple(sph, 11, 5, &buf[..len_app_data], true) PusTcCreator::new_simple(sph, 11, 5, &buf[..len_app_data], true)
} }
fn double_wrapped_time_tagged_tc(timestamp: UnixTime, buf: &mut [u8]) -> PusTcCreator { fn double_wrapped_time_tagged_tc(timestamp: UnixTime, buf: &mut [u8]) -> PusTcCreator<'_> {
let cds_time = let cds_time =
cds::CdsTime::from_unix_time_with_u16_days(&timestamp, cds::SubmillisPrecision::Absent) cds::CdsTime::from_unix_time_with_u16_days(&timestamp, cds::SubmillisPrecision::Absent)
.unwrap(); .unwrap();

View File

@@ -1,9 +1,9 @@
use super::scheduler::PusSchedulerProvider; use super::scheduler::PusSchedulerProvider;
use super::verification::{VerificationReporter, VerificationReportingProvider}; use super::verification::{VerificationReporter, VerificationReportingProvider};
use super::{ use super::{
DirectPusPacketHandlerResult, EcssTcInMemConversionProvider, EcssTcInSharedPoolConverter, CacheAndReadRawEcssTc, DirectPusPacketHandlerResult, EcssTcInSharedPoolCacher, EcssTcReceiver,
EcssTcInVecConverter, EcssTcReceiver, EcssTmSender, HandlingStatus, MpscTcReceiver, EcssTcVecCacher, EcssTmSender, HandlingStatus, MpscTcReceiver, PartialPusHandlingError,
PartialPusHandlingError, PusServiceHelper, PusServiceHelper,
}; };
use crate::pool::PoolProvider; use crate::pool::PoolProvider;
use crate::pus::PusPacketHandlingError; use crate::pus::PusPacketHandlingError;
@@ -24,7 +24,7 @@ use std::sync::mpsc;
pub struct PusSchedServiceHandler< pub struct PusSchedServiceHandler<
TcReceiver: EcssTcReceiver, TcReceiver: EcssTcReceiver,
TmSender: EcssTmSender, TmSender: EcssTmSender,
TcInMemConverter: EcssTcInMemConversionProvider, TcInMemConverter: CacheAndReadRawEcssTc,
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
PusScheduler: PusSchedulerProvider, PusScheduler: PusSchedulerProvider,
> { > {
@@ -36,7 +36,7 @@ pub struct PusSchedServiceHandler<
impl< impl<
TcReceiver: EcssTcReceiver, TcReceiver: EcssTcReceiver,
TmSender: EcssTmSender, TmSender: EcssTmSender,
TcInMemConverter: EcssTcInMemConversionProvider, TcInMemConverter: CacheAndReadRawEcssTc,
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
Scheduler: PusSchedulerProvider, Scheduler: PusSchedulerProvider,
> PusSchedServiceHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter, Scheduler> > PusSchedServiceHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter, Scheduler>
@@ -213,7 +213,7 @@ impl<
pub type PusService11SchedHandlerDynWithMpsc<PusScheduler> = PusSchedServiceHandler< pub type PusService11SchedHandlerDynWithMpsc<PusScheduler> = PusSchedServiceHandler<
MpscTcReceiver, MpscTcReceiver,
mpsc::Sender<PacketAsVec>, mpsc::Sender<PacketAsVec>,
EcssTcInVecConverter, EcssTcVecCacher,
VerificationReporter, VerificationReporter,
PusScheduler, PusScheduler,
>; >;
@@ -222,7 +222,7 @@ pub type PusService11SchedHandlerDynWithMpsc<PusScheduler> = PusSchedServiceHand
pub type PusService11SchedHandlerDynWithBoundedMpsc<PusScheduler> = PusSchedServiceHandler< pub type PusService11SchedHandlerDynWithBoundedMpsc<PusScheduler> = PusSchedServiceHandler<
MpscTcReceiver, MpscTcReceiver,
mpsc::SyncSender<PacketAsVec>, mpsc::SyncSender<PacketAsVec>,
EcssTcInVecConverter, EcssTcVecCacher,
VerificationReporter, VerificationReporter,
PusScheduler, PusScheduler,
>; >;
@@ -231,7 +231,7 @@ pub type PusService11SchedHandlerDynWithBoundedMpsc<PusScheduler> = PusSchedServ
pub type PusService11SchedHandlerStaticWithMpsc<PusScheduler> = PusSchedServiceHandler< pub type PusService11SchedHandlerStaticWithMpsc<PusScheduler> = PusSchedServiceHandler<
MpscTcReceiver, MpscTcReceiver,
PacketSenderWithSharedPool, PacketSenderWithSharedPool,
EcssTcInSharedPoolConverter, EcssTcInSharedPoolCacher,
VerificationReporter, VerificationReporter,
PusScheduler, PusScheduler,
>; >;
@@ -240,7 +240,7 @@ pub type PusService11SchedHandlerStaticWithMpsc<PusScheduler> = PusSchedServiceH
pub type PusService11SchedHandlerStaticWithBoundedMpsc<PusScheduler> = PusSchedServiceHandler< pub type PusService11SchedHandlerStaticWithBoundedMpsc<PusScheduler> = PusSchedServiceHandler<
MpscTcReceiver, MpscTcReceiver,
PacketSenderWithSharedPool, PacketSenderWithSharedPool,
EcssTcInSharedPoolConverter, EcssTcInSharedPoolCacher,
VerificationReporter, VerificationReporter,
PusScheduler, PusScheduler,
>; >;
@@ -253,7 +253,7 @@ mod tests {
use crate::pus::{DirectPusPacketHandlerResult, MpscTcReceiver, PusPacketHandlingError}; use crate::pus::{DirectPusPacketHandlerResult, MpscTcReceiver, PusPacketHandlingError};
use crate::pus::{ use crate::pus::{
EcssTcInSharedPoolConverter, EcssTcInSharedPoolCacher,
scheduler::{self, PusSchedulerProvider, TcInfo}, scheduler::{self, PusSchedulerProvider, TcInfo},
tests::PusServiceHandlerWithSharedStoreCommon, tests::PusServiceHandlerWithSharedStoreCommon,
verification::{RequestId, TcStateAccepted, VerificationToken}, verification::{RequestId, TcStateAccepted, VerificationToken},
@@ -278,7 +278,7 @@ mod tests {
handler: PusSchedServiceHandler< handler: PusSchedServiceHandler<
MpscTcReceiver, MpscTcReceiver,
PacketSenderWithSharedPool, PacketSenderWithSharedPool,
EcssTcInSharedPoolConverter, EcssTcInSharedPoolCacher,
VerificationReporter, VerificationReporter,
TestScheduler, TestScheduler,
>, >,

View File

@@ -9,9 +9,8 @@ use std::sync::mpsc;
use super::verification::{VerificationReporter, VerificationReportingProvider}; use super::verification::{VerificationReporter, VerificationReportingProvider};
use super::{ use super::{
EcssTcInMemConversionProvider, EcssTcInSharedPoolConverter, EcssTcInVecConverter, CacheAndReadRawEcssTc, EcssTcInSharedPoolCacher, EcssTcReceiver, EcssTcVecCacher, EcssTmSender,
EcssTcReceiver, EcssTmSender, GenericConversionError, HandlingStatus, MpscTcReceiver, GenericConversionError, HandlingStatus, MpscTcReceiver, PusServiceHelper,
PusServiceHelper,
}; };
/// This is a helper class for [std] environments to handle generic PUS 17 (test service) packets. /// This is a helper class for [std] environments to handle generic PUS 17 (test service) packets.
@@ -19,7 +18,7 @@ use super::{
pub struct PusService17TestHandler< pub struct PusService17TestHandler<
TcReceiver: EcssTcReceiver, TcReceiver: EcssTcReceiver,
TmSender: EcssTmSender, TmSender: EcssTmSender,
TcInMemConverter: EcssTcInMemConversionProvider, TcInMemConverter: CacheAndReadRawEcssTc,
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
> { > {
pub service_helper: pub service_helper:
@@ -29,7 +28,7 @@ pub struct PusService17TestHandler<
impl< impl<
TcReceiver: EcssTcReceiver, TcReceiver: EcssTcReceiver,
TmSender: EcssTmSender, TmSender: EcssTmSender,
TcInMemConverter: EcssTcInMemConversionProvider, TcInMemConverter: CacheAndReadRawEcssTc,
VerificationReporter: VerificationReportingProvider, VerificationReporter: VerificationReportingProvider,
> PusService17TestHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter> > PusService17TestHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
{ {
@@ -112,7 +111,7 @@ impl<
pub type PusService17TestHandlerDynWithMpsc = PusService17TestHandler< pub type PusService17TestHandlerDynWithMpsc = PusService17TestHandler<
MpscTcReceiver, MpscTcReceiver,
mpsc::Sender<PacketAsVec>, mpsc::Sender<PacketAsVec>,
EcssTcInVecConverter, EcssTcVecCacher,
VerificationReporter, VerificationReporter,
>; >;
/// Helper type definition for a PUS 17 handler with a dynamic TMTC memory backend and bounded MPSC /// Helper type definition for a PUS 17 handler with a dynamic TMTC memory backend and bounded MPSC
@@ -120,7 +119,7 @@ pub type PusService17TestHandlerDynWithMpsc = PusService17TestHandler<
pub type PusService17TestHandlerDynWithBoundedMpsc = PusService17TestHandler< pub type PusService17TestHandlerDynWithBoundedMpsc = PusService17TestHandler<
MpscTcReceiver, MpscTcReceiver,
mpsc::SyncSender<PacketAsVec>, mpsc::SyncSender<PacketAsVec>,
EcssTcInVecConverter, EcssTcVecCacher,
VerificationReporter, VerificationReporter,
>; >;
/// Helper type definition for a PUS 17 handler with a shared store TMTC memory backend and bounded /// Helper type definition for a PUS 17 handler with a shared store TMTC memory backend and bounded
@@ -128,7 +127,7 @@ pub type PusService17TestHandlerDynWithBoundedMpsc = PusService17TestHandler<
pub type PusService17TestHandlerStaticWithBoundedMpsc = PusService17TestHandler< pub type PusService17TestHandlerStaticWithBoundedMpsc = PusService17TestHandler<
MpscTcReceiver, MpscTcReceiver,
PacketSenderWithSharedPool, PacketSenderWithSharedPool,
EcssTcInSharedPoolConverter, EcssTcInSharedPoolCacher,
VerificationReporter, VerificationReporter,
>; >;
@@ -144,7 +143,7 @@ mod tests {
}; };
use crate::pus::verification::{TcStateAccepted, VerificationToken}; use crate::pus::verification::{TcStateAccepted, VerificationToken};
use crate::pus::{ use crate::pus::{
DirectPusPacketHandlerResult, EcssTcInSharedPoolConverter, EcssTcInVecConverter, DirectPusPacketHandlerResult, EcssTcInSharedPoolCacher, EcssTcVecCacher,
GenericConversionError, HandlingStatus, MpscTcReceiver, MpscTmAsVecSender, GenericConversionError, HandlingStatus, MpscTcReceiver, MpscTmAsVecSender,
PartialPusHandlingError, PusPacketHandlingError, PartialPusHandlingError, PusPacketHandlingError,
}; };
@@ -163,7 +162,7 @@ mod tests {
handler: PusService17TestHandler< handler: PusService17TestHandler<
MpscTcReceiver, MpscTcReceiver,
PacketSenderWithSharedPool, PacketSenderWithSharedPool,
EcssTcInSharedPoolConverter, EcssTcInSharedPoolCacher,
VerificationReporter, VerificationReporter,
>, >,
} }
@@ -225,7 +224,7 @@ mod tests {
handler: PusService17TestHandler< handler: PusService17TestHandler<
MpscTcReceiver, MpscTcReceiver,
MpscTmAsVecSender, MpscTmAsVecSender,
EcssTcInVecConverter, EcssTcVecCacher,
VerificationReporter, VerificationReporter,
>, >,
} }

View File

@@ -17,7 +17,7 @@
//! use std::time::Duration; //! use std::time::Duration;
//! use satrs::pool::{PoolProviderWithGuards, StaticMemoryPool, StaticPoolConfig}; //! use satrs::pool::{PoolProviderWithGuards, StaticMemoryPool, StaticPoolConfig};
//! use satrs::pus::verification::{ //! use satrs::pus::verification::{
//! VerificationReportingProvider, VerificationReporterCfg, VerificationReporter //! VerificationReportingProvider, VerificationReporterConfig, VerificationReporter
//! }; //! };
//! use satrs::tmtc::{SharedStaticMemoryPool, PacketSenderWithSharedPool}; //! use satrs::tmtc::{SharedStaticMemoryPool, PacketSenderWithSharedPool};
//! use satrs::spacepackets::seq_count::SeqCountProviderSimple; //! use satrs::spacepackets::seq_count::SeqCountProviderSimple;
@@ -38,7 +38,7 @@
//! let shared_tm_pool = SharedStaticMemoryPool::new(RwLock::new(tm_pool)); //! let shared_tm_pool = SharedStaticMemoryPool::new(RwLock::new(tm_pool));
//! let (verif_tx, verif_rx) = mpsc::sync_channel(10); //! let (verif_tx, verif_rx) = mpsc::sync_channel(10);
//! let sender = PacketSenderWithSharedPool::new_with_shared_packet_pool(verif_tx, &shared_tm_pool); //! let sender = PacketSenderWithSharedPool::new_with_shared_packet_pool(verif_tx, &shared_tm_pool);
//! let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap(); //! let cfg = VerificationReporterConfig::new(TEST_APID, 1, 2, 8).unwrap();
//! let mut reporter = VerificationReporter::new(TEST_COMPONENT_ID.id(), &cfg); //! let mut reporter = VerificationReporter::new(TEST_COMPONENT_ID.id(), &cfg);
//! //!
//! let tc_header = PusTcSecondaryHeader::new_simple(17, 1); //! let tc_header = PusTcSecondaryHeader::new_simple(17, 1);
@@ -511,9 +511,7 @@ impl VerificationReportCreator {
self.dest_id = dest_id; self.dest_id = dest_id;
} }
/// Initialize verification handling by passing a TC reference. This returns a token required pub fn read_request_id(&self, pus_tc: &(impl CcsdsPacket + IsPusTelecommand)) -> RequestId {
/// to call the acceptance functions
pub fn read_request_id_from_tc(pus_tc: &(impl CcsdsPacket + IsPusTelecommand)) -> RequestId {
RequestId::new(pus_tc) RequestId::new(pus_tc)
} }
@@ -846,14 +844,14 @@ pub mod alloc_mod {
use core::cell::RefCell; use core::cell::RefCell;
#[derive(Clone)] #[derive(Clone)]
pub struct VerificationReporterCfg { pub struct VerificationReporterConfig {
apid: u16, apid: u16,
pub step_field_width: usize, pub step_field_width: usize,
pub fail_code_field_width: usize, pub fail_code_field_width: usize,
pub max_fail_data_len: usize, pub max_fail_data_len: usize,
} }
impl VerificationReporterCfg { impl VerificationReporterConfig {
pub fn new( pub fn new(
apid: u16, apid: u16,
step_field_width: usize, step_field_width: usize,
@@ -876,7 +874,7 @@ pub mod alloc_mod {
/// ///
/// The [Self::modify_tm] function is called before the TM is sent. This allows users to change /// The [Self::modify_tm] function is called before the TM is sent. This allows users to change
/// fields like the message count or sequence counter before the TM is sent. /// fields like the message count or sequence counter before the TM is sent.
pub trait VerificationHookProvider { pub trait VerificationHook {
fn modify_tm(&self, tm: &mut PusTmCreator); fn modify_tm(&self, tm: &mut PusTmCreator);
} }
@@ -886,7 +884,7 @@ pub mod alloc_mod {
#[derive(Default, Copy, Clone)] #[derive(Default, Copy, Clone)]
pub struct DummyVerificationHook {} pub struct DummyVerificationHook {}
impl VerificationHookProvider for DummyVerificationHook { impl VerificationHook for DummyVerificationHook {
fn modify_tm(&self, _tm: &mut PusTmCreator) {} fn modify_tm(&self, _tm: &mut PusTmCreator) {}
} }
@@ -899,16 +897,16 @@ pub mod alloc_mod {
/// destination fields are assumed to be constant for a given repoter instance. /// destination fields are assumed to be constant for a given repoter instance.
#[derive(Clone)] #[derive(Clone)]
pub struct VerificationReporter< pub struct VerificationReporter<
VerificationHook: VerificationHookProvider = DummyVerificationHook, VerificationHookInstance: VerificationHook = DummyVerificationHook,
> { > {
owner_id: ComponentId, owner_id: ComponentId,
source_data_buf: RefCell<alloc::vec::Vec<u8>>, source_data_buf: RefCell<alloc::vec::Vec<u8>>,
pub reporter_creator: VerificationReportCreator, pub report_creator: VerificationReportCreator,
pub tm_hook: VerificationHook, pub tm_hook: VerificationHookInstance,
} }
impl VerificationReporter<DummyVerificationHook> { impl VerificationReporter<DummyVerificationHook> {
pub fn new(owner_id: ComponentId, cfg: &VerificationReporterCfg) -> Self { pub fn new(owner_id: ComponentId, cfg: &VerificationReporterConfig) -> Self {
let reporter = VerificationReportCreator::new(cfg.apid).unwrap(); let reporter = VerificationReportCreator::new(cfg.apid).unwrap();
Self { Self {
owner_id, owner_id,
@@ -919,19 +917,19 @@ pub mod alloc_mod {
+ cfg.fail_code_field_width + cfg.fail_code_field_width
+ cfg.max_fail_data_len + cfg.max_fail_data_len
]), ]),
reporter_creator: reporter, report_creator: reporter,
tm_hook: DummyVerificationHook::default(), tm_hook: DummyVerificationHook::default(),
} }
} }
} }
impl<VerificationHook: VerificationHookProvider> VerificationReporter<VerificationHook> { impl<VerificationHookInstance: VerificationHook> VerificationReporter<VerificationHookInstance> {
/// The provided [VerificationHookProvider] can be used to modify a verification packet /// The provided [VerificationHookProvider] can be used to modify a verification packet
/// before it is sent. /// before it is sent.
pub fn new_with_hook( pub fn new_with_hook(
owner_id: ComponentId, owner_id: ComponentId,
cfg: &VerificationReporterCfg, cfg: &VerificationReporterConfig,
tm_hook: VerificationHook, tm_hook: VerificationHookInstance,
) -> Self { ) -> Self {
let reporter = VerificationReportCreator::new(cfg.apid).unwrap(); let reporter = VerificationReportCreator::new(cfg.apid).unwrap();
Self { Self {
@@ -943,7 +941,7 @@ pub mod alloc_mod {
+ cfg.fail_code_field_width + cfg.fail_code_field_width
+ cfg.max_fail_data_len + cfg.max_fail_data_len
]), ]),
reporter_creator: reporter, report_creator: reporter,
tm_hook, tm_hook,
} }
} }
@@ -952,9 +950,7 @@ pub mod alloc_mod {
&self, &self,
pus_tc: &(impl CcsdsPacket + IsPusTelecommand), pus_tc: &(impl CcsdsPacket + IsPusTelecommand),
) -> VerificationToken<TcStateNone> { ) -> VerificationToken<TcStateNone> {
VerificationToken::<TcStateNone>::new( VerificationToken::<TcStateNone>::new(self.report_creator.read_request_id(pus_tc))
VerificationReportCreator::read_request_id_from_tc(pus_tc),
)
} }
pub fn start_verification_with_req_id( pub fn start_verification_with_req_id(
@@ -965,7 +961,7 @@ pub mod alloc_mod {
} }
delegate!( delegate!(
to self.reporter_creator { to self.report_creator {
pub fn set_apid(&mut self, apid: u16) -> bool; pub fn set_apid(&mut self, apid: u16) -> bool;
pub fn apid(&self) -> u16; pub fn apid(&self) -> u16;
pub fn dest_id(&self) -> u16; pub fn dest_id(&self) -> u16;
@@ -978,11 +974,11 @@ pub mod alloc_mod {
} }
} }
impl<VerificationHook: VerificationHookProvider> VerificationReportingProvider impl<VerificationHookInstance: VerificationHook> VerificationReportingProvider
for VerificationReporter<VerificationHook> for VerificationReporter<VerificationHookInstance>
{ {
delegate!( delegate!(
to self.reporter_creator { to self.report_creator {
fn set_apid(&mut self, apid: Apid); fn set_apid(&mut self, apid: Apid);
fn apid(&self) -> Apid; fn apid(&self) -> Apid;
} }
@@ -1008,7 +1004,7 @@ pub mod alloc_mod {
) -> Result<VerificationToken<TcStateAccepted>, EcssTmtcError> { ) -> Result<VerificationToken<TcStateAccepted>, EcssTmtcError> {
let mut source_data_buf = self.source_data_buf.borrow_mut(); let mut source_data_buf = self.source_data_buf.borrow_mut();
let mut tm_creator = self let mut tm_creator = self
.reporter_creator .report_creator
.acceptance_success( .acceptance_success(
source_data_buf.as_mut_slice(), source_data_buf.as_mut_slice(),
&token.request_id(), &token.request_id(),
@@ -1031,7 +1027,7 @@ pub mod alloc_mod {
) -> Result<(), EcssTmtcError> { ) -> Result<(), EcssTmtcError> {
let mut buf = self.source_data_buf.borrow_mut(); let mut buf = self.source_data_buf.borrow_mut();
let mut tm_creator = self let mut tm_creator = self
.reporter_creator .report_creator
.acceptance_failure(buf.as_mut_slice(), &token.request_id(), 0, 0, params) .acceptance_failure(buf.as_mut_slice(), &token.request_id(), 0, 0, params)
.map_err(PusError::ByteConversion)?; .map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator); self.tm_hook.modify_tm(&mut tm_creator);
@@ -1050,7 +1046,7 @@ pub mod alloc_mod {
) -> Result<VerificationToken<TcStateStarted>, EcssTmtcError> { ) -> Result<VerificationToken<TcStateStarted>, EcssTmtcError> {
let mut buf = self.source_data_buf.borrow_mut(); let mut buf = self.source_data_buf.borrow_mut();
let mut tm_creator = self let mut tm_creator = self
.reporter_creator .report_creator
.start_success(buf.as_mut_slice(), &token.request_id(), 0, 0, time_stamp) .start_success(buf.as_mut_slice(), &token.request_id(), 0, 0, time_stamp)
.map_err(PusError::ByteConversion)?; .map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator); self.tm_hook.modify_tm(&mut tm_creator);
@@ -1070,7 +1066,7 @@ pub mod alloc_mod {
) -> Result<(), EcssTmtcError> { ) -> Result<(), EcssTmtcError> {
let mut buf = self.source_data_buf.borrow_mut(); let mut buf = self.source_data_buf.borrow_mut();
let mut tm_creator = self let mut tm_creator = self
.reporter_creator .report_creator
.start_failure(buf.as_mut_slice(), &token.request_id(), 0, 0, params) .start_failure(buf.as_mut_slice(), &token.request_id(), 0, 0, params)
.map_err(PusError::ByteConversion)?; .map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator); self.tm_hook.modify_tm(&mut tm_creator);
@@ -1090,7 +1086,7 @@ pub mod alloc_mod {
) -> Result<(), EcssTmtcError> { ) -> Result<(), EcssTmtcError> {
let mut buf = self.source_data_buf.borrow_mut(); let mut buf = self.source_data_buf.borrow_mut();
let mut tm_creator = self let mut tm_creator = self
.reporter_creator .report_creator
.step_success( .step_success(
buf.as_mut_slice(), buf.as_mut_slice(),
&token.request_id(), &token.request_id(),
@@ -1117,7 +1113,7 @@ pub mod alloc_mod {
) -> Result<(), EcssTmtcError> { ) -> Result<(), EcssTmtcError> {
let mut buf = self.source_data_buf.borrow_mut(); let mut buf = self.source_data_buf.borrow_mut();
let mut tm_creator = self let mut tm_creator = self
.reporter_creator .report_creator
.step_failure(buf.as_mut_slice(), token, 0, 0, params) .step_failure(buf.as_mut_slice(), token, 0, 0, params)
.map_err(PusError::ByteConversion)?; .map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator); self.tm_hook.modify_tm(&mut tm_creator);
@@ -1138,7 +1134,7 @@ pub mod alloc_mod {
) -> Result<(), EcssTmtcError> { ) -> Result<(), EcssTmtcError> {
let mut buf = self.source_data_buf.borrow_mut(); let mut buf = self.source_data_buf.borrow_mut();
let mut tm_creator = self let mut tm_creator = self
.reporter_creator .report_creator
.completion_success(buf.as_mut_slice(), &token.request_id(), 0, 0, time_stamp) .completion_success(buf.as_mut_slice(), &token.request_id(), 0, 0, time_stamp)
.map_err(PusError::ByteConversion)?; .map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator); self.tm_hook.modify_tm(&mut tm_creator);
@@ -1158,7 +1154,7 @@ pub mod alloc_mod {
) -> Result<(), EcssTmtcError> { ) -> Result<(), EcssTmtcError> {
let mut buf = self.source_data_buf.borrow_mut(); let mut buf = self.source_data_buf.borrow_mut();
let mut tm_creator = self let mut tm_creator = self
.reporter_creator .report_creator
.completion_failure(buf.as_mut_slice(), &token.request_id(), 0, 00, params) .completion_failure(buf.as_mut_slice(), &token.request_id(), 0, 00, params)
.map_err(PusError::ByteConversion)?; .map_err(PusError::ByteConversion)?;
self.tm_hook.modify_tm(&mut tm_creator); self.tm_hook.modify_tm(&mut tm_creator);
@@ -1693,7 +1689,7 @@ pub mod tests {
use crate::pus::tests::CommonTmInfo; use crate::pus::tests::CommonTmInfo;
use crate::pus::verification::{ use crate::pus::verification::{
EcssTmSender, EcssTmtcError, FailParams, FailParamsWithStep, RequestId, TcStateNone, EcssTmSender, EcssTmtcError, FailParams, FailParamsWithStep, RequestId, TcStateNone,
VerificationReporter, VerificationReporterCfg, VerificationToken, VerificationReporter, VerificationReporterConfig, VerificationToken,
handle_step_failure_with_generic_params, handle_step_failure_with_generic_params,
}; };
use crate::pus::{ChannelWithId, PusTmVariant}; use crate::pus::{ChannelWithId, PusTmVariant};
@@ -1717,8 +1713,8 @@ pub mod tests {
use super::{ use super::{
DummyVerificationHook, FailParamHelper, SeqCountProviderSimple, TcStateAccepted, DummyVerificationHook, FailParamHelper, SeqCountProviderSimple, TcStateAccepted,
TcStateStarted, VerificationHookProvider, VerificationReportingProvider, TcStateStarted, VerificationHook, VerificationReportingProvider, WasAtLeastAccepted,
WasAtLeastAccepted, handle_completion_failure_with_generic_params, handle_completion_failure_with_generic_params,
}; };
fn is_send<T: Send>(_: &T) {} fn is_send<T: Send>(_: &T) {}
@@ -1787,7 +1783,7 @@ pub mod tests {
pub msg_counter: SeqCountProviderSimple<u16>, pub msg_counter: SeqCountProviderSimple<u16>,
} }
impl VerificationHookProvider for SequenceCounterHook { impl VerificationHook for SequenceCounterHook {
fn modify_tm(&self, tm: &mut spacepackets::ecss::tm::PusTmCreator) { fn modify_tm(&self, tm: &mut spacepackets::ecss::tm::PusTmCreator) {
tm.set_seq_count(self.seq_counter.get_and_increment()); tm.set_seq_count(self.seq_counter.get_and_increment());
tm.set_msg_counter(self.msg_counter.get_and_increment()); tm.set_msg_counter(self.msg_counter.get_and_increment());
@@ -1795,29 +1791,29 @@ pub mod tests {
} }
struct VerificationReporterTestbench< struct VerificationReporterTestbench<
VerificationHook: VerificationHookProvider = DummyVerificationHook, VerificationHookInstance: VerificationHook = DummyVerificationHook,
> { > {
pub id: ComponentId, pub id: ComponentId,
sender: TestSender, sender: TestSender,
reporter: VerificationReporter<VerificationHook>, reporter: VerificationReporter<VerificationHookInstance>,
pub request_id: RequestId, pub request_id: RequestId,
tc: Vec<u8>, tc: Vec<u8>,
} }
fn base_reporter(id: ComponentId, max_fail_data_len: usize) -> VerificationReporter { fn base_reporter(id: ComponentId, max_fail_data_len: usize) -> VerificationReporter {
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, max_fail_data_len).unwrap(); let cfg = VerificationReporterConfig::new(TEST_APID, 1, 2, max_fail_data_len).unwrap();
VerificationReporter::new(id, &cfg) VerificationReporter::new(id, &cfg)
} }
fn reporter_with_hook<VerificationHook: VerificationHookProvider>( fn reporter_with_hook<VerificationHookInstance: VerificationHook>(
id: ComponentId, id: ComponentId,
hook: VerificationHook, hook: VerificationHookInstance,
) -> VerificationReporter<VerificationHook> { ) -> VerificationReporter<VerificationHookInstance> {
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap(); let cfg = VerificationReporterConfig::new(TEST_APID, 1, 2, 8).unwrap();
VerificationReporter::new_with_hook(id, &cfg, hook) VerificationReporter::new_with_hook(id, &cfg, hook)
} }
impl<VerificiationHook: VerificationHookProvider> VerificationReporterTestbench<VerificiationHook> { impl<VerificiationHook: VerificationHook> VerificationReporterTestbench<VerificiationHook> {
fn new_with_hook(id: ComponentId, tc: PusTcCreator, tm_hook: VerificiationHook) -> Self { fn new_with_hook(id: ComponentId, tc: PusTcCreator, tm_hook: VerificiationHook) -> Self {
let reporter = reporter_with_hook(id, tm_hook); let reporter = reporter_with_hook(id, tm_hook);
Self { Self {

View File

@@ -1,7 +1,7 @@
use core::fmt::Debug; use core::fmt::Debug;
/// Generic abstraction for a check/countdown timer. /// Generic abstraction for a check/countdown timer.
pub trait CountdownProvider: Debug { pub trait Countdown: Debug {
fn has_expired(&self) -> bool; fn has_expired(&self) -> bool;
fn reset(&mut self); fn reset(&mut self);
} }

View File

@@ -4,7 +4,7 @@ pub mod crossbeam_test {
use satrs::pool::{PoolProvider, PoolProviderWithGuards, StaticMemoryPool, StaticPoolConfig}; use satrs::pool::{PoolProvider, PoolProviderWithGuards, StaticMemoryPool, StaticPoolConfig};
use satrs::pus::test_util::{TEST_APID, TEST_COMPONENT_ID_0}; use satrs::pus::test_util::{TEST_APID, TEST_COMPONENT_ID_0};
use satrs::pus::verification::{ use satrs::pus::verification::{
FailParams, RequestId, VerificationReporter, VerificationReporterCfg, FailParams, RequestId, VerificationReporter, VerificationReporterConfig,
VerificationReportingProvider, VerificationReportingProvider,
}; };
use satrs::tmtc::{PacketSenderWithSharedPool, SharedStaticMemoryPool}; use satrs::tmtc::{PacketSenderWithSharedPool, SharedStaticMemoryPool};
@@ -31,7 +31,7 @@ pub mod crossbeam_test {
// We use a synced sequence count provider here because both verification reporters have the // We use a synced sequence count provider here because both verification reporters have the
// the same APID. If they had distinct APIDs, the more correct approach would be to have // the same APID. If they had distinct APIDs, the more correct approach would be to have
// each reporter have an own sequence count provider. // each reporter have an own sequence count provider.
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap(); let cfg = VerificationReporterConfig::new(TEST_APID, 1, 2, 8).unwrap();
// Shared pool object to store the verification PUS telemetry // Shared pool object to store the verification PUS telemetry
let pool_cfg = StaticPoolConfig::new_from_subpool_cfg_tuples( let pool_cfg = StaticPoolConfig::new_from_subpool_cfg_tuples(
vec![(10, 32), (10, 64), (10, 128), (10, 1024)], vec![(10, 32), (10, 64), (10, 128), (10, 1024)],