Something went wrong on our end
Forked from an inaccessible project.
-
Robin.Mueller authored
Additionally service 8 unit test added
Robin.Mueller authoredAdditionally service 8 unit test added
obsw_tc_service200.py 2.25 KiB
# -*- coding: utf-8 -*-
"""
Program: obsw_tc_service200.py
Date: 01.11.2019
Description: PUS Custom Service 200: Mode Commanding
Manual:
Contains a G_SERVICE select factory which returns specific G_SERVICE or device tests.
Also contains an all G_SERVICE and all device tc queue packer.
Run script with -s <Service or Device> -m 3 with optional -p parameter for file output inside the log folder
@author: R. Mueller
"""
from tc.obsw_pus_tc_base import PusTelecommand
from tc.obsw_pus_tc_packer import TcQueueT
import config.obsw_config as g
import struct
def pack_service200_test_into(tcQueue: TcQueueT) -> TcQueueT:
tcQueue.appendleft(("print", "Testing Service 200"))
# Object ID: Dummy Device
objectId = g.DUMMY_DEVICE_ID
# Set On Mode
tcQueue.appendleft(("print", "\r\nTesting Service 200: Set Mode On"))
modeData = packModeData(objectId, 1, 0)
command = PusTelecommand(service=200, subservice=1, ssc=2000, data=modeData)
tcQueue.appendleft(command.pack_command_tuple())
# Set Normal mode
tcQueue.appendleft(("print", "\r\nTesting Service 200: Set Mode Normal"))
modeData = packModeData(objectId, 2, 0)
command = PusTelecommand(service=200, subservice=1, ssc=2010, data=modeData)
tcQueue.appendleft(command.pack_command_tuple())
# Set Raw Mode
tcQueue.appendleft(("print", "\r\nTesting Service 200: Set Mode Raw"))
modeData = packModeData(objectId, 3, 0)
command = PusTelecommand(service=200, subservice=1, ssc=2020, data=modeData)
tcQueue.appendleft(command.pack_command_tuple())
# Set Off Mode
tcQueue.appendleft(("print", "\r\nTesting Service 200: Set Mode Off"))
modeData = packModeData(objectId, 0, 0)
command = PusTelecommand(service=200, subservice=1, ssc=2030, data=modeData)
tcQueue.appendleft(command.pack_command_tuple())
tcQueue.appendleft(("export", "log/tmtc_log_service200.txt"))
return tcQueue
# Mode 0: Off, Mode 1: Mode On, Mode 2: Mode Normal, Mode 3: Mode Raw
def packModeData(objectId: bytearray, mode_: int, submode_: int) -> bytearray:
# Normal mode
mode = struct.pack(">I", mode_)
# Submode default
submode = struct.pack('B', submode_)
modeData = objectId + mode + submode
return modeData