Catch GrpcError in new example

Apparently, it was a little _too_ simple.

Also, update the description for seconds_to_first_nonempty_slot field to reflect some behavior this script was able to capture.
This commit is contained in:
sparky8512 2021-02-02 09:07:42 -08:00
parent f5f1bbdb84
commit ed2ef50581
2 changed files with 38 additions and 29 deletions

View file

@ -25,6 +25,7 @@ def run_loop(context):
counter = None counter = None
prev_triggered = False prev_triggered = False
while True: while True:
try:
# `starlink_grpc.status_data` returns a tuple of 3 dicts, but in case # `starlink_grpc.status_data` returns a tuple of 3 dicts, but in case
# the API changes to add more in the future, it's best to reference # the API changes to add more in the future, it's best to reference
# them by index instead of direct assignment from the function call. # them by index instead of direct assignment from the function call.
@ -34,7 +35,11 @@ def run_loop(context):
# On the other hand, `starlink_grpc.history_bulk_data` will always # On the other hand, `starlink_grpc.history_bulk_data` will always
# return 2 dicts, because that's all the data there is. # return 2 dicts, because that's all the data there is.
general, bulk = starlink_grpc.history_bulk_data(samples, start=counter, context=context) general, bulk = starlink_grpc.history_bulk_data(samples, start=counter, context=context)
except starlink_grpc.GrpcError:
# Dish rebooting maybe, or LAN connectivity error. Just ignore it
# and hope it goes away.
pass
else:
# The following is what actually does stuff with the data. It should # The following is what actually does stuff with the data. It should
# be replaced with something more useful. # be replaced with something more useful.
@ -45,7 +50,8 @@ def run_loop(context):
# This computes a trigger detecting samples not marked as scheduled: # This computes a trigger detecting samples not marked as scheduled:
triggered = not all(bulk["scheduled"]) triggered = not all(bulk["scheduled"])
if triggered or prev_triggered: if triggered or prev_triggered:
print("Triggered" if triggered else "Continued", "at:", datetime.now(tz=timezone.utc)) print("Triggered" if triggered else "Continued", "at:",
datetime.now(tz=timezone.utc))
print("status:", status) print("status:", status)
print("history:", bulk) print("history:", bulk)
if not triggered: if not triggered:

View file

@ -39,7 +39,10 @@ This group holds information about the current state of the user terminal.
: **snr** : Most recent sample value. See bulk history data for detail. : **snr** : Most recent sample value. See bulk history data for detail.
: **seconds_to_first_nonempty_slot** : Amount of time from now, in seconds, : **seconds_to_first_nonempty_slot** : Amount of time from now, in seconds,
until a satellite will be scheduled to be available for transmit/receive. until a satellite will be scheduled to be available for transmit/receive.
See also *scheduled* in the bulk history data. See also *scheduled* in the bulk history data. May report as a negative
number, which appears to indicate unknown time until next satellite
scheduled and usually correlates with *state* reporting as other than
"CONNECTED".
: **pop_ping_drop_rate** : Most recent sample value. See bulk history data for : **pop_ping_drop_rate** : Most recent sample value. See bulk history data for
detail. detail.
: **downlink_throughput_bps** : Most recent sample value. See bulk history : **downlink_throughput_bps** : Most recent sample value. See bulk history