Skip to content

Commit fb887cf

Browse files
committed
Fix disable logic in TLM submit and default submit_tlm in config
This fixes the logic in the telemetry submitter block that is used to avoid sending any telemetry when the callsign or location is not set. The issue with the current approach is that the comparison was done after the latitude and longitude were converted to strings, so the comparison was wrong. This also fixes the default value for submit_tlm in the config file. The default values should be 'no'. Additionally, configparser.ConfigParser.BOOLEAN_STATES is used to parse the GR_SATELLITE_SUBMIT_TLM env variable instead of bool(int(.)), since bool(int(.)) has corner cases such as translating '-1' to True.
1 parent 45b146f commit fb887cf

3 files changed

Lines changed: 26 additions & 22 deletions

File tree

python/core/gr_satellites_flowgraph.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#
1010

1111
import argparse
12+
import configparser
1213
import functools
1314
import itertools
1415
import os
@@ -214,7 +215,9 @@ def _init_additional_datasinks(self):
214215
# submission
215216
tlm_env = os.environ.get('GR_SATELLITES_SUBMIT_TLM')
216217
if tlm_env is not None:
217-
tlm_submit = bool(int(tlm_env))
218+
# BOOLEAN_STATES can convert a few common strings, such as '0',
219+
# '1', 'true', 'on', 'false', 'off', to bool.
220+
tlm_submit = configparser.ConfigParser.BOOLEAN_STATES[tlm_env]
218221
else:
219222
tlm_submit = self.config.getboolean('Groundstation', 'submit_tlm')
220223
if tlm_submit:

python/submit.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from gnuradio import gr
1818
import pmt
19-
import numpy
2019

2120

2221
def parse_timestamp(s):
@@ -78,31 +77,33 @@ def __init__(self, url, noradID, source,
7877
in_sig=[],
7978
out_sig=[])
8079

81-
self.url = url
82-
self.request = {
83-
'noradID': noradID,
84-
'source': source,
85-
'locator': 'longLat',
86-
'longitude': str(
87-
abs(longitude)) + ('E' if longitude >= 0 else 'W'),
88-
'latitude': str(
89-
abs(latitude)) + ('N' if latitude >= 0 else 'S'),
90-
'version': '1.6.6',
80+
# Do not do anything if source is not entered or if the location is (0,
81+
# 0).
82+
self.disabled = not source or (longitude == 0 and latitude == 0)
83+
84+
if not self.disabled:
85+
self.url = url
86+
self.request = {
87+
'noradID': noradID,
88+
'source': source,
89+
'locator': 'longLat',
90+
'longitude': str(
91+
abs(longitude)) + ('E' if longitude >= 0 else 'W'),
92+
'latitude': str(
93+
abs(latitude)) + ('N' if latitude >= 0 else 'S'),
94+
'version': '1.6.6',
9195
}
92-
self.initialTimestamp = (
93-
parse_timestamp(initialTimestamp)
94-
if initialTimestamp != '' else None)
95-
self.startTimestamp = datetime.datetime.now(tz=datetime.timezone.utc)
96+
self.initialTimestamp = (
97+
parse_timestamp(initialTimestamp)
98+
if initialTimestamp != '' else None)
99+
self.startTimestamp = datetime.datetime.now(
100+
tz=datetime.timezone.utc)
96101

97102
self.message_port_register_in(pmt.intern('in'))
98103
self.set_msg_handler(pmt.intern('in'), self.handle_msg)
99104

100105
def handle_msg(self, msg_pmt):
101-
# Check that callsign and QTH have been entered
102-
if self.request['source'] == '':
103-
return
104-
if (self.request['longitude'] == 0.0
105-
and self.request['latitude'] == 0.0):
106+
if self.disabled:
106107
return
107108

108109
msg = pmt.cdr(msg_pmt)

python/utils/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def write_default_config(file):
4545
'callsign': '',
4646
'latitude': 0,
4747
'longitude': 0,
48-
'submit_tlm': 'yes',
48+
'submit_tlm': 'no',
4949
}
5050

5151
config['FUNcube'] = {

0 commit comments

Comments
 (0)