Skip to content

Commit

Permalink
prep next major version
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed May 3, 2024
1 parent a56a9bd commit 09a99d0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 28 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ Starting from v4.0.0, this project adheres to [Semantic Versioning](http://semve

# [unreleased]

# [v8.0.0] 2024-05-03

## Changed

- Renamed `FsfwTmTcPrinter.get_validity_buffer` to `FsfwTmTcPrinter.get_validity_buffer_str`

## Added

- Added `fsfw.tmtc_printer.get_validity_buffer_str` function.

# [v8.0.0rc2] 2024-04-23

- Bumped `spacepackets` to release range >=0.24, <0.25.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
name = "tmtccmd"
description = "TMTC Commander Core"
readme = "README.md"
version = "8.0.0rc.2"
version = "8.0.0"
requires-python = ">=3.8"
license = {text = "Apache-2.0 or MIT" }
authors = [
Expand Down
63 changes: 36 additions & 27 deletions tmtccmd/fsfw/tmtc_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,39 @@ class DisplayMode(enum.Enum):
LONG = enum.auto


def get_validity_buffer_str(validity_buffer: bytes, num_vars: int) -> str:
"""
:param validity_buffer: Validity buffer in bytes format
:param num_vars: Number of variables
:return:
"""
valid_list = []
counter = 0
for _index, byte in enumerate(validity_buffer):
for bit in range(1, 9):
if FsfwTmTcPrinter.bit_extractor(byte, bit) == 1:
valid_list.append(True)
else:
valid_list.append(False)
counter += 1
if counter == num_vars:
break
validity_lists = list(FsfwTmTcPrinter.chunks(n=16, lst=valid_list))
for valid_list in validity_lists:
printout = "Valid: ["
for idx, valid in enumerate(valid_list):
if valid:
printout += "Y"
else:
printout += "N"
if idx < len(valid_list) - 1:
printout += ","
else:
printout += "]"
return printout
return ""


class FsfwTmTcPrinter:
"""This class handles printing to the command line and to files"""

Expand Down Expand Up @@ -120,43 +153,19 @@ def generic_hk_tm_print(
self.file_logger.info(f"{get_current_time_string(True)}: {generic_info}")

def print_validity_buffer(self, validity_buffer: bytes, num_vars: int):
printout = FsfwTmTcPrinter.get_validity_buffer(validity_buffer, num_vars)
printout = FsfwTmTcPrinter.get_validity_buffer_str(validity_buffer, num_vars)
print(printout)
if self.file_logger:
self.file_logger.info(printout)

@staticmethod
def get_validity_buffer(validity_buffer: bytes, num_vars: int) -> str:
def get_validity_buffer_str(validity_buffer: bytes, num_vars: int) -> str:
"""
:param validity_buffer: Validity buffer in bytes format
:param num_vars: Number of variables
:return:
"""
valid_list = []
counter = 0
for index, byte in enumerate(validity_buffer):
for bit in range(1, 9):
if FsfwTmTcPrinter.bit_extractor(byte, bit) == 1:
valid_list.append(True)
else:
valid_list.append(False)
counter += 1
if counter == num_vars:
break
validity_lists = list(FsfwTmTcPrinter.chunks(n=16, lst=valid_list))
for valid_list in validity_lists:
printout = "Valid: ["
for idx, valid in enumerate(valid_list):
if valid:
printout += "Y"
else:
printout += "N"
if idx < len(valid_list) - 1:
printout += ","
else:
printout += "]"
return printout
return ""
return get_validity_buffer_str(validity_buffer, num_vars)

@staticmethod
def generic_action_packet_tm_print(
Expand Down

0 comments on commit 09a99d0

Please sign in to comment.