From 88161ed1257fba717cc8a23bdad2902b06af35c9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 17 Aug 2023 11:33:42 +0200 Subject: [PATCH 01/29] more cleaning up, new cfdp module --- eive_tmtc/cfdp/__init__.py | 0 eive_tmtc/cfdp/fault_handler.py | 15 +++ eive_tmtc/cfdp/user.py | 52 +++++++++ eive_tmtc/pus_tc/tc_handler.py | 147 ++++++++++++++++++++++++ tmtcc.py | 198 +------------------------------- 5 files changed, 219 insertions(+), 193 deletions(-) create mode 100644 eive_tmtc/cfdp/__init__.py create mode 100644 eive_tmtc/cfdp/fault_handler.py create mode 100644 eive_tmtc/cfdp/user.py create mode 100644 eive_tmtc/pus_tc/tc_handler.py diff --git a/eive_tmtc/cfdp/__init__.py b/eive_tmtc/cfdp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/eive_tmtc/cfdp/fault_handler.py b/eive_tmtc/cfdp/fault_handler.py new file mode 100644 index 0000000..baa061b --- /dev/null +++ b/eive_tmtc/cfdp/fault_handler.py @@ -0,0 +1,15 @@ +from tmtccmd.cfdp.mib import DefaultFaultHandlerBase + + +class EiveCfdpFaultHandler(DefaultFaultHandlerBase): + def notice_of_suspension_cb(self, cond: ConditionCode): + pass + + def notice_of_cancellation_cb(self, cond: ConditionCode): + pass + + def abandoned_cb(self, cond: ConditionCode): + pass + + def ignore_cb(self, cond: ConditionCode): + pass diff --git a/eive_tmtc/cfdp/user.py b/eive_tmtc/cfdp/user.py new file mode 100644 index 0000000..7a25ad2 --- /dev/null +++ b/eive_tmtc/cfdp/user.py @@ -0,0 +1,52 @@ +import logging + +from spacepackets.cfdp import ConditionCode +from tmtccmd.cfdp import CfdpUserBase, TransactionId +from tmtccmd.cfdp.user import ( + TransactionFinishedParams, + MetadataRecvParams, + FileSegmentRecvdParams, +) + +_LOGGER = logging.getLogger(__name__) + + +class EiveCfdpUser(CfdpUserBase): + def transaction_indication(self, transaction_id: TransactionId): + _LOGGER.info(f"CFDP User: Start of File {transaction_id}") + + def eof_sent_indication(self, transaction_id: TransactionId): + _LOGGER.info(f"CFDP User: EOF sent for {transaction_id}") + + def transaction_finished_indication(self, params: TransactionFinishedParams): + _LOGGER.info(f"CFDP User: {params.transaction_id} finished") + + def metadata_recv_indication(self, params: MetadataRecvParams): + pass + + def file_segment_recv_indication(self, params: FileSegmentRecvdParams): + pass + + def report_indication(self, transaction_id: TransactionId, status_report: any): + pass + + def suspended_indication( + self, transaction_id: TransactionId, cond_code: ConditionCode + ): + pass + + def resumed_indication(self, transaction_id: TransactionId, progress: int): + pass + + def fault_indication( + self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int + ): + pass + + def abandoned_indication( + self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int + ): + pass + + def eof_recv_indication(self, transaction_id: TransactionId): + pass diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py new file mode 100644 index 0000000..596e5ec --- /dev/null +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -0,0 +1,147 @@ +import logging +from typing import cast + +from eive_tmtc.config.definitions import CFDP_REMOTE_ENTITY_ID, PUS_APID +from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure +from tmtcc import CfdpInCcsdsWrapper +from tmtccmd import TcHandlerBase, ProcedureWrapper +from tmtccmd.cfdp.defs import CfdpRequestType +from tmtccmd.logging import get_current_time_string +from tmtccmd.logging.pus import RawTmtcTimedLogWrapper +from tmtccmd.tc import ( + DefaultPusQueueHelper, + QueueWrapper, + FeedWrapper, + TcProcedureType, + SendCbParams, + TcQueueEntryType, +) +from spacepackets.ecss import PusVerificator +from tmtccmd.util import FileSeqCountProvider +from spacepackets.cfdp import PduHolder, DirectiveType + + +_LOGGER = logging.getLogger(__name__) + + +class TcHandler(TcHandlerBase): + def __init__( + self, + seq_count_provider: FileSeqCountProvider, + cfdp_in_ccsds_wrapper: CfdpInCcsdsWrapper, + pus_verificator: PusVerificator, + high_level_file_logger: logging.Logger, + raw_pus_logger: RawTmtcTimedLogWrapper, + gui: bool, + ): + super().__init__() + self.cfdp_handler_started = False + self.cfdp_dest_id = CFDP_REMOTE_ENTITY_ID + self.seq_count_provider = seq_count_provider + self.pus_verificator = pus_verificator + self.high_level_file_logger = high_level_file_logger + self.pus_raw_logger = raw_pus_logger + self.gui = gui + self.queue_helper = DefaultPusQueueHelper( + queue_wrapper=QueueWrapper.empty(), + default_pus_apid=PUS_APID, + seq_cnt_provider=seq_count_provider, + pus_verificator=pus_verificator, + tc_sched_timestamp_len=4, + ) + self.cfdp_in_ccsds_wrapper = cfdp_in_ccsds_wrapper + + def cfdp_done(self) -> bool: + if self.cfdp_handler_started: + if not self.cfdp_in_ccsds_wrapper.handler.put_request_pending(): + self.cfdp_handler_started = False + return True + return False + + def feed_cb(self, info: ProcedureWrapper, wrapper: FeedWrapper): + self.queue_helper.queue_wrapper = wrapper.queue_wrapper + if info.proc_type == TcProcedureType.DEFAULT: + handle_default_procedure(self, info.to_def_procedure(), self.queue_helper) + elif info.proc_type == TcProcedureType.CFDP: + self.handle_cfdp_procedure(info) + + 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.apid = PUS_APID + raw_tc = pus_tc_wrapper.pus_tc.pack() + self.pus_raw_logger.log_tc(pus_tc_wrapper.pus_tc) + tc_info_string = f"Sent {pus_tc_wrapper.pus_tc}" + _LOGGER.info(tc_info_string) + self.high_level_file_logger.info( + f"{get_current_time_string(True)}: {tc_info_string}" + ) + # with open("tc.bin", "wb") as of: + # of.write(raw_tc) + send_params.com_if.send(raw_tc) + elif entry_helper.entry_type == TcQueueEntryType.CCSDS_TC: + cfdp_packet_in_ccsds = entry_helper.to_space_packet_entry() + send_params.com_if.send(cfdp_packet_in_ccsds.space_packet.pack()) + # TODO: Log raw CFDP packets similarly to how PUS packets are logged. + # - Log full raw format including space packet wrapper + # - Log context information: Transaction ID, and PDU type and directive + # Could re-use file logger. Should probably do that + # print(f"sending packet: [{cfdp_packet_in_ccsds.space_packet.pack()}]") + # with open(f"cfdp_packet_{self.cfdp_counter}", "wb") as of: + # of.write(cfdp_packet_in_ccsds.space_packet.pack()) + # self.cfdp_counter += 1 + elif entry_helper.entry_type == TcQueueEntryType.LOG: + log_entry = entry_helper.to_log_entry() + _LOGGER.info(log_entry.log_str) + self.high_level_file_logger.info(log_entry.log_str) + + def handle_cfdp_procedure(self, info: ProcedureWrapper): + cfdp_procedure = info.to_cfdp_procedure() + if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT: + if ( + not self.cfdp_in_ccsds_wrapper.handler.put_request_pending() + and not self.cfdp_handler_started + ): + put_req = cfdp_procedure.request_wrapper.to_put_request() + put_req.cfg.destination_id = self.cfdp_dest_id + _LOGGER.info( + f"CFDP: Starting file put request with parameters:\n{put_req}" + ) + self.cfdp_in_ccsds_wrapper.handler.cfdp_handler.put_request(put_req) + self.cfdp_handler_started = True + + for source_pair, dest_pair in self.cfdp_in_ccsds_wrapper.handler: + pdu, sp = source_pair + pdu = cast(PduHolder, pdu) + if pdu.is_file_directive: + if pdu.pdu_directive_type == DirectiveType.METADATA_PDU: + metadata = pdu.to_metadata_pdu() + self.queue_helper.add_log_cmd( + f"CFDP Source: Sending Metadata PDU for file with size " + f"{metadata.file_size}" + ) + elif pdu.pdu_directive_type == DirectiveType.EOF_PDU: + self.queue_helper.add_log_cmd( + "CFDP Source: Sending EOF PDU" + ) + else: + fd_pdu = pdu.to_file_data_pdu() + self.queue_helper.add_log_cmd( + f"CFDP Source: Sending File Data PDU for segment at offset " + f"{fd_pdu.offset} with length {len(fd_pdu.file_data)}" + ) + self.queue_helper.add_ccsds_tc(sp) + self.cfdp_in_ccsds_wrapper.handler.confirm_source_packet_sent() + self.cfdp_in_ccsds_wrapper.handler.source_handler.state_machine() + + def queue_finished_cb(self, info: ProcedureWrapper): + if info is not None: + if info.proc_type == TcQueueEntryType.PUS_TC: + def_proc = info.to_def_procedure() + _LOGGER.info( + f"Finished queue for service {def_proc.service} and op code {def_proc.op_code}" + ) + elif info.proc_type == TcProcedureType.CFDP: + _LOGGER.info("Finished CFDP queue") diff --git a/tmtcc.py b/tmtcc.py index d6d3645..ec19fdf 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -4,21 +4,22 @@ import sys import time import traceback from pathlib import Path -from typing import cast +from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler +from eive_tmtc.cfdp.user import EiveCfdpUser from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE from spacepackets.cfdp import ( ConditionCode, ChecksumType, TransmissionMode, - PduHolder, DirectiveType, PduFactory, PduType, ) + +from eive_tmtc.pus_tc.tc_handler import TcHandler from tmtccmd.logging import add_colorlog_console_logger from tmtccmd.cfdp import CfdpUserBase, TransactionId -from tmtccmd.cfdp.defs import CfdpRequestType from tmtccmd.cfdp.handler import CfdpInCcsdsHandler from tmtccmd.cfdp.mib import ( DefaultFaultHandlerBase, @@ -31,7 +32,6 @@ from tmtccmd.cfdp.user import ( MetadataRecvParams, FileSegmentRecvdParams, ) -from tmtccmd.tc.handler import SendCbParams try: import spacepackets @@ -54,7 +54,7 @@ except ImportError: sys.exit(1) from spacepackets.ecss import PusVerificator -from tmtccmd import TcHandlerBase, BackendBase +from tmtccmd import BackendBase from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter @@ -66,15 +66,6 @@ from tmtccmd.logging.pus import ( from tmtccmd.pus import VerificationWrapper from tmtccmd.tm import SpecificApidHandlerBase, GenericApidHandlerBase, CcsdsTmHandler from tmtccmd.core import BackendRequest -from tmtccmd.logging import get_current_time_string -from tmtccmd.tc import ( - ProcedureWrapper, - FeedWrapper, - TcProcedureType, - TcQueueEntryType, - DefaultPusQueueHelper, - QueueWrapper, -) from tmtccmd.config import ( default_json_path, SetupWrapper, @@ -95,7 +86,6 @@ from eive_tmtc.config.definitions import ( ) from eive_tmtc.config.hook import EiveHookObject from eive_tmtc.pus_tm.pus_demux import pus_factory_hook -from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure _LOGGER = APP_LOGGER _LOG_LEVEL = logging.INFO @@ -105,61 +95,6 @@ ROTATING_TIMED_LOGGER_INTERVAL_WHEN = TimedLogWhen.PER_MINUTE ROTATING_TIMED_LOGGER_INTERVAL = 30 -class EiveCfdpFaultHandler(DefaultFaultHandlerBase): - def notice_of_suspension_cb(self, cond: ConditionCode): - pass - - def notice_of_cancellation_cb(self, cond: ConditionCode): - pass - - def abandoned_cb(self, cond: ConditionCode): - pass - - def ignore_cb(self, cond: ConditionCode): - pass - - -class EiveCfdpUser(CfdpUserBase): - def transaction_indication(self, transaction_id: TransactionId): - _LOGGER.info(f"CFDP User: Start of File {transaction_id}") - - def eof_sent_indication(self, transaction_id: TransactionId): - _LOGGER.info(f"CFDP User: EOF sent for {transaction_id}") - - def transaction_finished_indication(self, params: TransactionFinishedParams): - _LOGGER.info(f"CFDP User: {params.transaction_id} finished") - - def metadata_recv_indication(self, params: MetadataRecvParams): - pass - - def file_segment_recv_indication(self, params: FileSegmentRecvdParams): - pass - - def report_indication(self, transaction_id: TransactionId, status_report: any): - pass - - def suspended_indication( - self, transaction_id: TransactionId, cond_code: ConditionCode - ): - pass - - def resumed_indication(self, transaction_id: TransactionId, progress: int): - pass - - def fault_indication( - self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int - ): - pass - - def abandoned_indication( - self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int - ): - pass - - def eof_recv_indication(self, transaction_id: TransactionId): - pass - - class PusHandler(SpecificApidHandlerBase): def __init__( self, @@ -216,129 +151,6 @@ class CfdpInCcsdsWrapper(SpecificApidHandlerBase): self.handler.pass_pdu_packet(pdu_base) -class TcHandler(TcHandlerBase): - def __init__( - self, - seq_count_provider: FileSeqCountProvider, - cfdp_in_ccsds_wrapper: CfdpInCcsdsWrapper, - pus_verificator: PusVerificator, - high_level_file_logger: logging.Logger, - raw_pus_logger: RawTmtcTimedLogWrapper, - gui: bool, - ): - super().__init__() - self.cfdp_handler_started = False - self.cfdp_dest_id = CFDP_REMOTE_ENTITY_ID - self.seq_count_provider = seq_count_provider - self.pus_verificator = pus_verificator - self.high_level_file_logger = high_level_file_logger - self.pus_raw_logger = raw_pus_logger - self.gui = gui - self.queue_helper = DefaultPusQueueHelper( - queue_wrapper=QueueWrapper.empty(), - default_pus_apid=PUS_APID, - seq_cnt_provider=seq_count_provider, - pus_verificator=pus_verificator, - tc_sched_timestamp_len=4, - ) - self.cfdp_in_ccsds_wrapper = cfdp_in_ccsds_wrapper - - def cfdp_done(self) -> bool: - if self.cfdp_handler_started: - if not self.cfdp_in_ccsds_wrapper.handler.put_request_pending(): - self.cfdp_handler_started = False - return True - return False - - def feed_cb(self, info: ProcedureWrapper, wrapper: FeedWrapper): - self.queue_helper.queue_wrapper = wrapper.queue_wrapper - if info.proc_type == TcProcedureType.DEFAULT: - handle_default_procedure(self, info.to_def_procedure(), self.queue_helper) - elif info.proc_type == TcProcedureType.CFDP: - self.handle_cfdp_procedure(info) - - 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.apid = PUS_APID - raw_tc = pus_tc_wrapper.pus_tc.pack() - self.pus_raw_logger.log_tc(pus_tc_wrapper.pus_tc) - tc_info_string = f"Sent {pus_tc_wrapper.pus_tc}" - _LOGGER.info(tc_info_string) - self.high_level_file_logger.info( - f"{get_current_time_string(True)}: {tc_info_string}" - ) - # with open("tc.bin", "wb") as of: - # of.write(raw_tc) - send_params.com_if.send(raw_tc) - elif entry_helper.entry_type == TcQueueEntryType.CCSDS_TC: - cfdp_packet_in_ccsds = entry_helper.to_space_packet_entry() - send_params.com_if.send(cfdp_packet_in_ccsds.space_packet.pack()) - # TODO: Log raw CFDP packets similarly to how PUS packets are logged. - # - Log full raw format including space packet wrapper - # - Log context information: Transaction ID, and PDU type and directive - # Could re-use file logger. Should probably do that - # print(f"sending packet: [{cfdp_packet_in_ccsds.space_packet.pack()}]") - # with open(f"cfdp_packet_{self.cfdp_counter}", "wb") as of: - # of.write(cfdp_packet_in_ccsds.space_packet.pack()) - # self.cfdp_counter += 1 - elif entry_helper.entry_type == TcQueueEntryType.LOG: - log_entry = entry_helper.to_log_entry() - _LOGGER.info(log_entry.log_str) - self.high_level_file_logger.info(log_entry.log_str) - - def handle_cfdp_procedure(self, info: ProcedureWrapper): - cfdp_procedure = info.to_cfdp_procedure() - if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT: - if ( - not self.cfdp_in_ccsds_wrapper.handler.put_request_pending() - and not self.cfdp_handler_started - ): - put_req = cfdp_procedure.request_wrapper.to_put_request() - put_req.cfg.destination_id = self.cfdp_dest_id - _LOGGER.info( - f"CFDP: Starting file put request with parameters:\n{put_req}" - ) - self.cfdp_in_ccsds_wrapper.handler.cfdp_handler.put_request(put_req) - self.cfdp_handler_started = True - - for source_pair, dest_pair in self.cfdp_in_ccsds_wrapper.handler: - pdu, sp = source_pair - pdu = cast(PduHolder, pdu) - if pdu.is_file_directive: - if pdu.pdu_directive_type == DirectiveType.METADATA_PDU: - metadata = pdu.to_metadata_pdu() - self.queue_helper.add_log_cmd( - f"CFDP Source: Sending Metadata PDU for file with size " - f"{metadata.file_size}" - ) - elif pdu.pdu_directive_type == DirectiveType.EOF_PDU: - self.queue_helper.add_log_cmd( - "CFDP Source: Sending EOF PDU" - ) - else: - fd_pdu = pdu.to_file_data_pdu() - self.queue_helper.add_log_cmd( - f"CFDP Source: Sending File Data PDU for segment at offset " - f"{fd_pdu.offset} with length {len(fd_pdu.file_data)}" - ) - self.queue_helper.add_ccsds_tc(sp) - self.cfdp_in_ccsds_wrapper.handler.confirm_source_packet_sent() - self.cfdp_in_ccsds_wrapper.handler.source_handler.state_machine() - - def queue_finished_cb(self, info: ProcedureWrapper): - if info is not None: - if info.proc_type == TcQueueEntryType.PUS_TC: - def_proc = info.to_def_procedure() - _LOGGER.info( - f"Finished queue for service {def_proc.service} and op code {def_proc.op_code}" - ) - elif info.proc_type == TcProcedureType.CFDP: - _LOGGER.info("Finished CFDP queue") - - def setup_params() -> (SetupWrapper, int): hook_obj = EiveHookObject(default_json_path()) params = SetupParams() From 011be9837ed67bf65d8c9f5a5fece8784dfe4e68 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 17 Aug 2023 11:34:34 +0200 Subject: [PATCH 02/29] remove more unused includes --- tmtcc.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tmtcc.py b/tmtcc.py index ec19fdf..c032291 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -9,7 +9,6 @@ from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler from eive_tmtc.cfdp.user import EiveCfdpUser from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE from spacepackets.cfdp import ( - ConditionCode, ChecksumType, TransmissionMode, DirectiveType, @@ -19,19 +18,12 @@ from spacepackets.cfdp import ( from eive_tmtc.pus_tc.tc_handler import TcHandler from tmtccmd.logging import add_colorlog_console_logger -from tmtccmd.cfdp import CfdpUserBase, TransactionId from tmtccmd.cfdp.handler import CfdpInCcsdsHandler from tmtccmd.cfdp.mib import ( - DefaultFaultHandlerBase, LocalEntityCfg, IndicationCfg, RemoteEntityCfg, ) -from tmtccmd.cfdp.user import ( - TransactionFinishedParams, - MetadataRecvParams, - FileSegmentRecvdParams, -) try: import spacepackets From 54a7c3566f5b124e8c666ea1b5eccd7cd0128f88 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 17 Aug 2023 11:34:54 +0200 Subject: [PATCH 03/29] added missing stuff --- eive_tmtc/cfdp/fault_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/eive_tmtc/cfdp/fault_handler.py b/eive_tmtc/cfdp/fault_handler.py index baa061b..a20ba80 100644 --- a/eive_tmtc/cfdp/fault_handler.py +++ b/eive_tmtc/cfdp/fault_handler.py @@ -1,3 +1,4 @@ +from spacepackets.cfdp import ConditionCode from tmtccmd.cfdp.mib import DefaultFaultHandlerBase From 14b558b7f7621ebe0673a0bcff77105fe84f7c9e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 17 Aug 2023 16:42:53 +0200 Subject: [PATCH 04/29] prepare file downlink --- eive_tmtc/pus_tc/tc_handler.py | 22 ++++++++++++++++++---- pyproject.toml | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index 596e5ec..f34f965 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -1,7 +1,11 @@ import logging from typing import cast -from eive_tmtc.config.definitions import CFDP_REMOTE_ENTITY_ID, PUS_APID +from eive_tmtc.config.definitions import ( + CFDP_REMOTE_ENTITY_ID, + PUS_APID, + CFDP_LOCAL_ENTITY_ID, +) from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure from tmtcc import CfdpInCcsdsWrapper from tmtccmd import TcHandlerBase, ProcedureWrapper @@ -16,6 +20,10 @@ from tmtccmd.tc import ( SendCbParams, TcQueueEntryType, ) +from tmtccmd.config import ( + cfdp_put_req_params_to_procedure, + cfdp_req_to_put_req_proxy_get_req, +) from spacepackets.ecss import PusVerificator from tmtccmd.util import FileSeqCountProvider from spacepackets.cfdp import PduHolder, DirectiveType @@ -36,7 +44,6 @@ class TcHandler(TcHandlerBase): ): super().__init__() self.cfdp_handler_started = False - self.cfdp_dest_id = CFDP_REMOTE_ENTITY_ID self.seq_count_provider = seq_count_provider self.pus_verificator = pus_verificator self.high_level_file_logger = high_level_file_logger @@ -104,8 +111,15 @@ class TcHandler(TcHandlerBase): not self.cfdp_in_ccsds_wrapper.handler.put_request_pending() and not self.cfdp_handler_started ): - put_req = cfdp_procedure.request_wrapper.to_put_request() - put_req.cfg.destination_id = self.cfdp_dest_id + put_req_cfg_wrapper = cfdp_procedure.request_wrapper.to_put_request() + if put_req_cfg_wrapper.cfg.proxy_op: + put_req = cfdp_req_to_put_req_proxy_get_req( + put_req_cfg_wrapper.cfg, + CFDP_REMOTE_ENTITY_ID, + CFDP_LOCAL_ENTITY_ID, + ) + else: + put_req = cfdp_put_req_params_to_procedure(put_req_cfg_wrapper.cfg) _LOGGER.info( f"CFDP: Starting file put request with parameters:\n{put_req}" ) diff --git a/pyproject.toml b/pyproject.toml index e3d3429..a82d4c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,9 +29,9 @@ classifiers = [ "Topic :: Scientific/Engineering" ] dependencies = [ - "tmtccmd ~= 5.0", + # "tmtccmd ~= 5.0", "python-dateutil ~= 2.8", - # "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@1b110d321ef85#egg=tmtccmd" + "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@#egg=cfdp-proxy-op-support" ] [project.urls] From 984107669931b6750feeada817ebeae8cb1852b8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 17 Aug 2023 16:44:34 +0200 Subject: [PATCH 05/29] maybe this works better --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a82d4c9..3e613db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ classifiers = [ dependencies = [ # "tmtccmd ~= 5.0", "python-dateutil ~= 2.8", - "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@#egg=cfdp-proxy-op-support" + "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@cfdp-proxy-op-support" ] [project.urls] From 8743f59b565b7b6828a9b30e8b3d3f5b60e4ea2b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Aug 2023 21:31:27 +0200 Subject: [PATCH 06/29] fix for HK level parsing --- tmtcc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tmtcc.py b/tmtcc.py index c032291..1e82245 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -165,7 +165,10 @@ def setup_params() -> (SetupWrapper, int): post_arg_parsing_wrapper.set_params_with_prompts(proc_param_wrapper) else: post_arg_parsing_wrapper.set_params_without_prompts(proc_param_wrapper) - hk_level = int(post_arg_parsing_wrapper.args_raw.hk) + if hasattr(post_arg_parsing_wrapper.args_raw, "hk"): + hk_level = int(post_arg_parsing_wrapper.args_raw.hk) + else: + hk_level = 0 params.apid = PUS_APID if params.com_if is None: raise ValueError("could not determine a COM interface.") From 948f3a1a417562a8b4f0f72666b155ca6a8e38bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Aug 2023 21:41:29 +0200 Subject: [PATCH 07/29] improve architecture a bit --- eive_tmtc/cfdp/tm.py | 31 +++++++++++++ eive_tmtc/pus_tc/tc_handler.py | 19 ++++---- eive_tmtc/tmtc/acs/gps.py | 80 +++++++++++++++++++++++++--------- tmtcc.py | 31 ++----------- 4 files changed, 104 insertions(+), 57 deletions(-) create mode 100644 eive_tmtc/cfdp/tm.py diff --git a/eive_tmtc/cfdp/tm.py b/eive_tmtc/cfdp/tm.py new file mode 100644 index 0000000..93dcd44 --- /dev/null +++ b/eive_tmtc/cfdp/tm.py @@ -0,0 +1,31 @@ +import logging + +from eive_tmtc.config.definitions import CFDP_APID +from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE +from spacepackets.cfdp import PduFactory, PduType, DirectiveType +from tmtccmd.cfdp.handler import CfdpInCcsdsHandler +from tmtccmd.tm import SpecificApidHandlerBase + +_LOGGER = logging.getLogger(__name__) + + +class CfdpInCcsdsWrapper(SpecificApidHandlerBase): + def __init__(self, cfdp_in_ccsds_handler: CfdpInCcsdsHandler): + super().__init__(CFDP_APID, None) + self.handler = cfdp_in_ccsds_handler + + def handle_tm(self, packet: bytes, _user_args: any): + # Ignore the space packet header. Its only purpose is to use the same protocol and + # have a seaprate APID for space packets. If this function is called, the APID is correct. + pdu = packet[SPACE_PACKET_HEADER_SIZE:] + pdu_base = PduFactory.from_raw(pdu) + if pdu_base.pdu_type == PduType.FILE_DATA: + _LOGGER.info("Received File Data PDU TM") + else: + if pdu_base.directive_type == DirectiveType.FINISHED_PDU: + _LOGGER.info("Received Finished PDU TM") + else: + _LOGGER.info( + f"Received File Directive PDU with type {pdu_base.directive_type!r} TM" + ) + self.handler.pass_pdu_packet(pdu_base) diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index f34f965..ae61918 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -7,9 +7,9 @@ from eive_tmtc.config.definitions import ( CFDP_LOCAL_ENTITY_ID, ) from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure -from tmtcc import CfdpInCcsdsWrapper from tmtccmd import TcHandlerBase, ProcedureWrapper from tmtccmd.cfdp.defs import CfdpRequestType +from tmtccmd.cfdp.handler import CfdpInCcsdsHandler from tmtccmd.logging import get_current_time_string from tmtccmd.logging.pus import RawTmtcTimedLogWrapper from tmtccmd.tc import ( @@ -36,7 +36,7 @@ class TcHandler(TcHandlerBase): def __init__( self, seq_count_provider: FileSeqCountProvider, - cfdp_in_ccsds_wrapper: CfdpInCcsdsWrapper, + cfdp_in_ccsds_handler: CfdpInCcsdsHandler, pus_verificator: PusVerificator, high_level_file_logger: logging.Logger, raw_pus_logger: RawTmtcTimedLogWrapper, @@ -56,11 +56,11 @@ class TcHandler(TcHandlerBase): pus_verificator=pus_verificator, tc_sched_timestamp_len=4, ) - self.cfdp_in_ccsds_wrapper = cfdp_in_ccsds_wrapper + self.cfdp_in_ccsds_handler = cfdp_in_ccsds_handler def cfdp_done(self) -> bool: if self.cfdp_handler_started: - if not self.cfdp_in_ccsds_wrapper.handler.put_request_pending(): + if not self.cfdp_in_ccsds_handler.put_request_pending(): self.cfdp_handler_started = False return True return False @@ -108,7 +108,7 @@ class TcHandler(TcHandlerBase): cfdp_procedure = info.to_cfdp_procedure() if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT: if ( - not self.cfdp_in_ccsds_wrapper.handler.put_request_pending() + not self.cfdp_in_ccsds_handler.put_request_pending() and not self.cfdp_handler_started ): put_req_cfg_wrapper = cfdp_procedure.request_wrapper.to_put_request() @@ -118,15 +118,16 @@ class TcHandler(TcHandlerBase): CFDP_REMOTE_ENTITY_ID, CFDP_LOCAL_ENTITY_ID, ) + print(put_req) else: put_req = cfdp_put_req_params_to_procedure(put_req_cfg_wrapper.cfg) _LOGGER.info( f"CFDP: Starting file put request with parameters:\n{put_req}" ) - self.cfdp_in_ccsds_wrapper.handler.cfdp_handler.put_request(put_req) + self.cfdp_in_ccsds_handler.cfdp_handler.put_request(put_req) self.cfdp_handler_started = True - for source_pair, dest_pair in self.cfdp_in_ccsds_wrapper.handler: + for source_pair, dest_pair in self.cfdp_in_ccsds_handler: pdu, sp = source_pair pdu = cast(PduHolder, pdu) if pdu.is_file_directive: @@ -147,8 +148,8 @@ class TcHandler(TcHandlerBase): f"{fd_pdu.offset} with length {len(fd_pdu.file_data)}" ) self.queue_helper.add_ccsds_tc(sp) - self.cfdp_in_ccsds_wrapper.handler.confirm_source_packet_sent() - self.cfdp_in_ccsds_wrapper.handler.source_handler.state_machine() + self.cfdp_in_ccsds_handler.confirm_source_packet_sent() + self.cfdp_in_ccsds_handler.source_handler.state_machine() def queue_finished_cb(self, info: ProcedureWrapper): if info is not None: diff --git a/eive_tmtc/tmtc/acs/gps.py b/eive_tmtc/tmtc/acs/gps.py index da90ce1..e5a57b7 100644 --- a/eive_tmtc/tmtc/acs/gps.py +++ b/eive_tmtc/tmtc/acs/gps.py @@ -82,34 +82,52 @@ def pack_gps_command(object_id: bytes, q: DefaultPusQueueHelper, op_code: str): raise ValueError("invalid interval") q.add_log_cmd(f"GPS: {Info.ENABLE_CORE_HK}") cmds = create_enable_periodic_hk_command_with_interval( - diag=False, sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK), interval_seconds=interval + diag=False, + sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK), + interval_seconds=interval, ) for cmd in cmds: q.add_pus_tc(cmd) if op_code in OpCode.DISABLE_CORE_HK: q.add_log_cmd(f"gps: {Info.DISABLE_CORE_HK}") - q.add_pus_tc(create_disable_periodic_hk_command(diag=False, sid=make_sid(object_id=object_id, - set_id=SetId.CORE_HK))) + q.add_pus_tc( + create_disable_periodic_hk_command( + diag=False, sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK) + ) + ) if op_code in OpCode.REQ_CORE_HK: q.add_log_cmd(f"GPS: {Info.REQ_CORE_HK}") - q.add_pus_tc(create_request_one_hk_command(sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK))) + q.add_pus_tc( + create_request_one_hk_command( + sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK) + ) + ) if op_code in OpCode.ENABLE_SKYVIEW_HK: interval = float(input("Please specify interval in floating point seconds: ")) if interval <= 0: raise ValueError("invalid interval") q.add_log_cmd(f"GPS: {Info.ENABLE_SKYVIEW_HK}") cmds = create_enable_periodic_hk_command_with_interval( - diag=False, sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK), interval_seconds=interval + diag=False, + sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK), + interval_seconds=interval, ) for cmd in cmds: q.add_pus_tc(cmd) if op_code in OpCode.DISABLE_SKYVIEW_HK: q.add_log_cmd(f"gps: {Info.DISABLE_SKYVIEW_HK}") - q.add_pus_tc(create_disable_periodic_hk_command(diag=False, sid=make_sid(object_id=object_id, - set_id=SetId.SKYVIEW_HK))) + q.add_pus_tc( + create_disable_periodic_hk_command( + diag=False, sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK) + ) + ) if op_code in OpCode.REQ_SKYVIEW_HK: q.add_log_cmd(f"GPS: {Info.REQ_SKYVIEW_HK}") - q.add_pus_tc(create_request_one_hk_command(sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK))) + q.add_pus_tc( + create_request_one_hk_command( + sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK) + ) + ) if op_code in OpCode.ON: q.add_log_cmd(f"GPS: {Info.ON}") q.add_pus_tc(create_mode_command(object_id, Mode.ON, 0)) @@ -133,7 +151,7 @@ def handle_gps_data( def handle_core_data(pw: PrintWrapper, hk_data: bytes): - if len(hk_data) < 4*8+4+2+8: + if len(hk_data) < 4 * 8 + 4 + 2 + 8: pw.dlog( f"GPS Core dataset with size {len(hk_data)} does not have expected size" f" of {4*8+4+2+8} bytes" @@ -179,7 +197,7 @@ def handle_core_data(pw: PrintWrapper, hk_data: bytes): def handle_skyview_data(pw: PrintWrapper, hk_data: bytes): - data_length = 8+GpsInfo.MAX_SATELLITES*(8+3*2+1) + data_length = 8 + GpsInfo.MAX_SATELLITES * (8 + 3 * 2 + 1) if len(hk_data) < data_length: pw.dlog( f"GPS Skyview dataset with size {len(hk_data)} does not have expected size" @@ -195,24 +213,46 @@ def handle_skyview_data(pw: PrintWrapper, hk_data: bytes): inc_len_int16 = struct.calcsize(fmt_str_int16) inc_len_double = struct.calcsize(fmt_str_double) inc_len_uint8 = struct.calcsize(fmt_str_uint8) - unix = struct.unpack(fmt_str_unix, hk_data[current_idx: current_idx + inc_len_unix])[0] + unix = struct.unpack( + fmt_str_unix, hk_data[current_idx : current_idx + inc_len_unix] + )[0] current_idx += inc_len_unix - prn_id = struct.unpack(fmt_str_int16, hk_data[current_idx: current_idx + inc_len_int16]) + prn_id = struct.unpack( + fmt_str_int16, hk_data[current_idx : current_idx + inc_len_int16] + ) current_idx += inc_len_int16 - azimuth = struct.unpack(fmt_str_int16, hk_data[current_idx: current_idx + inc_len_int16]) + azimuth = struct.unpack( + fmt_str_int16, hk_data[current_idx : current_idx + inc_len_int16] + ) current_idx += inc_len_int16 - elevation = struct.unpack(fmt_str_int16, hk_data[current_idx: current_idx + inc_len_int16]) + elevation = struct.unpack( + fmt_str_int16, hk_data[current_idx : current_idx + inc_len_int16] + ) current_idx += inc_len_int16 - signal_to_noise = struct.unpack(fmt_str_double, hk_data[current_idx: current_idx + inc_len_double]) + signal_to_noise = struct.unpack( + fmt_str_double, hk_data[current_idx : current_idx + inc_len_double] + ) current_idx += inc_len_double - used = struct.unpack(fmt_str_uint8, hk_data[current_idx: current_idx + inc_len_uint8]) + used = struct.unpack( + fmt_str_uint8, hk_data[current_idx : current_idx + inc_len_uint8] + ) current_idx += inc_len_uint8 pw.dlog(f"Skyview Time: {unix} unix-sec") - pw.dlog("{:<8} {:<8} {:<8} {:<8} {:<8}".format('PRN_ID', 'AZ [°]', 'EL [°]', 'S2N [dBW]', 'USED')) + pw.dlog( + "{:<8} {:<8} {:<8} {:<8} {:<8}".format( + "PRN_ID", "AZ [°]", "EL [°]", "S2N [dBW]", "USED" + ) + ) for idx in range(GpsInfo.MAX_SATELLITES): - pw.dlog("{:<8} {:<8} {:<8} {:<8} {:<8}".format(prn_id[idx], azimuth[idx], elevation[idx], signal_to_noise[idx], - used[idx])) + pw.dlog( + "{:<8} {:<8} {:<8} {:<8} {:<8}".format( + prn_id[idx], + azimuth[idx], + elevation[idx], + signal_to_noise[idx], + used[idx], + ) + ) FsfwTmTcPrinter.get_validity_buffer( validity_buffer=hk_data[current_idx:], num_vars=6 ) - diff --git a/tmtcc.py b/tmtcc.py index 1e82245..35d03fb 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -6,14 +6,11 @@ import traceback from pathlib import Path from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler +from eive_tmtc.cfdp.tm import CfdpInCcsdsWrapper from eive_tmtc.cfdp.user import EiveCfdpUser -from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE from spacepackets.cfdp import ( ChecksumType, TransmissionMode, - DirectiveType, - PduFactory, - PduType, ) from eive_tmtc.pus_tc.tc_handler import TcHandler @@ -121,28 +118,6 @@ class CustomCcsdsTmHandler(CcsdsTmHandler): _LOGGER.debug(f"Received packet {packet.hex(sep=',')} with APID {apid}") -class CfdpInCcsdsWrapper(SpecificApidHandlerBase): - def __init__(self, cfdp_in_ccsds_handler: CfdpInCcsdsHandler): - super().__init__(CFDP_APID, None) - self.handler = cfdp_in_ccsds_handler - - def handle_tm(self, packet: bytes, _user_args: any): - # Ignore the space packet header. Its only purpose is to use the same protocol and - # have a seaprate APID for space packets. If this function is called, the APID is correct. - pdu = packet[SPACE_PACKET_HEADER_SIZE:] - pdu_base = PduFactory.from_raw(pdu) - if pdu_base.pdu_type == PduType.FILE_DATA: - _LOGGER.info("Received File Data PDU TM") - else: - if pdu_base.directive_type == DirectiveType.FINISHED_PDU: - _LOGGER.info("Received Finished PDU TM") - else: - _LOGGER.info( - f"Received File Directive PDU with type {pdu_base.directive_type!r} TM" - ) - self.handler.pass_pdu_packet(pdu_base) - - def setup_params() -> (SetupWrapper, int): hook_obj = EiveHookObject(default_json_path()) params = SetupParams() @@ -234,7 +209,7 @@ def setup_tmtc_handlers( high_level_file_logger=printer.file_logger, raw_pus_logger=raw_logger, gui=gui, - cfdp_in_ccsds_wrapper=cfdp_in_ccsds_wrapper, + cfdp_in_ccsds_handler=cfdp_in_ccsds_wrapper.handler, ) return ccsds_handler, tc_handler @@ -285,7 +260,7 @@ def main(): # noqa C901: Complexity okay here. try: while True: state = tmtc_backend.periodic_op(None) - tc_handler.cfdp_in_ccsds_wrapper.handler.fsm() + tc_handler.cfdp_in_ccsds_handler.handler.fsm() if state.request == BackendRequest.TERMINATION_NO_ERROR: sys.exit(0) elif state.request == BackendRequest.DELAY_IDLE: From cc7b1d33315157f8cff62b7a920283c124e16ea8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Aug 2023 21:57:10 +0200 Subject: [PATCH 08/29] this is annoying.. --- eive_tmtc/pus_tc/tc_handler.py | 1 - tmtcc.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index ae61918..d3e71da 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -118,7 +118,6 @@ class TcHandler(TcHandlerBase): CFDP_REMOTE_ENTITY_ID, CFDP_LOCAL_ENTITY_ID, ) - print(put_req) else: put_req = cfdp_put_req_params_to_procedure(put_req_cfg_wrapper.cfg) _LOGGER.info( diff --git a/tmtcc.py b/tmtcc.py index 35d03fb..bb9b7ff 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -8,6 +8,7 @@ from pathlib import Path from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler from eive_tmtc.cfdp.tm import CfdpInCcsdsWrapper from eive_tmtc.cfdp.user import EiveCfdpUser +from spacepackets.version import get_version as get_spacepackets_version from spacepackets.cfdp import ( ChecksumType, TransmissionMode, @@ -232,7 +233,7 @@ def setup_backend( def main(): # noqa C901: Complexity okay here. print(f"-- eive tmtc v{__version__} --") - print(f"-- spacepackets v{spacepackets.__version__} --") + print(f"-- spacepackets v{get_spacepackets_version()} --") add_colorlog_console_logger(_LOGGER) # TODO: -V CLI argument to enable this? _LOGGER.setLevel(_LOG_LEVEL) From 25c7decb1ee3f46da4e10110ee2e027a3159f45b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Aug 2023 22:34:57 +0200 Subject: [PATCH 09/29] add local entity as remote entity cfg --- tmtcc.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tmtcc.py b/tmtcc.py index bb9b7ff..73c00e8 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -161,6 +161,15 @@ def setup_cfdp_handler() -> CfdpInCcsdsWrapper: indication_cfg=IndicationCfg(), default_fault_handlers=fh_base, ) + self_as_remote = RemoteEntityCfg( + closure_requested=False, + entity_id=CFDP_LOCAL_ENTITY_ID, + max_file_segment_len=990, + check_limit=None, + crc_on_transmission=False, + crc_type=ChecksumType.CRC_32, + default_transmission_mode=TransmissionMode.UNACKNOWLEDGED + ) remote_cfg = RemoteEntityCfg( closure_requested=False, entity_id=CFDP_REMOTE_ENTITY_ID, @@ -179,7 +188,7 @@ def setup_cfdp_handler() -> CfdpInCcsdsWrapper: cfdp_user = EiveCfdpUser() cfdp_in_ccsds_handler = CfdpInCcsdsHandler( cfg=cfdp_cfg, - remote_cfgs=[remote_cfg], + remote_cfgs=[remote_cfg, self_as_remote], ccsds_apid=CFDP_APID, ccsds_seq_cnt_provider=cfdp_ccsds_seq_count_provider, cfdp_seq_cnt_provider=cfdp_seq_count_provider, From c0bd5f572c22a3d2ee959efd73cbfbacc453ef1a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Aug 2023 22:56:26 +0200 Subject: [PATCH 10/29] small fix --- tmtcc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtcc.py b/tmtcc.py index 73c00e8..cc34106 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -270,7 +270,7 @@ def main(): # noqa C901: Complexity okay here. try: while True: state = tmtc_backend.periodic_op(None) - tc_handler.cfdp_in_ccsds_handler.handler.fsm() + tc_handler.cfdp_in_ccsds_handler.fsm() if state.request == BackendRequest.TERMINATION_NO_ERROR: sys.exit(0) elif state.request == BackendRequest.DELAY_IDLE: From 8d6ca602f2ab8dd6b38e88546f23dd8e809211c2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Aug 2023 23:28:57 +0200 Subject: [PATCH 11/29] this finally looks correct --- eive_tmtc/pus_tc/tc_handler.py | 2 +- tmtcc.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index d3e71da..35df314 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -115,8 +115,8 @@ class TcHandler(TcHandlerBase): if put_req_cfg_wrapper.cfg.proxy_op: put_req = cfdp_req_to_put_req_proxy_get_req( put_req_cfg_wrapper.cfg, - CFDP_REMOTE_ENTITY_ID, CFDP_LOCAL_ENTITY_ID, + CFDP_REMOTE_ENTITY_ID, ) else: put_req = cfdp_put_req_params_to_procedure(put_req_cfg_wrapper.cfg) diff --git a/tmtcc.py b/tmtcc.py index cc34106..503cf9d 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -168,7 +168,7 @@ def setup_cfdp_handler() -> CfdpInCcsdsWrapper: check_limit=None, crc_on_transmission=False, crc_type=ChecksumType.CRC_32, - default_transmission_mode=TransmissionMode.UNACKNOWLEDGED + default_transmission_mode=TransmissionMode.UNACKNOWLEDGED, ) remote_cfg = RemoteEntityCfg( closure_requested=False, From f9f8f9481fe78aec60a4ad121a72d2011d18363f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Aug 2023 11:04:05 +0200 Subject: [PATCH 12/29] hmm --- .run/CFDP Downlink Test.run.xml | 24 ++++++++++++++++++++++++ eive_tmtc/pus_tc/tc_handler.py | 4 ++-- pyproject.toml | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .run/CFDP Downlink Test.run.xml diff --git a/.run/CFDP Downlink Test.run.xml b/.run/CFDP Downlink Test.run.xml new file mode 100644 index 0000000..42f0a50 --- /dev/null +++ b/.run/CFDP Downlink Test.run.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index 35df314..10fca86 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -10,6 +10,7 @@ from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure from tmtccmd import TcHandlerBase, ProcedureWrapper from tmtccmd.cfdp.defs import CfdpRequestType from tmtccmd.cfdp.handler import CfdpInCcsdsHandler +from tmtccmd.config import cfdp_put_req_params_to_procedure from tmtccmd.logging import get_current_time_string from tmtccmd.logging.pus import RawTmtcTimedLogWrapper from tmtccmd.tc import ( @@ -20,8 +21,7 @@ from tmtccmd.tc import ( SendCbParams, TcQueueEntryType, ) -from tmtccmd.config import ( - cfdp_put_req_params_to_procedure, +from tmtccmd.config.cfdp import ( cfdp_req_to_put_req_proxy_get_req, ) from spacepackets.ecss import PusVerificator diff --git a/pyproject.toml b/pyproject.toml index 3e613db..6fcf95e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ classifiers = [ dependencies = [ # "tmtccmd ~= 5.0", "python-dateutil ~= 2.8", - "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@cfdp-proxy-op-support" + "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@main" ] [project.urls] From c2bed714dc43bc4a8ef4954fe72ae7c98b8bc2c8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Aug 2023 11:37:17 +0200 Subject: [PATCH 13/29] call correct conversion function --- eive_tmtc/pus_tc/tc_handler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index 10fca86..684a8b0 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -10,7 +10,6 @@ from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure from tmtccmd import TcHandlerBase, ProcedureWrapper from tmtccmd.cfdp.defs import CfdpRequestType from tmtccmd.cfdp.handler import CfdpInCcsdsHandler -from tmtccmd.config import cfdp_put_req_params_to_procedure from tmtccmd.logging import get_current_time_string from tmtccmd.logging.pus import RawTmtcTimedLogWrapper from tmtccmd.tc import ( @@ -23,6 +22,7 @@ from tmtccmd.tc import ( ) from tmtccmd.config.cfdp import ( cfdp_req_to_put_req_proxy_get_req, + cfdp_req_to_put_req_regular, ) from spacepackets.ecss import PusVerificator from tmtccmd.util import FileSeqCountProvider @@ -119,7 +119,9 @@ class TcHandler(TcHandlerBase): CFDP_REMOTE_ENTITY_ID, ) else: - put_req = cfdp_put_req_params_to_procedure(put_req_cfg_wrapper.cfg) + put_req = cfdp_req_to_put_req_regular( + put_req_cfg_wrapper.cfg, CFDP_REMOTE_ENTITY_ID + ) _LOGGER.info( f"CFDP: Starting file put request with parameters:\n{put_req}" ) From c687b1411ce5349f3301bbe31ef09e6325d1ad43 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 31 Aug 2023 09:25:57 +0200 Subject: [PATCH 14/29] adapt run file for file downlink --- .run/CFDP Downlink Test.run.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.run/CFDP Downlink Test.run.xml b/.run/CFDP Downlink Test.run.xml index 42f0a50..85113b1 100644 --- a/.run/CFDP Downlink Test.run.xml +++ b/.run/CFDP Downlink Test.run.xml @@ -13,7 +13,7 @@