Add a few new IDs, use 4FSKTEST-V2 custom fields by default

pull/63/head
Mark Jessop 2022-02-20 18:50:37 +10:30
rodzic fa8a0094ec
commit 3cef0956af
6 zmienionych plików z 66 dodań i 26 usunięć

Wyświetl plik

@ -19,13 +19,13 @@
]
},
"4FSKTEST-V2": {
"struct": "<BfBBH",
"comment": "Default custom fields for RS41ng",
"struct": "<hhBHxx",
"fields": [
["test_field 1", "none"],
["test_field 2", "none"],
["test_field 3", "battery_5v_byte"],
["test_field 4", "divide_by_10"],
["test_field 5", "divide_by_100"]
["ascent_rate", "divide_by_100"],
["ext_temperature", "divide_by_10"],
["ext_humidity", "none"],
["ext_pressure", "divide_by_10"]
]
},
"MAGNU-V2": {
@ -46,5 +46,14 @@
["ext_humidity", "none"],
["ext_pressure", "divide_by_10"]
]
},
"VK5BRL-V2": {
"struct": "<hhBHxx",
"fields": [
["ascent_rate", "divide_by_100"],
["ext_temperature", "divide_by_10"],
["ext_humidity", "none"],
["ext_pressure", "divide_by_10"]
]
}
}

Wyświetl plik

@ -1 +1 @@
__version__ = "0.3.2"
__version__ = "0.3.3"

Wyświetl plik

@ -50,6 +50,27 @@ def check_packet_crc(data:bytes, checksum:str='crc16'):
raise ValueError(f"Checksum - Unknown Checksym type {checksum}.")
def add_packet_crc(data:bytes, checksum:str='crc16'):
"""
Add a CRC onto the end of provided bytes
Support CRC types: CRC16-CCITT
"""
if (checksum == 'crc16') or (checksum == 'CRC16') or (checksum == 'crc16-ccitt') or (checksum == 'CRC16-CCITT'):
# Calculate a CRC over the data
_crc16 = crcmod.predefined.mkCrcFun('crc-ccitt-false')
_calculated_crc = _crc16(data)
_packet_crc = struct.pack('<H', _calculated_crc)
return data + _packet_crc
else:
raise ValueError(f"Checksum - Unknown Checksym type {checksum}.")
if __name__ == "__main__":

Wyświetl plik

@ -138,15 +138,25 @@ def decode_packet(data:bytes, packet_format:dict = None, ignore_crc:bool = False
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 horusdemodlib.payloads.HORUS_CUSTOM_FIELDS:
(_custom_data, _custom_str) = decode_custom_fields(_field_data, _output['payload_id'])
# If this payload has a specific custom field description, use that.
_custom_field_name = _output['payload_id']
else:
# Otherwise use the default from 4FSKTEST-V2, which matches
# the default fields from RS41ng
_custom_field_name = '4FSKTEST-V2'
(_custom_data, _custom_str) = decode_custom_fields(_field_data, _custom_field_name)
# Add custom fields to string
_ukhas_fields.append(_custom_str)
# Add custom fields to output dict.
for _field in _custom_data:
_output[_field] = _custom_data[_field]
# Add custom fields to string
_ukhas_fields.append(_custom_str)
# Add custom fields to output dict.
for _field in _custom_data:
_output[_field] = _custom_data[_field]
# Ignore checksum field. (and maybe other fields?)
elif _field_name not in ['checksum']:
@ -314,7 +324,9 @@ if __name__ == "__main__":
['horus_binary_v1', b'\x01\x12\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x1C\x9A\x95\x45', 'error'],
['horus_binary_v2_16byte', b'\x01\x12\x02\x00\x02\xbc\xeb!AR\x10\x00\xff\x00\xe1\x7e', ''],
# id seq_no HH MM SS lat lon alt spd sat tmp bat custom data -----------------------| crc16
['horus_binary_v2_32byte', b'\x00\x01\x02\x00\x0C\x22\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\xB4\xC6', '']
['horus_binary_v2_32byte', b'\x00\x01\x02\x00\x0C\x22\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\xB4\xC6', ''],
# id seq_no HH MM SS lat lon alt spd sat tmp bat custom data -----------------------| crc16
['horus_binary_v2_32byte_noident', b'\xff\xff\x02\x00\x0C\x22\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x17\x1c', '']
]
for _test in tests:

Wyświetl plik

@ -7,7 +7,7 @@ import requests
import struct
# Global payload list - Basic version
HORUS_PAYLOAD_LIST = {0:'4FSKTEST', 1:'HORUSBINARY', 257:'4FSKTEST32', 65535:'HORUSTEST'}
HORUS_PAYLOAD_LIST = {0:'4FSKTEST', 1:'HORUSBINARY', 256: '4FSKTEST-V2'}
# URL for payload list
PAYLOAD_ID_LIST_URL = "https://raw.githubusercontent.com/projecthorus/horusdemodlib/master/payload_id_list.txt"
@ -35,18 +35,13 @@ HORUS_CUSTOM_FIELDS = {
]
},
"4FSKTEST-V2": {
"struct": "<BBBBBBBBB",
"struct": "<hhBHxx",
"fields": [
["test_field 1", "none"],
["test_field 2", "none"],
["test_field 3", "none"],
["test_field 4", "none"],
["test_field 5", "none"],
["test_field 6", "none"],
["test_field 7", "none"],
["test_field 8", "none"],
["test_field 9", "none"],
]
["ascent_rate", "divide_by_100"],
["ext_temperature", "divide_by_10"],
["ext_humidity", "none"],
["ext_pressure", "divide_by_10"]
]
}
}

Wyświetl plik

@ -107,6 +107,7 @@
97, SQ1FYB-4FSK
98, W3YP
99, KN6SPE
100, SQ3MP-4FSK
# IDs for 32-byte payloads
256, 4FSKTEST-V2
257, OH3VHH-4FSK-V2
@ -115,4 +116,6 @@
260, Peanut127-V2
261, 9A3ZI-V2
262, SQ1FYB-V2
263, SQ3MP-V2
264, VK5BRL-V2
31415, HORUS-V2