tmtccmd refactoring
This commit is contained in:
parent
e67eb6633e
commit
3c302bd4e8
@ -6,6 +6,7 @@ from typing import Union
|
|||||||
|
|
||||||
from tmtccmd.config.definitions import CoreServiceList
|
from tmtccmd.config.definitions import CoreServiceList
|
||||||
from tmtccmd.logging import get_console_logger
|
from tmtccmd.logging import get_console_logger
|
||||||
|
from tmtccmd.logging.pus import log_pus_tc
|
||||||
from tmtccmd.tc.definitions import TcQueueT
|
from tmtccmd.tc.definitions import TcQueueT
|
||||||
from tmtccmd.tc.service_5_event import pack_generic_service5_test_into
|
from tmtccmd.tc.service_5_event import pack_generic_service5_test_into
|
||||||
from tmtccmd.pus.service_17_test import pack_service_17_ping_command
|
from tmtccmd.pus.service_17_test import pack_service_17_ping_command
|
||||||
@ -68,6 +69,12 @@ from config.object_ids import (
|
|||||||
LOGGER = get_console_logger()
|
LOGGER = get_console_logger()
|
||||||
|
|
||||||
|
|
||||||
|
def pre_tc_send_cb(packet: bytes, user_args: any):
|
||||||
|
service = packet[7]
|
||||||
|
subservice = packet[8]
|
||||||
|
log_pus_tc(packet=packet, srv_subservice=(service, subservice))
|
||||||
|
|
||||||
|
|
||||||
def pack_service_queue_user(
|
def pack_service_queue_user(
|
||||||
service: Union[str, int], op_code: str, service_queue: TcQueueT
|
service: Union[str, int], op_code: str, service_queue: TcQueueT
|
||||||
):
|
):
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
from tmtccmd.tm.service_8_fsfw_functional_cmd import Service8FsfwTm
|
from tmtccmd.tm.service_8_fsfw_functional_cmd import Service8FsfwTm
|
||||||
from spacepackets.ecss.tm import PusTelemetry
|
from spacepackets.ecss.tm import PusTelemetry
|
||||||
from tmtccmd.logging import get_console_logger
|
from tmtccmd.logging import get_console_logger
|
||||||
|
from tmtccmd.logging.pus import log_pus_tm, log_unknown_packet, PacketTypes
|
||||||
|
|
||||||
from tmtccmd.pus.service_1_verification import Service1TMExtended
|
from tmtccmd.pus.service_1_verification import Service1TMExtended
|
||||||
from tmtccmd.pus.service_17_test import Service17TMExtended
|
from tmtccmd.pus.service_17_test import Service17TMExtended
|
||||||
@ -32,6 +33,7 @@ def pus_factory_hook(raw_tm_packet: bytes, tmtc_printer: FsfwTmTcPrinter):
|
|||||||
LOGGER.warning("Detected packet shorter than 8 bytes!")
|
LOGGER.warning("Detected packet shorter than 8 bytes!")
|
||||||
return
|
return
|
||||||
service_type = raw_tm_packet[7]
|
service_type = raw_tm_packet[7]
|
||||||
|
subservice_type = raw_tm_packet[8]
|
||||||
tm_packet = None
|
tm_packet = None
|
||||||
try:
|
try:
|
||||||
if service_type == 1:
|
if service_type == 1:
|
||||||
@ -57,9 +59,11 @@ def pus_factory_hook(raw_tm_packet: bytes, tmtc_printer: FsfwTmTcPrinter):
|
|||||||
tm_packet = PusTelemetry.unpack(raw_telemetry=raw_tm_packet)
|
tm_packet = PusTelemetry.unpack(raw_telemetry=raw_tm_packet)
|
||||||
tm_packet.print_source_data(PrintFormats.HEX)
|
tm_packet.print_source_data(PrintFormats.HEX)
|
||||||
LOGGER.info(f"Received packet with service {service_type}")
|
LOGGER.info(f"Received packet with service {service_type}")
|
||||||
|
log_pus_tm(packet=raw_tm_packet, srv_subservice=(service_type, subservice_type))
|
||||||
# tmtc_printer.print_telemetry(
|
# tmtc_printer.print_telemetry(
|
||||||
# packet_if=tm_packet, info_if=tm_packet, print_raw_tm=False
|
# packet_if=tm_packet, info_if=tm_packet, print_raw_tm=False
|
||||||
# )
|
# )
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# TODO: Log faulty packet
|
# TODO: Log faulty packet
|
||||||
LOGGER.warning("Invalid packet format detected")
|
LOGGER.warning("Invalid packet format detected")
|
||||||
|
log_unknown_packet(packet=raw_tm_packet, packet_type=PacketTypes.TM)
|
||||||
|
23
tmtccli.py
23
tmtccli.py
@ -26,16 +26,11 @@ limitations under the License.
|
|||||||
|
|
||||||
@author R. Mueller
|
@author R. Mueller
|
||||||
"""
|
"""
|
||||||
import logging
|
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from tmtccmd.runner import (
|
import tmtccmd.runner as tmtccmd
|
||||||
initialize_tmtc_commander,
|
|
||||||
run_tmtc_commander,
|
|
||||||
add_ccsds_handler,
|
|
||||||
)
|
|
||||||
from tmtccmd.ccsds.handler import CcsdsTmHandler, ApidHandler
|
from tmtccmd.ccsds.handler import CcsdsTmHandler, ApidHandler
|
||||||
from tmtccmd.logging import init_console_logger
|
from tmtccmd.logging import init_console_logger
|
||||||
except ImportError as error:
|
except ImportError as error:
|
||||||
@ -59,20 +54,28 @@ except ImportError as error:
|
|||||||
from config.hook_implementations import EiveHookObject
|
from config.hook_implementations import EiveHookObject
|
||||||
from config.version import __version__
|
from config.version import __version__
|
||||||
from config.definitions import PUS_APID
|
from config.definitions import PUS_APID
|
||||||
|
from pus_tc.tc_packer_hook import pre_tc_send_cb
|
||||||
from pus_tm.factory_hook import ccsds_tm_handler
|
from pus_tm.factory_hook import ccsds_tm_handler
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
hook_obj = EiveHookObject()
|
|
||||||
print(f"-- eive tmtc version {__version__} --")
|
print(f"-- eive tmtc version {__version__} --")
|
||||||
print(f"-- spacepackets version {spacepackets.__version__} --")
|
print(f"-- spacepackets version {spacepackets.__version__} --")
|
||||||
initialize_tmtc_commander(hook_object=hook_obj)
|
hook_obj = EiveHookObject()
|
||||||
|
tmtccmd.init_tmtccmd(hook_object=hook_obj)
|
||||||
ccsds_handler = CcsdsTmHandler()
|
ccsds_handler = CcsdsTmHandler()
|
||||||
init_console_logger()
|
init_console_logger()
|
||||||
pus_handler = ApidHandler(cb=ccsds_tm_handler, queue_len=50, user_args=None)
|
pus_handler = ApidHandler(cb=ccsds_tm_handler, queue_len=50, user_args=None)
|
||||||
ccsds_handler.add_tm_handler(apid=PUS_APID, handler=pus_handler)
|
ccsds_handler.add_tm_handler(apid=PUS_APID, handler=pus_handler)
|
||||||
add_ccsds_handler(ccsds_handler)
|
tmtccmd.add_ccsds_handler(ccsds_handler)
|
||||||
run_tmtc_commander(False)
|
tmtccmd.setup_tmtccmd(use_gui=False, reduced_printout=False)
|
||||||
|
tmtc_backend = tmtccmd.get_default_tmtc_backend(
|
||||||
|
hook_obj=hook_obj,
|
||||||
|
json_cfg_path=hook_obj.get_json_config_file_path(),
|
||||||
|
tm_handler=ccsds_handler
|
||||||
|
)
|
||||||
|
tmtc_backend.set_pre_send_cb(callable=pre_tc_send_cb, user_args=None)
|
||||||
|
tmtccmd.run_tmtccmd(False, tmtc_backend=tmtc_backend, run_setup=False)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
2
tmtccmd
2
tmtccmd
@ -1 +1 @@
|
|||||||
Subproject commit 0107689ce4362a315fd06642322e0487ab17ca90
|
Subproject commit 092babfe1430c756f0b3b1eb55333c8771b3e2b9
|
@ -35,8 +35,8 @@ from pus_tm.factory_hook import ccsds_tm_handler
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from tmtccmd.runner import (
|
from tmtccmd.runner import (
|
||||||
initialize_tmtc_commander,
|
init_tmtccmd,
|
||||||
run_tmtc_commander,
|
run_tmtccmd,
|
||||||
add_ccsds_handler,
|
add_ccsds_handler,
|
||||||
)
|
)
|
||||||
from tmtccmd.ccsds.handler import CcsdsTmHandler
|
from tmtccmd.ccsds.handler import CcsdsTmHandler
|
||||||
@ -56,13 +56,13 @@ def main():
|
|||||||
hook_obj = EiveHookObject()
|
hook_obj = EiveHookObject()
|
||||||
print(f"-- eive tmtc version {__version__}")
|
print(f"-- eive tmtc version {__version__}")
|
||||||
print(f"-- spacepackets version {spacepackets.__version__} --")
|
print(f"-- spacepackets version {spacepackets.__version__} --")
|
||||||
initialize_tmtc_commander(hook_object=hook_obj)
|
init_tmtccmd(hook_object=hook_obj)
|
||||||
ccsds_handler = CcsdsTmHandler()
|
ccsds_handler = CcsdsTmHandler()
|
||||||
ccsds_handler.add_tm_handler(
|
ccsds_handler.add_tm_handler(
|
||||||
apid=PUS_APID, pus_tm_handler=ccsds_tm_handler, max_queue_len=50
|
apid=PUS_APID, pus_tm_handler=ccsds_tm_handler, max_queue_len=50
|
||||||
)
|
)
|
||||||
add_ccsds_handler(ccsds_handler)
|
add_ccsds_handler(ccsds_handler)
|
||||||
run_tmtc_commander(use_gui=True)
|
run_tmtccmd(use_gui=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user