kopia lustrzana https://github.com/projecthorus/horusdemodlib
Fun with namespaces and imports.
rodzic
71aa870d16
commit
9de63dcd67
|
@ -1 +1 @@
|
|||
__version__ = "0.1.11"
|
||||
__version__ = "0.1.14"
|
||||
|
|
|
@ -7,8 +7,8 @@ import struct
|
|||
import time
|
||||
from .delegates import *
|
||||
from .checksums import *
|
||||
from .payloads import HORUS_CUSTOM_FIELDS, HORUS_PAYLOAD_LIST, init_custom_field_list, init_payload_id_list
|
||||
|
||||
from .payloads import init_custom_field_list, init_payload_id_list
|
||||
import horusdemodlib.payloads
|
||||
|
||||
|
||||
#
|
||||
|
@ -135,7 +135,7 @@ def decode_packet(data:bytes, packet_format:dict = None) -> dict:
|
|||
if _field_name == 'custom':
|
||||
# Attempt to interpret custom fields.
|
||||
# Note: This requires that the payload ID has been decoded prior to this field being parsed.
|
||||
if _output['payload_id'] in HORUS_CUSTOM_FIELDS:
|
||||
if _output['payload_id'] in horusdemodlib.payloads.HORUS_CUSTOM_FIELDS:
|
||||
(_custom_data, _custom_str) = decode_custom_fields(_field_data, _output['payload_id'])
|
||||
|
||||
# Add custom fields to string
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import struct
|
||||
import time
|
||||
|
||||
from .payloads import HORUS_PAYLOAD_LIST, HORUS_CUSTOM_FIELDS
|
||||
import horusdemodlib.payloads
|
||||
|
||||
# Payload ID
|
||||
|
||||
|
@ -17,8 +17,8 @@ def decode_payload_id(data: int) -> str:
|
|||
if type(data) != int:
|
||||
return ValueError("payload_id - Invalid input type.")
|
||||
|
||||
if data in HORUS_PAYLOAD_LIST:
|
||||
_str = HORUS_PAYLOAD_LIST[data]
|
||||
if data in horusdemodlib.payloads.HORUS_PAYLOAD_LIST:
|
||||
_str = horusdemodlib.payloads.HORUS_PAYLOAD_LIST[data]
|
||||
else:
|
||||
_str = "UNKNOWN_PAYLOAD_ID"
|
||||
|
||||
|
@ -155,10 +155,10 @@ def decode_field(field_type:str, data):
|
|||
def decode_custom_fields(data:bytes, payload_id:str):
|
||||
""" Attempt to decode custom field data from the 9-byte custom section of a 32-byte payload """
|
||||
|
||||
if payload_id not in HORUS_CUSTOM_FIELDS:
|
||||
if payload_id not in horusdemodlib.payloads.HORUS_CUSTOM_FIELDS:
|
||||
raise ValueError(f"Custom Field Decoder - Unknown payload ID {payload_id}")
|
||||
|
||||
_custom_field = HORUS_CUSTOM_FIELDS[payload_id]
|
||||
_custom_field = horusdemodlib.payloads.HORUS_CUSTOM_FIELDS[payload_id]
|
||||
_struct = _custom_field['struct']
|
||||
_struct_len = struct.calcsize(_struct)
|
||||
_field_names = _custom_field['fields']
|
||||
|
@ -213,6 +213,7 @@ if __name__ == "__main__":
|
|||
['battery_5v_byte', 0, "0.00"],
|
||||
['battery_5v_byte', 128, "2.51"],
|
||||
['battery_5v_byte', 255, "5.00"],
|
||||
['payload_id', 0, '4FSKTEST']
|
||||
]
|
||||
|
||||
for _test in tests:
|
||||
|
|
|
@ -274,6 +274,13 @@ def init_custom_field_list(filename="custom_field_list.json"):
|
|||
HORUS_CUSTOM_FIELDS = read_custom_field_list(filename=filename)
|
||||
|
||||
|
||||
def update_payload_lists(payload_list, custom_field_list):
|
||||
""" Helper function to get updated lists into the right namespace """
|
||||
global HORUS_PAYLOAD_LIST, HORUS_CUSTOM_FIELDS
|
||||
HORUS_PAYLOAD_LIST = payload_list
|
||||
HORUS_CUSTOM_FIELDS = custom_field_list
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Setup Logging
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "horusdemodlib"
|
||||
version = "0.1.11"
|
||||
version = "0.1.14"
|
||||
description = "Project Horus HAB Telemetry Demodulators"
|
||||
authors = ["Mark Jessop"]
|
||||
license = "LGPL-2.1-or-later"
|
||||
|
|
Ładowanie…
Reference in New Issue