Skip to content

Commit

Permalink
Minor fix, added radiosonde support
Browse files Browse the repository at this point in the history
* Implemented workaround for faulty M10 serial decoding in recent versions of sondemod
* Added support for the Graw Pilotsonde PS-15
  • Loading branch information
Eshco93 authored Oct 1, 2023
1 parent 7cb98f0 commit 45c329b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 20 deletions.
26 changes: 19 additions & 7 deletions SondeHubUploader/handleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,20 @@ def reformat_telemetry(self, unified_telemetry):
# Second, mandatory radiosonde-specific reformatted telemetry parameters are added
# Go through all possible radiosonde types
for name in self.shuConfig.radiosonde:
# The radiosonde type is compared
if unified_telemetry['type'].startswith(name):
# The radiosonde type/subtype is compared in order to find a match
if unified_telemetry['type'] == name or\
(self.shuConfig.radiosonde[name]['subtype'] is not None and unified_telemetry['type'] in self.shuConfig.radiosonde[name]['subtype']):
# manufacturer and type can be transferred directly
reformatted_telemetry['manufacturer'] = self.shuConfig.radiosonde[name]['manufacturer']
reformatted_telemetry['type'] = self.shuConfig.radiosonde[name]['type']
# A subtype might be present for some radiosondes
if self.shuConfig.radiosonde[name]['subtype'] is not None and unified_telemetry['type'] in self.shuConfig.radiosonde[name]['subtype']:
# Check whether the provided type matches the type
if unified_telemetry['type'] == self.shuConfig.radiosonde[name]['type']:
# In that case, this is the only type available (no subtype)
reformatted_telemetry['type'] = unified_telemetry['type']
# In any other case the provided type matches the subtype
else:
# In that case, the subtype is set accordingly and the type is taken from the radiosonde table
reformatted_telemetry['subtype'] = unified_telemetry['type']
reformatted_telemetry['type'] = self.shuConfig.radiosonde[name]['type']
# For IMET radiosondes a unique serial must be calculated (based on the convention of SondeHub)
if self.shuConfig.radiosonde[name]['serial'] == 'IMET':
# The date provided by the radiosonde is used (if it is available)
Expand All @@ -337,9 +343,15 @@ def reformat_telemetry(self, unified_telemetry):
# For all other radiosondes, the serial can be transferred directly
else:
serial = unified_telemetry[self.shuConfig.radiosonde[name]['serial'][0]][self.shuConfig.radiosonde[name]['serial'][1]:]
# For M10 radiosondes, the serial provided by dxlAPRS is missing some dashes
# For M10 radiosondes, the serial provided by dxlAPRS might be faulty in recent versions of sondemod
# Therefore the serial is calculated based on the APRS serial that dxlAPRS provides
# This provides a workaround for the bug in recent versions of sondemod
# A special thank you goes to Vigor G. from France, who helped implementing this workaround
if reformatted_telemetry['type'] == 'M10':
reformatted_telemetry['serial'] = serial[0:3] + '-' + serial[3] + '-' + serial[4:]
rs_serial = 0
for i in range(4):
rs_serial += int(serial[5 + i], 16) * 16 ** (3 - i)
reformatted_telemetry['serial'] = serial[2] + '{:02d}'.format(int(serial[3], 16)) + '-' + serial[4] + '-' + '{:1d}'.format(rs_serial >> 13) + '{:04d}'.format(rs_serial & 0x1FFF)
# For M20 radiosondes, the serial might have some sort of number in square brackets attached
# This needs to me removed
elif reformatted_telemetry['type'] == 'M20':
Expand Down
12 changes: 6 additions & 6 deletions SondeHubUploader/shuConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# Software definitions
software_name = 'dxlAPRS-SHUE'
software_version = '1.1.1'
software_version = '1.1.2'

# Status code definitions
status_code_ok = 200
Expand Down Expand Up @@ -369,7 +369,7 @@
'json_conversion_function': lambda a, b: handleData.unify_json_type(a, b),
'aprs_source': 'type',
'aprs_conversion_function': lambda a: a,
'plausibility_function': lambda a: True if a.startswith(tuple(radiosonde.keys())) else False,
'plausibility_function': lambda a: telemetryChecks.check_type_plausibility(a, radiosonde),
'name': 'Type',
'unit': None,
'mandatory': True,
Expand All @@ -385,7 +385,7 @@
'plausibility_function': lambda a: True if len(a) >= 4 else False,
'name': 'Serial',
'unit': None,
'mandatory': ['RS41', 'RS92', 'DFM'],
'mandatory': ['RS41', 'RS92', 'DFM', 'M10'],
'optional': False,
'reformat_function': None
},
Expand All @@ -398,7 +398,7 @@
'plausibility_function': lambda a: True if len(a) >= 4 else False,
'name': 'Serial2',
'unit': None,
'mandatory': ['M10', 'M20', 'MRZ', 'MEISEI'],
'mandatory': ['M20', 'MRZ', 'MEISEI'],
'optional': False,
'reformat_function': None
},
Expand Down Expand Up @@ -966,7 +966,7 @@
{
'manufacturer': 'Graw',
'type': 'DFM',
'subtype': ['DFM06', 'DFM09', 'DFM09P', 'DFM17'],
'subtype': ['DFM06', 'DFM09', 'DFM09P', 'DFM17', 'PS-15'],
'serial': ['serial', 1],
'framenumber': 'gps',
'altitude_precision': 2,
Expand All @@ -993,7 +993,7 @@
'manufacturer': 'Meteomodem',
'type': 'M10',
'subtype': None,
'serial': ['serial_2', 0],
'serial': ['serial', 0],
'framenumber': 'gps',
'altitude_precision': 2,
'radiosonde_time_reference': 'GPS',
Expand Down
22 changes: 17 additions & 5 deletions SondeHubUploader/telemetryChecks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ def check_callsign_plausibility(callsign):
return False


# Check whether the type is plausible
def check_type_plausibility(_type, radiosonde):
# Go through all possible radiosondes in order to check the type plausibility
for name in radiosonde:
# The provided type must either match a radiosonde name or subtype
if _type == name or (radiosonde[name]['subtype'] is not None and _type in radiosonde[name]['subtype']):
return True
return False


# Check whether a date is plausible
def check_date_plausibility(date, difference_days):
# The date must be within a certain range around the current UTC date in order to be deemed plausible
Expand Down Expand Up @@ -115,13 +125,15 @@ def check_mandatory(self, unified_telemetry):
self.loggerObj.debug_detail(f'Mandatory parameter "{parameter}" exists')
else:
result = False
self.loggerObj.debug_detail(f'Mandatory parameter "{parameter}" is missing')
self.loggerObj.error(f'Mandatory parameter "{parameter}" is missing')
# The radiosonde type needs to be determined in order to check the mandatory unified telemetry parameters for specific radiosondes
_type = None
# Go through all possible radiosonde types and compare the type
for key in self.shuConfig.radiosonde.keys():
if 'type' in unified_telemetry and unified_telemetry['type'].startswith(key):
_type = key
# Go through all possible radiosondes in order to determine the type
for name in self.shuConfig.radiosonde:
# The radiosonde type/subtype is compared in order to find a match
if ('type' in unified_telemetry and unified_telemetry['type'] == name) or\
(self.shuConfig.radiosonde[name]['subtype'] is not None and 'type' in unified_telemetry and unified_telemetry['type'] in self.shuConfig.radiosonde[name]['subtype']):
_type = name
if _type is not None:
# Go through all possible unified telemetry parameters (again)
for parameter in self.shuConfig.telemetry:
Expand Down
5 changes: 3 additions & 2 deletions SondeHubUploader/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ def process_input_queue(self):
self.writeData.write_reformatted_telemetry(self, reformatted_telemetry)
# Go through all possible radiosonde types
for name in self.shuConfig.radiosonde:
# The radiosonde type is compared
if unified_telemetry['type'].startswith(name):
# The radiosonde type/subtype is compared in order to find a match
if unified_telemetry['type'] == name or\
(self.shuConfig.radiosonde[name]['subtype'] is not None and unified_telemetry['type'] in self.shuConfig.radiosonde[name]['subtype']):
# Check whether uploading for this radiosonde is enabled
if self.shuConfig.radiosonde[name]['enabled']:
self.loggerObj.debug('Uploading for radiosonde type %s is enabled', name)
Expand Down

0 comments on commit 45c329b

Please sign in to comment.