Skip to content

Commit

Permalink
prepare patch
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed May 8, 2024
1 parent 14d9acd commit f4fab80
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Starting from v4.0.0, this project adheres to [Semantic Versioning](http://semve

# [unreleased]

# [v8.0.1] 2024-05-08

## Fixed

- PUS TC 20 (Parameters) FSFW interface: Default values for APID.

# [v8.0.0] 2024-05-05

## Changed
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.0"
version = "8.0.1"
requires-python = ">=3.8"
license = {text = "Apache-2.0 or MIT" }
authors = [
Expand Down
11 changes: 7 additions & 4 deletions tests/tc/test_srv20.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
from unittest import TestCase

from spacepackets.ecss import PusTelecommand, PusService
from spacepackets.ecss import PfcUnsigned, Ptc, PusTc, PusService
from tmtccmd.pus.s20_fsfw_param_defs import Parameter, CustomSubservice
from tmtccmd.pus.s20_fsfw_param import (
create_load_param_cmd,
create_scalar_boolean_parameter,
)


class TestSrv20Tc(TestCase):
class TestSrv20FsfwTc(TestCase):
def setUp(self):
self.obj_id = bytes([0x01, 0x02, 0x03, 0x04])
self.boolean_param = create_scalar_boolean_parameter(
object_id=self.obj_id, domain_id=1, unique_id=5, parameter=True
)
self.tc = create_load_param_cmd(0x05, self.boolean_param)
self.assertEqual(self.boolean_param.ptc, Ptc.UNSIGNED)
self.assertEqual(self.boolean_param.pfc, PfcUnsigned.ONE_BYTE)
self.tc = create_load_param_cmd(self.boolean_param, 0x05)

def test_basic(self):
# 12 bytes of generic parameter header + 1 byte parameter itself
self.assertEqual(len(self.tc.app_data), 13)
self.assertEqual(self.tc.apid, 0x05)
self.assertEqual(self.tc.service, PusService.S20_PARAMETER)
self.assertEqual(self.tc.subservice, CustomSubservice.TC_LOAD)

def test_unpack(self):
raw_tc = self.tc.pack()
unpacked = PusTelecommand.unpack(raw_tc)
unpacked = PusTc.unpack(raw_tc)
boolean_param_conv_back = Parameter.unpack(unpacked.app_data)
self.assertEqual(boolean_param_conv_back, self.boolean_param)
14 changes: 6 additions & 8 deletions tmtccmd/pus/s20_fsfw_param_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import dataclasses
import enum
import struct
from typing import Optional, Union, Sequence
from typing import Union, Sequence

from spacepackets.ecss import Ptc, PfcUnsigned, PfcSigned, PfcReal

Expand Down Expand Up @@ -67,7 +67,7 @@ class FsfwParamId:

object_id: bytes
param_id: ParameterId
ptc: Optional[Ptc]
ptc: Ptc
pfc: int
rows: int
columns: int
Expand Down Expand Up @@ -135,7 +135,7 @@ def empty(cls):
fsfw_param_id=FsfwParamId(
object_id=bytes([0, 0, 0, 0]),
param_id=ParameterId.empty(),
ptc=None,
ptc=Ptc.DEDUCED,
pfc=0,
rows=0,
columns=0,
Expand Down Expand Up @@ -247,11 +247,9 @@ def deserialize_scalar_entry(
if param_len < 8:
raise ValueError(f"{__BASE_LEN_ERR} 8")
return struct.unpack("!d", param_data[0:8])[0]
else:
raise NotImplementedError(
f"Parsing of real (floating point) PTC {ptc} not implemented "
f"for PFC {pfc}"
)
raise NotImplementedError(

Check warning on line 250 in tmtccmd/pus/s20_fsfw_param_defs.py

View check run for this annotation

Codecov / codecov/patch

tmtccmd/pus/s20_fsfw_param_defs.py#L250

Added line #L250 was not covered by tests
f"Parsing of real (floating point) PTC {ptc} not implemented " f"for PFC {pfc}"
)


def create_scalar_boolean_parameter(
Expand Down
8 changes: 5 additions & 3 deletions tmtccmd/pus/tc/s20_fsfw_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)


def create_load_param_cmd(apid: int, parameter: Parameter) -> PusTelecommand:
def create_load_param_cmd(parameter: Parameter, apid: int = 0) -> PusTelecommand:
return PusTelecommand(
apid=apid,
service=PusService.S20_PARAMETER,
Expand All @@ -40,7 +40,7 @@ def create_load_param_cmd(apid: int, parameter: Parameter) -> PusTelecommand:
)


def create_dump_param_cmd(apid: int, param_fsfw_id: FsfwParamId) -> PusTelecommand:
def create_dump_param_cmd(param_fsfw_id: FsfwParamId, apid: int = 0) -> PusTelecommand:
return PusTelecommand(
apid=apid,
service=PusService.S20_PARAMETER,
Expand All @@ -49,7 +49,9 @@ def create_dump_param_cmd(apid: int, param_fsfw_id: FsfwParamId) -> PusTelecomma
)


def create_load_param_cmd_from_raw(apid: int, parameter_raw: bytes) -> PusTelecommand:
def create_load_param_cmd_from_raw(
parameter_raw: bytes, apid: int = 0
) -> PusTelecommand:
return PusTelecommand(
apid=apid,
service=PusService.S20_PARAMETER,
Expand Down

0 comments on commit f4fab80

Please sign in to comment.