Skip to content

Commit

Permalink
fixed conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobMeier committed Dec 24, 2021
2 parents d167d8c + 1c3c9c4 commit 5fdeec2
Show file tree
Hide file tree
Showing 68 changed files with 1,681 additions and 916 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Change Log
=======

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased]

## [v1.11.0]

- New API to build service/opcode dictionary

## [v1.10.1]

- Applied consistent formatting with `black` tool
- Some bugfixes for PUS packet stack
29 changes: 14 additions & 15 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../src'))

sys.path.insert(0, os.path.abspath("../src"))
import tmtccmd

# -- Project information -----------------------------------------------------

project = 'tmtccmd'
copyright = '2021, Robin Mueller'
author = 'Robin Mueller'
project = "tmtccmd"
copyright = "2021, Robin Mueller"
author = "Robin Mueller"

# The full version, including alpha/beta/rc tags
version = release = tmtccmd.__version__
Expand All @@ -29,37 +30,35 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']
extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = ".rst"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
exclude_trees = ["_build"]

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None)
}
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = 'logo_tmtccmd.png'
html_logo = "logo_tmtccmd.png"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -70,4 +69,4 @@

# The name of an image file (relative to this directory) to place at the top of
# the title page.
latex_logo = 'logo_tmtccmd.png'
latex_logo = "logo_tmtccmd.png"
2 changes: 1 addition & 1 deletion example/config/definitions.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
APID = 0xef
APID = 0xEF
24 changes: 17 additions & 7 deletions example/config/hook_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,62 @@
from tmtccmd.tm.service_3_base import Service3Base

from config.definitions import APID

LOGGER = get_console_logger()


class ExampleHookClass(TmTcHookBase):

def add_globals_pre_args_parsing(self, gui: bool = False):
from tmtccmd.config.globals import set_default_globals_pre_args_parsing

set_default_globals_pre_args_parsing(gui=gui, tc_apid=APID, tm_apid=APID)

def add_globals_post_args_parsing(self, args: argparse.Namespace):
from tmtccmd.config.globals import set_default_globals_post_args_parsing

set_default_globals_post_args_parsing(
args=args, json_cfg_path=self.get_json_config_file_path()
)

def assign_communication_interface(self, com_if_key: str, tmtc_printer: TmTcPrinter) -> \
Union[CommunicationInterface, None]:
def assign_communication_interface(
self, com_if_key: str, tmtc_printer: TmTcPrinter
) -> Union[CommunicationInterface, None]:
from tmtccmd.config.com_if import create_communication_interface_default

LOGGER.info("Communication interface assignment function was called")
return create_communication_interface_default(
com_if_key=com_if_key, tmtc_printer=tmtc_printer,
json_cfg_path=self.get_json_config_file_path()
com_if_key=com_if_key,
tmtc_printer=tmtc_printer,
json_cfg_path=self.get_json_config_file_path(),
)

def perform_mode_operation(self, tmtc_backend: TmTcHandler, mode: int):
LOGGER.info("Mode operation hook was called")
pass

def pack_service_queue(self, service: Union[str, int], op_code: str, service_queue: TcQueueT):
def pack_service_queue(
self, service: Union[str, int], op_code: str, service_queue: TcQueueT
):
from tmtccmd.tc.packer import default_service_queue_preparation

LOGGER.info("Service queue packer hook was called")
default_service_queue_preparation(
service=service, op_code=op_code, service_queue=service_queue
)

def get_object_ids(self) -> Dict[bytes, list]:
from tmtccmd.config.objects import get_core_object_ids

return get_core_object_ids()

def get_service_op_code_dictionary(self) -> ServiceOpCodeDictT:
from tmtccmd.config.globals import get_default_service_op_code_dict

return get_default_service_op_code_dict()

@staticmethod
def handle_service_8_telemetry(
object_id: int, action_id: int, custom_data: bytearray
object_id: int, action_id: int, custom_data: bytearray
) -> Tuple[list, list]:
pass

Expand Down
8 changes: 6 additions & 2 deletions example/tmtc_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"""Example application for the TMTC Commander
"""
from tmtccmd.ccsds.handler import CcsdsTmHandler
from tmtccmd.runner import run_tmtc_commander, initialize_tmtc_commander, add_ccsds_handler
from tmtccmd.runner import (
run_tmtc_commander,
initialize_tmtc_commander,
add_ccsds_handler,
)
from tmtccmd.tm.handler import default_ccsds_packet_handler

from config.hook_implementation import ExampleHookClass
Expand All @@ -20,5 +24,5 @@ def main():
run_tmtc_commander(use_gui=False)


if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion example/tmtc_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def main():
run_tmtc_commander(use_gui=True, app_name="TMTC Commander Example")


if __name__ == '__main__':
if __name__ == "__main__":
main()
29 changes: 15 additions & 14 deletions lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@

def main():
# Ignore folder created by venv
exclude_dirs_flag = '--exclude bin,lib'
additional_flags_both_steps = '--count --statistics'
additional_flags_first_step = '--select=E9,F63,F7,F82 --show-source'
flake8_first_step_cmd = \
f'flake8 . {additional_flags_both_steps} {additional_flags_first_step} {exclude_dirs_flag}'
exclude_dirs_flag = "--exclude bin,lib"
additional_flags_both_steps = "--count --statistics"
additional_flags_first_step = "--select=E9,F63,F7,F82 --show-source"
flake8_first_step_cmd = f"flake8 . {additional_flags_both_steps} {additional_flags_first_step} {exclude_dirs_flag}"
status = os.system(flake8_first_step_cmd)
if os.name == 'nt':
if os.name == "nt":
if status != 0:
print(f'Flake8 linter errors with status {status}')
print(f"Flake8 linter errors with status {status}")
else:
if os.WEXITSTATUS(status) != 0:
print(f'Flake8 linter errors with status {status}')
print(f"Flake8 linter errors with status {status}")
sys.exit(0)
additional_flags_second_step = \
'--exit-zero --max-complexity=10 --per-file-ignores="__init__.py:F401" ' \
'--max-line-length=127'
flake8_second_step_cmd = \
f'flake8 . {additional_flags_both_steps} {additional_flags_second_step}' \
f' {exclude_dirs_flag}'
additional_flags_second_step = (
'--exit-zero --max-complexity=10 --per-file-ignores="__init__.py:F401" '
"--max-line-length=127"
)
flake8_second_step_cmd = (
f"flake8 . {additional_flags_both_steps} {additional_flags_second_step}"
f" {exclude_dirs_flag}"
)
os.system(flake8_second_step_cmd)


Expand Down
22 changes: 15 additions & 7 deletions src/tests/backend_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@


def create_backend_mock(tm_handler: CcsdsTmHandler) -> TmTcHandler:
tmtc_printer = TmTcPrinter(display_mode=DisplayMode.LONG, do_print_to_file=False, print_tc=True)
com_if = create_communication_interface_default(
com_if_key=CoreComInterfaces.DUMMY.value, json_cfg_path="tmtc_config.json", tmtc_printer=tmtc_printer
tmtc_printer = TmTcPrinter(
display_mode=DisplayMode.LONG, do_print_to_file=False, print_tc=True
)
tm_listener = TmListener(
com_if=com_if, tm_timeout=3.0, tc_timeout_factor=3.0
com_if = create_communication_interface_default(
com_if_key=CoreComInterfaces.DUMMY.value,
json_cfg_path="tmtc_config.json",
tmtc_printer=tmtc_printer,
)
tm_listener = TmListener(com_if=com_if, tm_timeout=3.0, tc_timeout_factor=3.0)
# The global variables are set by the argument parser.
tmtc_backend = TmTcHandler(
com_if=com_if, tmtc_printer=tmtc_printer, tm_listener=tm_listener,
init_mode=CoreModeList.IDLE, init_service=17, init_opcode="0", tm_handler=tm_handler
com_if=com_if,
tmtc_printer=tmtc_printer,
tm_listener=tm_listener,
init_mode=CoreModeList.IDLE,
init_service=17,
init_opcode="0",
tm_handler=tm_handler,
)
tmtc_backend.start_listener = MagicMock(return_value=0)
tmtc_backend.initialize = MagicMock(return_value=0)
Expand All @@ -29,6 +36,7 @@ def create_backend_mock(tm_handler: CcsdsTmHandler) -> TmTcHandler:

def create_frontend_mock() -> FrontendBase:
from tmtccmd.core.frontend_base import FrontendBase

tmtc_frontend = FrontendBase()
tmtc_frontend.start = MagicMock(return_value=0)
return tmtc_frontend
21 changes: 15 additions & 6 deletions src/tests/hook_obj_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def create_hook_mock_with_srv_handlers() -> TmTcHookBase:
tmtc_hook_base.handle_service_5_event = MagicMock(return_value="Test Custom String")
# Valid returnvalue for now
srv_3_return_tuple = (["Test"], [0], bytearray(0b10000000), 1)
tmtc_hook_base.handle_service_3_housekeeping = MagicMock(return_value=srv_3_return_tuple)
tmtc_hook_base.handle_service_3_housekeeping = MagicMock(
return_value=srv_3_return_tuple
)
return tmtc_hook_base


Expand Down Expand Up @@ -67,6 +69,7 @@ def add_globals_pre_args_parsing(self, gui: bool = False):
:return:
"""
from tmtccmd.config.globals import set_default_globals_pre_args_parsing

set_default_globals_pre_args_parsing(gui=gui, apid=DEFAULT_APID)

@abstractmethod
Expand All @@ -76,13 +79,14 @@ def add_globals_post_args_parsing(self, args: argparse.Namespace):
:param args: Specify whether a GUI is used
"""
from tmtccmd.config.globals import set_default_globals_post_args_parsing

set_default_globals_post_args_parsing(
args=args, json_cfg_path=self.get_json_config_file_path()
)

@abstractmethod
def assign_communication_interface(
self, com_if_key: str, tmtc_printer: TmTcPrinter
self, com_if_key: str, tmtc_printer: TmTcPrinter
) -> Optional[CommunicationInterface]:
"""Assign the communication interface used by the TMTC commander to send and receive
TMTC with.
Expand All @@ -91,9 +95,11 @@ def assign_communication_interface(
:param tmtc_printer: Printer utility instance.
"""
from tmtccmd.config.com_if import create_communication_interface_default

return create_communication_interface_default(
com_if_key=com_if_key, tmtc_printer=tmtc_printer,
json_cfg_path=self.get_json_config_file_path()
com_if_key=com_if_key,
tmtc_printer=tmtc_printer,
json_cfg_path=self.get_json_config_file_path(),
)

@abstractmethod
Expand All @@ -104,6 +110,7 @@ def get_service_op_code_dictionary(self) -> ServiceOpCodeDictT:
:return:
"""
from tmtccmd.config.globals import get_default_service_op_code_dict

return get_default_service_op_code_dict()

@abstractmethod
Expand All @@ -116,7 +123,9 @@ def perform_mode_operation(self, tmtc_backend: TmTcHandler, mode: int):
pass

@abstractmethod
def pack_service_queue(self, service: Union[int, str], op_code: str, service_queue: TcQueueT):
def pack_service_queue(
self, service: Union[int, str], op_code: str, service_queue: TcQueueT
):
"""Overriding this function allows the user to package a telecommand queue for a given
service and operation code combination.
Expand All @@ -129,7 +138,7 @@ def pack_service_queue(self, service: Union[int, str], op_code: str, service_que

@staticmethod
def handle_service_8_telemetry(
object_id: bytes, action_id: int, custom_data: bytearray
object_id: bytes, action_id: int, custom_data: bytearray
) -> Tuple[list, list]:
"""This function is called by the TMTC core to handle Service 8 packets
The user can return a tuple of two lists, where the first list
Expand Down

0 comments on commit 5fdeec2

Please sign in to comment.