added stuff, preparing for change of packageids

This commit is contained in:
lkoester 2023-01-18 10:04:36 +01:00
parent 154e4ef4ce
commit 7ae4701e5f
20 changed files with 1907 additions and 307 deletions

View File

@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Cross Remote Debug" type="com.jetbrains.cidr.remote.gdbserver.type" factoryName="com.jetbrains.cidr.remote.gdbserver.factory" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="eurosim-obsw" TARGET_NAME="Cross" CONFIG_NAME="Cross" version="1" RUN_PATH="$PROJECT_DIR$/target/armv7-unknown-linux-gnueabihf/debug/eurosim-obsw">
<custom-gdb-server version="1" gdb-connect="obc.local:1234" executable="" warmup-ms="0" download-type="ALWAYS" sshConfigName="koesterl@obc.local:22 password" uploadFile="/tmp/CLion/debug/eurosim-obsw" defaultGdbServerArgs=":1234 /tmp/CLion/debug/eurosim-obsw">
<debugger kind="GDB" isBundled="true" />
</custom-gdb-server>
<method v="2">
<option name="CLION.COMPOUND.BUILD" enabled="true" />
</method>
</configuration>
</component>

View File

@ -3,7 +3,7 @@
<option name="command" value="run --package eurosim-obsw --bin eurosim-obsw" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="requiredFeatures" value="false" />
<option name="allFeatures" value="false" />
<option name="emulateTerminal" value="false" />
<option name="withSudo" value="false" />

265
Cargo.lock generated
View File

@ -23,12 +23,12 @@ dependencies = [
]
[[package]]
name = "atomic-polyfill"
version = "0.1.11"
name = "array-init"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28"
checksum = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72"
dependencies = [
"critical-section",
"nodrop",
]
[[package]]
@ -43,12 +43,30 @@ version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "bitflags"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bstr"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"lazy_static",
"memchr",
"regex-automata",
"serde",
]
[[package]]
name = "bumpalo"
version = "3.11.1"
@ -93,6 +111,7 @@ dependencies = [
"iana-time-zone",
"num-integer",
"num-traits",
"serde",
"winapi",
]
@ -127,12 +146,6 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff"
[[package]]
name = "critical-section"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52"
[[package]]
name = "crossbeam-channel"
version = "0.5.6"
@ -152,6 +165,28 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "csv"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1"
dependencies = [
"bstr",
"csv-core",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "csv-core"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90"
dependencies = [
"memchr",
]
[[package]]
name = "cxx"
version = "1.0.83"
@ -196,17 +231,6 @@ dependencies = [
"syn",
]
[[package]]
name = "delegate"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d70a2d4995466955a415223acf3c9c934b9ff2339631cdf4ffc893da4bacd717"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "delegate"
version = "0.8.0"
@ -247,16 +271,8 @@ name = "eurosim-obsw"
version = "0.1.0"
dependencies = [
"satrs-core",
"spacepackets",
]
[[package]]
name = "hash32"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
dependencies = [
"byteorder",
"satrs-mib",
"socketcan",
]
[[package]]
@ -268,19 +284,6 @@ dependencies = [
"ahash",
]
[[package]]
name = "heapless"
version = "0.7.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743"
dependencies = [
"atomic-polyfill",
"hash32",
"rustc_version",
"spin",
"stable_deref_trait",
]
[[package]]
name = "hermit-abi"
version = "0.1.19"
@ -290,6 +293,12 @@ dependencies = [
"libc",
]
[[package]]
name = "hex"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa"
[[package]]
name = "iana-time-zone"
version = "0.1.53"
@ -314,6 +323,18 @@ dependencies = [
"cxx-build",
]
[[package]]
name = "itertools"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a9b56eb56058f43dc66e58f40a214b2ccbc9f3df51861b63d51dec7b65bc3f"
[[package]]
name = "itoa"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "js-sys"
version = "0.3.60"
@ -323,6 +344,12 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.138"
@ -338,16 +365,6 @@ dependencies = [
"cc",
]
[[package]]
name = "lock_api"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.17"
@ -357,6 +374,34 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "nix"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfb3ddedaa14746434a02041940495bf11325c22f6d36125d3bdd56090d50a79"
dependencies = [
"bitflags 0.4.0",
"libc",
]
[[package]]
name = "nodrop"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "num-integer"
version = "0.1.45"
@ -401,7 +446,7 @@ dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"smallvec 1.10.0",
"windows-sys",
]
@ -435,17 +480,20 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags",
"bitflags 1.3.2",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]]
name = "ryu"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
[[package]]
name = "satrs-core"
@ -453,22 +501,37 @@ version = "0.1.0"
dependencies = [
"bus",
"crossbeam-channel",
"delegate 0.8.0",
"delegate",
"downcast-rs",
"dyn-clone",
"embed-doc-image",
"hashbrown",
"heapless",
"num-traits",
"paste",
"serde",
"spacepackets",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
name = "satrs-mib"
version = "0.1.0"
dependencies = [
"csv",
"satrs-core",
"satrs-mib-codegen",
"serde",
"serde-hex",
]
[[package]]
name = "satrs-mib-codegen"
version = "0.1.0"
dependencies = [
"proc-macro2",
"quote",
"satrs-core",
"syn",
]
[[package]]
name = "scratch"
@ -476,12 +539,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
[[package]]
name = "semver"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
[[package]]
name = "serde"
version = "1.0.150"
@ -491,6 +548,17 @@ dependencies = [
"serde_derive",
]
[[package]]
name = "serde-hex"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca37e3e4d1b39afd7ff11ee4e947efae85adfddf4841787bfa47c470e96dc26d"
dependencies = [
"array-init",
"serde",
"smallvec 0.6.14",
]
[[package]]
name = "serde_derive"
version = "1.0.150"
@ -502,39 +570,48 @@ dependencies = [
"syn",
]
[[package]]
name = "smallvec"
version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0"
dependencies = [
"maybe-uninit",
]
[[package]]
name = "smallvec"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "socketcan"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3101efc6ef5af6f1c1a488241b469757b7a183baca63af958cd90e4696446c80"
dependencies = [
"hex",
"itertools",
"libc",
"nix",
"try_from",
]
[[package]]
name = "spacepackets"
version = "0.2.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9199251260fa674673a195bbe68703ba8d7ac0875d97df05cd4b5618218da054"
dependencies = [
"chrono",
"crc",
"delegate 0.7.0",
"delegate",
"num-traits",
"serde",
"zerocopy",
]
[[package]]
name = "spin"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09"
dependencies = [
"lock_api",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "syn"
version = "1.0.105"
@ -555,6 +632,12 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "try_from"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "923a7ee3e97dbfe8685261beb4511cc9620a1252405d02693d43169729570111"
[[package]]
name = "unicode-ident"
version = "1.0.5"

View File

@ -13,11 +13,17 @@ categories = ["aerospace", "hardware-support", "embedded"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
socketcan = {version = "1.7.0", optional = true }
[dependencies.spacepackets]
path = "../satrs-launchpad/spacepackets"
#[dependencies.spacepackets]
#path = "../satrs-launchpad/spacepackets"
[dependencies.satrs-core]
path = "../satrs-launchpad/satrs-core"
[dependencies.satrs-mib]
path = "../satrs-launchpad/satrs-mib"
[features]
default = ["can"]
can = ["socketcan"]

6
pyclient/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
/venv
/log
/.idea/*
!/.idea/runConfigurations
/seqcnt.txt

322
pyclient/main.py Normal file
View File

@ -0,0 +1,322 @@
#!/usr/bin/env python3
"""Example client for the sat-rs example application"""
import enum
import struct
import sys
import time
from typing import Optional
import tmtccmd
from spacepackets.ecss import PusTelemetry, PusTelecommand, PusVerificator
from spacepackets.ecss.pus_17_test import Service17Tm
from spacepackets.ecss.pus_1_verification import UnpackParams, Service1Tm
from tmtccmd import CcsdsTmtcBackend, TcHandlerBase, ProcedureParamsWrapper
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.core.base import BackendRequest
from tmtccmd.pus import VerificationWrapper
from tmtccmd.tm import CcsdsTmHandler, SpecificApidHandlerBase
from tmtccmd.com_if import ComInterface
from tmtccmd.config import (
default_json_path,
SetupParams,
TmTcCfgHookBase,
TmtcDefinitionWrapper,
CoreServiceList,
OpCodeEntry,
params_to_procedure_conversion,
)
from tmtccmd.config import PreArgsParsingWrapper, SetupWrapper
from tmtccmd.logging import get_console_logger
from tmtccmd.logging.pus import (
RegularTmtcLogWrapper,
RawTmtcTimedLogWrapper,
TimedLogWhen,
)
from tmtccmd.tc import (
TcQueueEntryType,
ProcedureWrapper,
TcProcedureType,
FeedWrapper,
SendCbParams,
DefaultPusQueueHelper,
)
from tmtccmd.tm.pus_5_event import Service5Tm
from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider
from tmtccmd.util.obj_id import ObjectIdDictT
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
LOGGER = get_console_logger()
EXAMPLE_PUS_APID = 0x02
class SatRsConfigHook(TmTcCfgHookBase):
def __init__(self, json_cfg_path: str):
super().__init__(json_cfg_path=json_cfg_path)
def assign_communication_interface(self, com_if_key: str) -> Optional[ComInterface]:
from tmtccmd.config.com_if import (
create_com_interface_default,
create_com_interface_cfg_default,
)
cfg = create_com_interface_cfg_default(
com_if_key=com_if_key,
json_cfg_path=self.cfg_path,
space_packet_ids=None,
)
return create_com_interface_default(cfg)
def get_tmtc_definitions(self) -> TmtcDefinitionWrapper:
from tmtccmd.config.globals import get_default_tmtc_defs
defs = get_default_tmtc_defs()
srv_5 = OpCodeEntry()
srv_5.add("0", "Event Test")
defs.add_service(
name=CoreServiceList.SERVICE_5.value,
info="PUS Service 5 Event",
op_code_entry=srv_5,
)
srv_17 = OpCodeEntry()
srv_17.add("0", "Ping Test")
defs.add_service(
name=CoreServiceList.SERVICE_17_ALT,
info="PUS Service 17 Test",
op_code_entry=srv_17,
)
srv_3 = OpCodeEntry()
srv_3.add(HkOpCodes.GENERATE_ONE_SHOT, "Generate AOCS one shot HK")
defs.add_service(
name=CoreServiceList.SERVICE_3,
info="PUS Service 3 Housekeeping",
op_code_entry=srv_3
)
return defs
def perform_mode_operation(self, tmtc_backend: CcsdsTmtcBackend, mode: int):
LOGGER.info("Mode operation hook was called")
pass
def get_object_ids(self) -> ObjectIdDictT:
from tmtccmd.config.objects import get_core_object_ids
return get_core_object_ids()
class PusHandler(SpecificApidHandlerBase):
def __init__(
self,
verif_wrapper: VerificationWrapper,
printer: FsfwTmTcPrinter,
raw_logger: RawTmtcTimedLogWrapper,
):
super().__init__(EXAMPLE_PUS_APID, None)
self.printer = printer
self.raw_logger = raw_logger
self.verif_wrapper = verif_wrapper
def handle_tm(self, packet: bytes, _user_args: any):
try:
tm_packet = PusTelemetry.unpack(packet)
except ValueError as e:
LOGGER.warning("Could not generate PUS TM object from raw data")
LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}")
raise e
service = tm_packet.service
dedicated_handler = False
if service == 1:
tm_packet = Service1Tm.unpack(data=packet, params=UnpackParams(1, 2))
res = self.verif_wrapper.add_tm(tm_packet)
if res is None:
LOGGER.info(
f"Received Verification TM[{tm_packet.service}, {tm_packet.subservice}] "
f"with Request ID {tm_packet.tc_req_id.as_u32():#08x}"
)
LOGGER.warning(
f"No matching telecommand found for {tm_packet.tc_req_id}"
)
else:
self.verif_wrapper.log_to_console(tm_packet, res)
self.verif_wrapper.log_to_file(tm_packet, res)
dedicated_handler = True
if service == 3:
LOGGER.info("No handling for HK packets implemented")
LOGGER.info(f"Raw packet: 0x[{packet.hex(sep=',')}]")
pus_tm = PusTelemetry.unpack(packet)
if pus_tm.subservice == 25:
if len(pus_tm.source_data) < 8:
raise ValueError("No addressable ID in HK packet")
json_str = pus_tm.source_data[8:]
dedicated_handler = True
if service == 5:
tm_packet = Service5Tm.unpack(packet)
if service == 17:
tm_packet = Service17Tm.unpack(packet)
dedicated_handler = True
if tm_packet.subservice == 2:
self.printer.file_logger.info("Received Ping Reply TM[17,2]")
LOGGER.info("Received Ping Reply TM[17,2]")
else:
self.printer.file_logger.info(
f"Received Test Packet with unknown subservice {tm_packet.subservice}"
)
LOGGER.info(
f"Received Test Packet with unknown subservice {tm_packet.subservice}"
)
if tm_packet is None:
LOGGER.info(
f"The service {service} is not implemented in Telemetry Factory"
)
tm_packet = PusTelemetry.unpack(packet)
self.raw_logger.log_tm(tm_packet)
if not dedicated_handler and tm_packet is not None:
self.printer.handle_long_tm_print(packet_if=tm_packet, info_if=tm_packet)
def make_addressable_id(target_id: int, unique_id: int) -> bytes:
byte_string = bytearray(struct.pack("!I", target_id))
byte_string.extend(struct.pack("!I", unique_id))
return byte_string
class RequestTargetId(enum.IntEnum):
ACS = 1
class AcsHkIds(enum.IntEnum):
MGM_SET = 1
class HkOpCodes:
GENERATE_ONE_SHOT = ["0", "oneshot"]
class TcHandler(TcHandlerBase):
def __init__(
self,
seq_count_provider: FileSeqCountProvider,
verif_wrapper: VerificationWrapper,
):
super(TcHandler, self).__init__()
self.seq_count_provider = seq_count_provider
self.verif_wrapper = verif_wrapper
self.queue_helper = DefaultPusQueueHelper(
queue_wrapper=None,
seq_cnt_provider=seq_count_provider,
)
def send_cb(self, send_params: SendCbParams):
entry_helper = send_params.entry
if entry_helper.is_tc:
if entry_helper.entry_type == TcQueueEntryType.PUS_TC:
pus_tc_wrapper = entry_helper.to_pus_tc_entry()
pus_tc_wrapper.pus_tc.seq_count = (
self.seq_count_provider.get_and_increment()
)
self.verif_wrapper.add_tc(pus_tc_wrapper.pus_tc)
raw_tc = pus_tc_wrapper.pus_tc.pack()
LOGGER.info(f"Sending {pus_tc_wrapper.pus_tc}")
send_params.com_if.send(raw_tc)
elif entry_helper.entry_type == TcQueueEntryType.LOG:
log_entry = entry_helper.to_log_entry()
LOGGER.info(log_entry.log_str)
def queue_finished_cb(self, helper: ProcedureWrapper):
if helper.proc_type == TcProcedureType.DEFAULT:
def_proc = helper.to_def_procedure()
LOGGER.info(
f"Queue handling finished for service {def_proc.service} and "
f"op code {def_proc.op_code}"
)
def feed_cb(self, helper: ProcedureWrapper, wrapper: FeedWrapper):
q = self.queue_helper
q.queue_wrapper = wrapper.queue_wrapper
if helper.proc_type == TcProcedureType.DEFAULT:
def_proc = helper.to_def_procedure()
service = def_proc.service
op_code = def_proc.op_code
if (
service == CoreServiceList.SERVICE_17
or service == CoreServiceList.SERVICE_17_ALT
):
q.add_log_cmd("Sending PUS ping telecommand")
return q.add_pus_tc(
PusTelecommand(service=17, subservice=1)
)
if service == CoreServiceList.SERVICE_3:
if op_code in HkOpCodes.GENERATE_ONE_SHOT:
q.add_log_cmd("Sending HK one shot request")
q.add_pus_tc(
generate_one_hk_command(make_addressable_id(RequestTargetId.ACS, AcsHkIds.MGM_SET))
)
pass
def main():
tmtccmd.init_printout(False)
hook_obj = SatRsConfigHook(json_cfg_path=default_json_path())
parser_wrapper = PreArgsParsingWrapper()
parser_wrapper.create_default_parent_parser()
parser_wrapper.create_default_parser()
parser_wrapper.add_def_proc_args()
post_args_wrapper = parser_wrapper.parse(hook_obj)
params = SetupParams()
proc_wrapper = ProcedureParamsWrapper()
if post_args_wrapper.use_gui:
post_args_wrapper.set_params_without_prompts(params, proc_wrapper)
else:
post_args_wrapper.set_params_with_prompts(params, proc_wrapper)
params.apid = EXAMPLE_PUS_APID
setup_args = SetupWrapper(
hook_obj=hook_obj, setup_params=params, proc_param_wrapper=proc_wrapper
)
# Create console logger helper and file loggers
tmtc_logger = RegularTmtcLogWrapper()
printer = FsfwTmTcPrinter(tmtc_logger.logger)
raw_logger = RawTmtcTimedLogWrapper(when=TimedLogWhen.PER_HOUR, interval=1)
verificator = PusVerificator()
verification_wrapper = VerificationWrapper(verificator, LOGGER, printer.file_logger)
# Create primary TM handler and add it to the CCSDS Packet Handler
tm_handler = PusHandler(verification_wrapper, printer, raw_logger)
ccsds_handler = CcsdsTmHandler(generic_handler=None)
ccsds_handler.add_apid_handler(tm_handler)
# Create TC handler
seq_count_provider = PusFileSeqCountProvider()
tc_handler = TcHandler(seq_count_provider, verification_wrapper)
tmtccmd.setup(setup_args=setup_args)
init_proc = params_to_procedure_conversion(setup_args.proc_param_wrapper)
tmtc_backend = tmtccmd.create_default_tmtc_backend(
setup_wrapper=setup_args,
tm_handler=ccsds_handler,
tc_handler=tc_handler,
init_procedure=init_proc,
)
tmtccmd.start(tmtc_backend=tmtc_backend, hook_obj=hook_obj)
try:
while True:
state = tmtc_backend.periodic_op(None)
if state.request == BackendRequest.TERMINATION_NO_ERROR:
sys.exit(0)
elif state.request == BackendRequest.DELAY_IDLE:
LOGGER.info("TMTC Client in IDLE mode")
time.sleep(3.0)
elif state.request == BackendRequest.DELAY_LISTENER:
time.sleep(0.8)
elif state.request == BackendRequest.DELAY_CUSTOM:
if state.next_delay.total_seconds() <= 0.4:
time.sleep(state.next_delay.total_seconds())
else:
time.sleep(0.4)
elif state.request == BackendRequest.CALL_NEXT:
pass
except KeyboardInterrupt:
sys.exit(0)
if __name__ == "__main__":
main()

View File

@ -0,0 +1 @@
tmtccmd == 3.0.0

6
pyclient/tmtc_conf.json Normal file
View File

@ -0,0 +1,6 @@
{
"com_if": "udp",
"tcpip_udp_ip_addr": "127.0.0.1",
"tcpip_udp_port": 7301,
"tcpip_udp_recv_max_size": 1500
}

View File

@ -1,33 +1,218 @@
use std::sync::Receiver;
use std::sync::Sender;
use satrs_core::pool::StoreAddr;
#[cfg(feature = "can")]
use socketcan;
use crate::tmtc::TmStore;
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
struct CanThreadArgs {
rx_can_request: Receiver<HkRequest>,
tm_sender: Sender<StoreAddr>,
tm_store: TmStore,
use crate::device_handler::DeviceState;
use crate::can_ids::{
can_id_to_package_id, package_id_to_can_id, value_to_package_id, DeviceId, PackageId,
PackageModel, SenderReceiverThread, ThreadId,
};
use embedded_can::{self, Frame};
use log::{debug, error, info, trace, warn};
use serde::{Deserialize, Serialize};
use serde_json;
use socketcan::{errors, frame, socket, CanFrame, Socket};
use std::collections::HashMap;
use std::ffi::c_void;
use std::io;
use std::mem::size_of;
use std::sync::mpsc::Sender;
pub struct CanRxHandler {
interface: &'static str,
socket: socket::CanSocket,
//frame_id_to_sender_id: HashMap<embedded_can::Id, u32>, // double hash map: frame id -> receiver id -> sender handle
can_senders: HashMap<ThreadId, Sender<PackageModel>>,
//dismissed_ids: Vec<embedded_can::Id>,
package_map: HashMap<PackageId, SenderReceiverThread>,
//packet_id_to_sender_id: HashMap<PackageId, ThreadId>,
}
pub type CollInterval = u32;
pub enum HkIds {
AcsHk = 0
}
pub enum HkRequest {
OneShot(HkIds),
Enable(HkIds, CollInterval), // periodic
Disable(HkIds, CollInterval)
impl CanRxHandler {
pub fn new_socket(
interface: &'static str,
//frame_id_to_sender_id: HashMap<embedded_can::Id, u32>,
can_senders: HashMap<ThreadId, Sender<PackageModel>>,
package_map: HashMap<PackageId, SenderReceiverThread>,
) -> Result<CanRxHandler, ()> {
let socket = socket::CanSocket::open(&interface);
if let Ok(socket) = socket {
Ok(CanRxHandler {
interface,
socket,
can_senders,
package_map,
})
} else {
Err(())
}
}
/*
pub fn new_socket_with_filter(
interface: &'static str,
can_id_to_sender_id: HashMap<embedded_can::Id, u32>,
can_senders: HashMap<u32, Sender<Vec<u8>>>,
can_filters: &[socket::CanFilter],
) -> Result<CanRxHandler, ()> {
let can_wrapper = Self::new_socket(interface, can_id_to_sender_id, can_senders)?;
let filter_result = can_wrapper.socket.set_filters(can_filters);
if let Err(e) = filter_result {
warn!("Can Bus set filter error: {}", e);
}
Ok(can_wrapper)
}
*/
pub fn read_frame(&self) -> io::Result<frame::CanFrame> {
let frame = self.socket.read_frame();
if let Err(e) = &frame {
warn!("CAN bus read error: {}", e);
}
frame
}
pub fn rx_socket(&self) -> Option<CanFrame> {
let frame = self.socket.read_frame().ok()?;
info!("Can Frame read: {:?}.", frame);
return Some(frame);
/*
if let Ok(frame) = frame {
println!("Frame received: {:?}", frame);
return Some(frame);
}
None
*/
}
pub fn forward_frame(&self, frame: CanFrame) {
let frame_id = can_id_to_package_id(frame.id());
info!("Frame forwarding with id: {:?}", frame_id);
if let Some(frame_id) = frame_id {
if self.package_map.contains_key(&frame_id) {
let value = self.package_map.get(&frame_id).unwrap();
if value.get_sender() != DeviceId::OBC {
let message_sender = self.can_senders.get(&value.get_thread()).unwrap();
let data = frame.data();
let message =
PackageModel::new(frame_id, data).expect("Error generating message.");
message_sender.send(message).expect(&*format!(
"Failure sending can bus frame to thread{:?}, frame id {:?}",
value.get_thread(),
frame_id
));
}
}
}
}
/*
pub fn set_filter(&self, filters: &[socket::CanFilter]) -> io::Result<()> {
info!("Setting filter with filter {:?}", filters);
let result = self.socket.set_filters(filters);
if let Err(e) = result {
warn!("Can bus socket filter set error: {}", e);
}
Ok(())
}
*/
}
// impl CanThreadArgs {
// fn operation(&self) {
//
// }
// }
fn can_thread(canthreadargs: CanThreadArgs) {
// handle tc requests
// request from devices
// send tms
}
pub struct CanTxHandler {
interface: &'static str,
socket: socket::CanSocket,
thread_id: ThreadId,
package_map: HashMap<PackageId, SenderReceiverThread>,
}
impl CanTxHandler {
pub fn new_socket(
interface: &'static str,
thread_id: ThreadId,
package_map: HashMap<PackageId, SenderReceiverThread>,
) -> Result<CanTxHandler, ()> {
let socket = socket::CanSocket::open(&interface);
if let Ok(socket) = socket {
socket.filter_drop_all().unwrap(); // tx nodes cannot receive data
Ok(CanTxHandler {
interface,
socket,
thread_id,
package_map,
})
} else {
Err(())
}
}
pub fn tx_socket(&self, package_id: PackageId, data: &[u8]) {
if self.package_map.contains_key(&package_id) {
let value = self.package_map.get(&package_id).unwrap();
if value.get_sender() == DeviceId::OBC {
if value.get_thread() == self.thread_id {
if data.len() <= 8 {
let frame_id = package_id_to_can_id(&package_id);
let frame = CanFrame::new(frame_id, data);
if let Some(frame) = frame {
self.socket
.write_frame(&frame)
.expect("Error writing frame.");
}
} else {
warn!(
"Message dismissed, data length ({:?}) exceeds 8 bytes",
data.len()
);
}
} else {
warn!(
"Message dismissed, mismatched thread id: {:?}",
value.get_thread()
);
}
} else {
warn!(
"Message dismissed, wrong sender id: {:?}",
value.get_sender()
);
}
} else {
warn!("Message dismissed, wrong package id: {:?}", package_id);
}
}
/*
pub fn tx_socket_from_frame(&self, frame: frame::CanFrame) -> io::Result<()> {
let frame_id = frame.id();
if !self.allowed_frame_ids.contains(&frame_id) {
warn!(
"Requested frame Id {:?} not allowed for current thread",
frame.id()
);
} else if let Err(e) = self.socket.write_frame(&frame) {
warn!("CAN bus write error: {}", e);
}
return Ok(());
}
pub fn tx_socket_from_data(
&self,
frame_id: embedded_can::Id,
frame_data: &[u8],
) -> io::Result<()> {
let frame = frame::CanFrame::new(frame_id, &frame_data).expect(&*format!(
"Failure sending can bus frame with id {:?}",
frame_id
));
self.tx_socket_from_frame(frame)
}
*/
}
pub fn open_socket(interface: &str) -> Result<socket::CanSocket, errors::CanSocketOpenError> {
let socket = socket::CanSocket::open(&interface);
return socket;
}

258
src/can_ids.rs Normal file
View File

@ -0,0 +1,258 @@
use embedded_can::{Id, StandardId};
use log::warn;
use std::collections::HashMap;
use std::fs;
use std::sync::mpsc::Sender;
use std::thread::Thread;
use crate::device_handler::{DeviceProperties, DeviceState, DeviceType};
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive, ToPrimitive};
use strum::IntoEnumIterator; // 0.17.1
use strum_macros::EnumIter; // 0.17.1
#[derive(Debug, EnumIter, Eq, Hash, PartialEq, Copy, Clone, FromPrimitive)]
pub enum ThreadId {
AOCSThread,
TMThread,
}
#[derive(Debug, EnumIter, Eq, Hash, PartialEq, Copy, Clone, FromPrimitive)]
pub enum PackageId {
PCDUStatusRequest = 10,
DevicePowerOnRequest = 11,
DevicePowerOffRequest = 12,
DevicePowerStatusRequest = 13,
PCDUStatusResponse = 20,
DevicePowerStatusResponse = 21,
DevicePowerOnRequestConfirmation = 22,
DevicePowerOffRequestConfirmation = 23,
DevicePowerOnConfirmation = 24,
DevicePowerOffConfirmation = 25,
AOCSControlMGT1 = 31,
AOCSControlMGT2 = 32,
AOCSControlMGT3 = 33,
AOCSControlRWL1 = 34,
AOCSControlRWL2 = 35,
AOCSControlRWL3 = 36,
AOCSDataMGM1 = 41,
AOCSDataMGM2 = 42,
AOCSDataMGM3 = 43,
AOCSDataSunSensor1 = 44,
AOCSDataSunSensor2 = 45,
AOCSDataSunSensor3 = 46,
AOCSDataStarTracker = 47,
HousekeepingRequest = 61,
HousekeepingMGM1 = 62,
HousekeepingMGM2 = 63,
HousekeepingMGM3 = 64,
HousekeepingSunSensor1 = 65,
HousekeepingSunSensor2 = 66,
HousekeepingSunSensor3 = 67,
HousekeepingStarTracker = 68,
HousekeepingMGT1 = 69,
HousekeepingMGT2 = 70,
HousekeepingMGT3 = 71,
HousekeepingRWL1 = 72,
HousekeepingRWL2 = 73,
HousekeepingRWL3 = 74,
CameraImageRequest = 101,
CameraImageRequestConfirmation = 102,
CameraImageExecutionStart = 103,
CameraImageExectutionEnd = 104,
}
#[derive(Debug, EnumIter, Eq, Hash, PartialEq, Copy, Clone, FromPrimitive)]
pub enum DeviceId {
OBC = 1,
PCDU = 2,
MGM1 = 3,
MGM2 = 4,
MGM3 = 5,
SunSensor1 = 6,
SunSensor2 = 7,
SunSensor3 = 8,
StarTracker = 9,
MGT1 = 10,
MGT2 = 11,
MGT3 = 12,
RWL1 = 13,
RWL2 = 14,
RWL3 = 15,
Camera = 16,
All = 17,
}
#[derive(Debug)]
pub struct PackageModel {
package_id: PackageId,
data: Vec<u8>,
}
impl PackageModel {
pub fn new(package_id: PackageId, data: &[u8]) -> Result<PackageModel, ()> {
if data.len() > 8 {
warn!("Data exceeds maximum length.");
return Err(());
}
let vec = Vec::from(data);
return Ok(PackageModel {
package_id,
data: vec,
});
}
pub fn package_id(&self) -> PackageId {
self.package_id
}
pub fn data(&self) -> &Vec<u8> {
&self.data
}
}
#[derive(Debug, Copy, Clone)]
pub struct SenderReceiverThread {
sender: DeviceId,
receiver: DeviceId,
thread: ThreadId,
}
impl SenderReceiverThread {
pub fn new(sender: DeviceId, receiver: DeviceId, thread: ThreadId) -> SenderReceiverThread {
SenderReceiverThread {
sender,
receiver,
thread,
}
}
pub fn get_sender(&self) -> DeviceId {
self.sender
}
pub fn get_receiver(&self) -> DeviceId {
self.receiver
}
pub fn get_thread(&self) -> ThreadId {
self.thread
}
}
pub fn load_package_ids() -> HashMap<PackageId, SenderReceiverThread> {
let mut package_map: HashMap<PackageId, SenderReceiverThread> = HashMap::new();
let properties = vec![
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGT1, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGT2, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGT3, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::RWL1, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::RWL2, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::RWL3, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::MGM1, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::MGM2, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::MGM3, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor1, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor2, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor3, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::StarTracker, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::All, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGM1, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGM2, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGM3, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::SunSensor1, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::SunSensor2, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::SunSensor3, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::StarTracker, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGT1, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGT2, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGT3, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::RWL1, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::RWL2, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::RWL3, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::Camera, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::TMThread),
];
let mut i = 0;
for id in PackageId::iter() {
let value = properties.get(i).unwrap();
package_map.insert(id, *value);
i += 1;
}
return package_map;
}
pub fn load_device_ids() {
let mut package_map: HashMap<DeviceId, DeviceProperties> = HashMap::new();
let properties = vec![
DeviceProperties::new(DeviceType::OBC, DeviceState::Unknown),
DeviceProperties::new(DeviceType::PCDU, DeviceState::Unknown),
DeviceProperties::new(DeviceType::MGM, DeviceState::Unknown),
DeviceProperties::new(DeviceType::MGM, DeviceState::Unknown),
DeviceProperties::new(DeviceType::MGM, DeviceState::Unknown),
DeviceProperties::new(DeviceType::CRS, DeviceState::Unknown),
DeviceProperties::new(DeviceType::CRS, DeviceState::Unknown),
DeviceProperties::new(DeviceType::CRS, DeviceState::Unknown),
DeviceProperties::new(DeviceType::STR, DeviceState::Unknown),
DeviceProperties::new(DeviceType::MGT, DeviceState::Unknown),
DeviceProperties::new(DeviceType::MGT, DeviceState::Unknown),
DeviceProperties::new(DeviceType::MGT, DeviceState::Unknown),
DeviceProperties::new(DeviceType::RWL, DeviceState::Unknown),
DeviceProperties::new(DeviceType::RWL, DeviceState::Unknown),
DeviceProperties::new(DeviceType::RWL, DeviceState::Unknown),
DeviceProperties::new(DeviceType::CAM, DeviceState::Unknown),
];
let mut i = 0;
for id in DeviceId::iter() {
let value = properties.get(i).unwrap();
package_map.insert(id, *value);
i += 1;
}
}
//TODO: change ids from u32 to embeddedcan ids
pub fn package_id_to_value(packageid: &PackageId) -> u32 {
*packageid as u32
}
pub fn package_id_to_can_id(packageid: &PackageId) -> Id {
let x = *packageid as u16;
Id::Standard(StandardId::new(x).unwrap())
}
pub fn device_id_to_value(deviceid: &DeviceId) -> u32 {
*deviceid as u32
}
pub fn value_to_package_id(value: u32) -> Option<PackageId> {
let element = FromPrimitive::from_u32(value);
return element;
}
pub fn can_id_to_package_id(value: Id) -> Option<PackageId> {
let buf = match value {
Id::Standard(id) => id.as_raw() as u32,
Id::Extended(id) => id.as_raw(),
};
let element = FromPrimitive::from_u32(buf);
return element;
}
pub fn value_to_device_id(value: u32) -> Option<DeviceId> {
let element = FromPrimitive::from_u32(value);
return element;
}

View File

@ -1,13 +1,13 @@
use crate::tmtc::PUS_APID;
use satrs_core::tmtc::{CcsdsPacketHandler, PusDistributor, ReceivesCcsdsTc};
use spacepackets::{CcsdsPacket, SpHeader};
use crate::tmtc::{MpscStoreAndSendError, PusTcSource, PUS_APID};
use satrs_core::tmtc::{CcsdsPacketHandler, ReceivesCcsdsTc};
use satrs_core::spacepackets::{CcsdsPacket, SpHeader};
pub struct CcsdsReceiver {
pub pus_handler: PusDistributor<()>,
pub tc_source: PusTcSource,
}
impl CcsdsPacketHandler for CcsdsReceiver {
type Error = ();
type Error = MpscStoreAndSendError;
fn valid_apids(&self) -> &'static [u16] {
&[PUS_APID]
@ -19,9 +19,7 @@ impl CcsdsPacketHandler for CcsdsReceiver {
tc_raw: &[u8],
) -> Result<(), Self::Error> {
if sp_header.apid() == PUS_APID {
self.pus_handler
.pass_ccsds(sp_header, tc_raw)
.expect("Handling PUS packet failed");
return self.tc_source.pass_ccsds(sp_header, tc_raw);
}
Ok(())
}

37
src/device_handler.rs Normal file
View File

@ -0,0 +1,37 @@
use socketcan::{errors, frame, socket, CanFrame, Socket};
use crate::can_ids::DeviceId;
#[derive(Copy, Clone)]
pub enum DeviceState {
On,
Off,
Broken,
Unknown,
}
#[derive(Copy, Clone)]
pub enum DeviceType {
MGM,
MGT,
RWL,
STR,
CRS,
OBC,
PCDU,
CAM,
}
#[derive(Copy, Clone)]
pub struct DeviceProperties {
device_type: DeviceType,
device_state: DeviceState,
}
impl DeviceProperties {
pub fn new(device_type: DeviceType, device_state: DeviceState) -> DeviceProperties {
return DeviceProperties {
device_type,
device_state,
};
}
}

243
src/example_main.rs Normal file
View File

@ -0,0 +1,243 @@
use crate::hk::{AcsHkIds, HkRequest};
use crate::requests::{Request, RequestWithToken};
use crate::tmtc::{
core_tmtc_task, OtherArgs, PusTcSource, TcArgs, TcStore, TmArgs, TmFunnel, TmStore, PUS_APID,
};
use satrs_core::event_man::{
EventManagerWithMpscQueue, MpscEventReceiver, MpscEventU32SendProvider, SendEventProvider,
};
use satrs_core::events::EventU32;
use satrs_core::pool::{LocalPool, PoolCfg, StoreAddr};
use satrs_core::pus::event_man::{
DefaultPusMgmtBackendProvider, EventReporter, EventRequest, EventRequestWithToken,
PusEventDispatcher,
};
use satrs_core::pus::hk::Subservice;
use satrs_core::pus::verification::{
MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender,
};
use satrs_core::pus::{EcssTmError, EcssTmSenderCore};
use satrs_core::seq_count::{SeqCountProviderSyncClonable, SequenceCountProvider};
use eurosim_obsw::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
use satrs_core::{
spacepackets::time::cds::TimeProvider,
spacepackets::time::TimeWriter,
spacepackets::tm::{PusTm, PusTmSecondaryHeader},
spacepackets::{SequenceFlags, SpHeader}
};
use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr};
use std::sync::mpsc::{channel, TryRecvError};
use std::sync::{mpsc, Arc, RwLock};
use std::thread;
use std::time::Duration;
use crate::EventTmSender;
fn example_main() {
let tm_pool = LocalPool::new(PoolCfg::new(vec![
(30, 32),
(15, 64),
(15, 128),
(15, 256),
(15, 1024),
(15, 2048),
]));
let tm_store = TmStore {
pool: Arc::new(RwLock::new(Box::new(tm_pool))),
};