Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/robamu-org/tmtccmd
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed May 5, 2022
2 parents 49232b5 + 5348bb9 commit 11960d5
Show file tree
Hide file tree
Showing 47 changed files with 260 additions and 277 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ cd example
py tmtccli.py
```

The [SOURCE](https://git.ksat-stuttgart.de/source/tmtc) implementation of the TMTC commander
provides a more complex implementation.
The [EIVE](https://egit.irs.uni-stuttgart.de/eive/eive-tmtc) and
[SOURCE](https://git.ksat-stuttgart.de/source/tmtc) project implementation of the TMTC commander
provide more complex implementations.

## Tests

Expand Down
2 changes: 1 addition & 1 deletion examples/config/tm_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from spacepackets.ecss import PusTelemetry
from tmtccmd.pus.service_17_test import Service17TMExtended
from tmtccmd.tm.pus_17_test import Service17TMExtended
from tmtccmd.tm import Service5Tm
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.logging import get_console_logger
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ install_requires =
colorama>=0.4.4
colorlog>=6.6.0
dle-encoder>=0.2
spacepackets>=0.6
spacepackets>=0.7.1
prompt-toolkit>=3.0.28
package_dir =
= src
Expand Down
2 changes: 1 addition & 1 deletion src/tests/hook_obj_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from tmtccmd.config.com_if import CommunicationInterface
from tmtccmd.config.definitions import DEFAULT_APID
from tmtccmd.config.definitions import ServiceOpCodeDictT, CoreModeList
from tmtccmd.tm.service_3_base import Service3Base
from tmtccmd.tm.pus_3_hk_base import Service3Base
from tmtccmd.core.backend import TmTcHandler
from tmtccmd.tc.definitions import TcQueueT
from tmtccmd.config.hook import TmTcHookBase
Expand Down
4 changes: 2 additions & 2 deletions src/tests/test_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from spacepackets.ccsds.time import CdsShortTimestamp

from tmtccmd.pus.service_1_verification import Service1TMExtended
from tmtccmd.pus.service_17_test import pack_service_17_ping_command
from tmtccmd.tm.pus_1_verification import Service1TMExtended
from tmtccmd.pus.pus_17_test import pack_service_17_ping_command
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.logging import get_console_logger, LOG_DIR
from tmtccmd.config.globals import update_global, CoreGlobalIds
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_pus.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from spacepackets.ecss.conf import get_pus_tm_version, PusVersion, set_default_tm_apid
from spacepackets.util import PrintFormats

from tmtccmd.pus.service_17_test import Service17TMExtended
from tmtccmd.tm.pus_17_test import Service17TMExtended


class TestTelemetry(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion src/tmtccmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

# I think this needs to be in string representation to be parsed so we can't
# use a formatted string here.
__version__ = "2.0.1"
__version__ = "2.1.0"
6 changes: 3 additions & 3 deletions src/tmtccmd/com_if/dummy_com_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from tmtccmd.com_if.com_interface_base import CommunicationInterface
from tmtccmd.tm import TelemetryListT
from tmtccmd.pus.service_1_verification import Service1TMExtended
from tmtccmd.pus.service_17_test import Srv17Subservices, Service17TMExtended
from tmtccmd.tm.pus_1_verification import Service1TMExtended
from tmtccmd.tm.pus_17_test import Subservices, Service17TMExtended
from tmtccmd.logging import get_console_logger
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter

Expand Down Expand Up @@ -100,7 +100,7 @@ def generate_reply_package(self):
self.next_telemetry_package.append(tm_packet_raw)
self.current_ssc += 1

tm_packer = Service17TMExtended(subservice=Srv17Subservices.PING_REPLY)
tm_packer = Service17TMExtended(subservice=Subservices.TM_REPLY)
tm_packet_raw = tm_packer.pack()
self.next_telemetry_package.append(tm_packet_raw)
self.current_ssc += 1
Expand Down
2 changes: 1 addition & 1 deletion src/tmtccmd/com_if/tcpip_udp_com_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def open(self, args: any = None):
# Set non-blocking because we use select.
self.udp_socket.setblocking(False)
if self.init_mode == CoreModeList.LISTENER_MODE:
from tmtccmd.pus.service_17_test import pack_service17_ping_command
from tmtccmd.pus.pus_17_test import pack_service17_ping_command

# Send ping command immediately so the reception address is known for UDP
ping_cmd = pack_service17_ping_command(ssc=0)
Expand Down
4 changes: 1 addition & 3 deletions src/tmtccmd/config/hook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys
import argparse
from abc import abstractmethod
from typing import Optional, Union

Expand All @@ -10,7 +8,7 @@
)
from tmtccmd.logging import get_console_logger
from tmtccmd.utility.retval import RetvalDictT
from tmtccmd.pus.obj_id import ObjectIdDictT
from tmtccmd.utility.obj_id import ObjectIdDictT
from tmtccmd.core.backend import BackendBase
from tmtccmd.tc.definitions import TcQueueT
from tmtccmd.com_if.com_interface_base import CommunicationInterface
Expand Down
4 changes: 1 addition & 3 deletions src/tmtccmd/config/objects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import copy
from typing import Dict
from tmtccmd.pus.obj_id import ObjectIdDictT, ObjectId
from tmtccmd.utility.obj_id import ObjectIdDictT, ObjectId


INVALID_ID = bytes([0xFF, 0xFF, 0xFF, 0xFF])
Expand Down
4 changes: 2 additions & 2 deletions src/tmtccmd/fsfw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os
import copy
from typing import Optional
from tmtccmd.pus.obj_id import ObjectId, ObjectIdDictT
from tmtccmd.pus.service_5_event import EventInfo, str_to_severity, EventDictT
from tmtccmd.utility.obj_id import ObjectId, ObjectIdDictT
from tmtccmd.pus.pus_5_event import EventInfo, EventDictT
from tmtccmd.utility.retval import RetvalDictT, RetvalInfo


Expand Down
2 changes: 1 addition & 1 deletion src/tmtccmd/pus/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from tmtccmd.pus.obj_id import ObjectId

51 changes: 51 additions & 0 deletions src/tmtccmd/pus/pus_17_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from __future__ import annotations
import enum

from spacepackets.ecss.conf import get_default_tc_apid
from spacepackets.ecss.pus_17_test import Subservices
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.definitions import PusTelecommand, TcQueueT


class CustomSubservices(enum.IntEnum):
TC_GEN_EVENT = 128


def pack_service_17_ping_command(ssc: int, apid: int = -1) -> PusTelecommand:
"""Generate a simple ping PUS telecommand packet"""
if apid == -1:
apid = get_default_tc_apid()
return PusTelecommand(
service=17, subservice=Subservices.TC_PING.value, ssc=ssc, apid=apid
)


def pack_generic_service17_test(
init_ssc: int, tc_queue: TcQueueT, apid: int = -1
) -> int:
if apid == -1:
apid = get_default_tc_apid()
new_ssc = init_ssc
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 17"))
# ping test
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 17: Ping Test"))
tc_queue.appendleft(pack_service_17_ping_command(ssc=new_ssc).pack_command_tuple())
new_ssc += 1
# enable event
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 17: Enable Event"))
command = PusTelecommand(service=5, subservice=5, ssc=new_ssc, apid=apid)
tc_queue.appendleft(command.pack_command_tuple())
new_ssc += 1
# test event
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 17: Trigger event"))
command = PusTelecommand(
service=17, subservice=CustomSubservices.TC_GEN_EVENT, ssc=new_ssc, apid=apid
)
tc_queue.appendleft(command.pack_command_tuple())
new_ssc += 1
# invalid subservice
tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 17: Invalid subservice"))
command = PusTelecommand(service=17, subservice=243, ssc=new_ssc, apid=apid)
tc_queue.appendleft(command.pack_command_tuple())
new_ssc += 1
return new_ssc
12 changes: 12 additions & 0 deletions src/tmtccmd/pus/pus_200_fsfw_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import enum


class Subservices(enum.IntEnum):
TC_MODE_COMMAND = 1
TC_MODE_COMMAND_FORCES = 2
TC_MODE_READ = 3
TC_MODE_ANNOUNCE = 4
TC_MODE_ANNOUNCE_RECURSIVE = 5
TM_MODE_REPLY = 6
TM_CANT_REACH_MODE = 7
TM_WRONG_MODE_REPLY = 8
8 changes: 8 additions & 0 deletions src/tmtccmd/pus/pus_201_fsfw_health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import enum


class Subservices(enum.IntEnum):
TC_SET_HEALTH = 1
TM_HEALTH_SET = 2
TC_ANNOUNCE_HEALTH = 3
TC_ANNOUNCE_HEALTH_ALL = 4
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import enum
from typing import Optional, Dict


class Severity(enum.IntEnum):
INFO = 1
LOW_SEVERITY = 2
MEDIUM_SEVERITY = 3
HIGH_SEVERITY = 4
from spacepackets.ecss.pus_5_event import Severity


def str_to_severity(string: str) -> Optional[Severity]:
Expand All @@ -20,15 +13,6 @@ def str_to_severity(string: str) -> Optional[Severity]:
return Severity.HIGH


class Srv5Subservices(enum.IntEnum):
INFO_EVENT = Severity.INFO
LOW_SEVERITY_EVENT = Severity.LOW_SEVERITY
MEDIUM_SEVERITY_EVENT = Severity.MEDIUM_SEVERITY
HIGH_SEVERITY_EVENT = Severity.HIGH_SEVERITY
ENABLE_EVENT_REPORTING = 5
DISABLE_EVENT_REPORTING = 6


class EventInfo:
id: int = 0
name: str = ""
Expand Down
6 changes: 6 additions & 0 deletions src/tmtccmd/pus/pus_8_funccmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import enum


class Subservices(enum.IntEnum):
FUNCTIONAL_CMD = 128
DATA_REPLY = 130
107 changes: 0 additions & 107 deletions src/tmtccmd/pus/service_17_test.py

This file was deleted.

12 changes: 0 additions & 12 deletions src/tmtccmd/pus/service_200_fsfw_mode.py

This file was deleted.

6 changes: 0 additions & 6 deletions src/tmtccmd/pus/service_8_func_cmd.py

This file was deleted.

Empty file removed src/tmtccmd/pus/service_list.py
Empty file.
4 changes: 2 additions & 2 deletions src/tmtccmd/tc/packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from tmtccmd.tc.definitions import TcQueueT
from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.logging import get_console_logger
from tmtccmd.pus.service_17_test import pack_service_17_ping_command
from tmtccmd.tc.service_5_event import pack_generic_service5_test_into
from tmtccmd.pus.pus_17_test import pack_service_17_ping_command
from tmtccmd.tc.pus_5_event import pack_generic_service5_test_into

LOGGER = get_console_logger()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import enum
import struct
from tmtccmd.pus.service_200_fsfw_mode import Subservices
from tmtccmd.pus.pus_200_fsfw_mode import Subservices


class Modes(enum.IntEnum):
Expand All @@ -15,9 +15,6 @@ class Modes(enum.IntEnum):

def pack_mode_data(object_id: bytes, mode: Modes, submode: int) -> bytearray:
"""Mode 0: Off, Mode 1: Mode On, Mode 2: Mode Normal, Mode 3: Mode Raw"""
# Normal mode
mode_packed = struct.pack("!I", mode)
# Submode default
submode_byte = struct.pack("B", submode)
mode_data = object_id + mode_packed + submode_byte
mode_data = bytearray()
mode_data += object_id + struct.pack("!I", mode) + struct.pack("B", submode)
return mode_data
Loading

0 comments on commit 11960d5

Please sign in to comment.