eive-tmtc/pus_tc/tmtcc_tc_service200_mode.py

54 lines
2.3 KiB
Python
Raw Normal View History

2021-01-10 11:42:06 +01:00
# -*- coding: utf-8 -*-
"""
@file tmtcc_tc_service200_mode.py
@brief PUS Service 200: PUS custom service 200: Mode commanding
@author R. Mueller
@date 02.05.2020
"""
2021-02-03 14:14:54 +01:00
from tmtc_core.core.tmtc_core_definitions import QueueCommands
2021-01-10 11:42:06 +01:00
from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand
from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT
from tmtc_core.core.tmtcc_object_id_manager import get_object_id
from config.tmtcc_object_ids import ObjectIds
import struct
TEST_DEVICE_ID = get_object_id(ObjectIds.TEST_DEVICE)
def pack_service200_test_into(tc_queue: TcQueueT) -> TcQueueT:
2021-02-03 14:14:54 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200"))
2021-01-10 11:42:06 +01:00
# Object ID: Dummy Device
object_id = TEST_DEVICE_ID
# Set On Mode
2021-02-03 14:14:54 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200: Set Mode On"))
2021-01-10 11:42:06 +01:00
mode_data = pack_mode_data(object_id, 1, 0)
command = PusTelecommand(service=200, subservice=1, ssc=2000, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple())
# Set Normal mode
2021-02-03 14:14:54 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200: Set Mode Normal"))
2021-01-10 11:42:06 +01:00
mode_data = pack_mode_data(object_id, 2, 0)
command = PusTelecommand(service=200, subservice=1, ssc=2010, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple())
# Set Raw Mode
2021-02-03 14:14:54 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200: Set Mode Raw"))
2021-01-10 11:42:06 +01:00
mode_data = pack_mode_data(object_id, 3, 0)
command = PusTelecommand(service=200, subservice=1, ssc=2020, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple())
# Set Off Mode
2021-02-03 14:14:54 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200: Set Mode Off"))
2021-01-10 11:42:06 +01:00
mode_data = pack_mode_data(object_id, 0, 0)
command = PusTelecommand(service=200, subservice=1, ssc=2030, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple())
2021-02-03 14:14:54 +01:00
tc_queue.appendleft((QueueCommands.EXPORT_LOG, "log/tmtc_log_service200.txt"))
2021-01-10 11:42:06 +01:00
return tc_queue
# Mode 0: Off, Mode 1: Mode On, Mode 2: Mode Normal, Mode 3: Mode Raw
def pack_mode_data(object_id: bytearray, mode_: int, submode_: int) -> bytearray:
# Normal mode
mode = struct.pack(">I", mode_)
# Submode default
submode = struct.pack('B', submode_)
mode_data = object_id + mode + submode
return mode_data