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:
parent
f5f1bbdb84
commit
ed2ef50581
2 changed files with 38 additions and 29 deletions
|
@ -25,37 +25,43 @@ def run_loop(context):
|
|||
counter = None
|
||||
prev_triggered = False
|
||||
while True:
|
||||
# `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
|
||||
# them by index instead of direct assignment from the function call.
|
||||
groups = starlink_grpc.status_data(context=context)
|
||||
status = groups[0]
|
||||
try:
|
||||
# `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
|
||||
# them by index instead of direct assignment from the function call.
|
||||
groups = starlink_grpc.status_data(context=context)
|
||||
status = groups[0]
|
||||
|
||||
# On the other hand, `starlink_grpc.history_bulk_data` will always
|
||||
# return 2 dicts, because that's all the data there is.
|
||||
general, bulk = starlink_grpc.history_bulk_data(samples, start=counter, context=context)
|
||||
# On the other hand, `starlink_grpc.history_bulk_data` will always
|
||||
# return 2 dicts, because that's all the data there is.
|
||||
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
|
||||
# be replaced with something more useful.
|
||||
|
||||
# The following is what actually does stuff with the data. It should
|
||||
# be replaced with something more useful.
|
||||
# This computes a trigger detecting any packet loss (ping drop):
|
||||
#triggered = any(x > 0 for x in bulk["pop_ping_drop_rate"])
|
||||
# This computes a trigger detecting samples marked as obstructed:
|
||||
#triggered = any(bulk["obstructed"])
|
||||
# This computes a trigger detecting samples not marked as scheduled:
|
||||
triggered = not all(bulk["scheduled"])
|
||||
if triggered or prev_triggered:
|
||||
print("Triggered" if triggered else "Continued", "at:",
|
||||
datetime.now(tz=timezone.utc))
|
||||
print("status:", status)
|
||||
print("history:", bulk)
|
||||
if not triggered:
|
||||
print()
|
||||
|
||||
# This computes a trigger detecting any packet loss (ping drop):
|
||||
#triggered = any(x > 0 for x in bulk["pop_ping_drop_rate"])
|
||||
# This computes a trigger detecting samples marked as obstructed:
|
||||
#triggered = any(bulk["obstructed"])
|
||||
# This computes a trigger detecting samples not marked as scheduled:
|
||||
triggered = not all(bulk["scheduled"])
|
||||
if triggered or prev_triggered:
|
||||
print("Triggered" if triggered else "Continued", "at:", datetime.now(tz=timezone.utc))
|
||||
print("status:", status)
|
||||
print("history:", bulk)
|
||||
if not triggered:
|
||||
print()
|
||||
|
||||
prev_triggered = triggered
|
||||
# The following makes the next loop only pull the history samples that
|
||||
# are newer than the ones already examined.
|
||||
samples = -1
|
||||
counter = general["end_counter"]
|
||||
prev_triggered = triggered
|
||||
# The following makes the next loop only pull the history samples that
|
||||
# are newer than the ones already examined.
|
||||
samples = -1
|
||||
counter = general["end_counter"]
|
||||
|
||||
# And this is a not-very-robust way of implementing an interval loop.
|
||||
# Note that a 4 second loop will poll the history buffer pretty
|
||||
|
|
|
@ -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.
|
||||
: **seconds_to_first_nonempty_slot** : Amount of time from now, in seconds,
|
||||
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
|
||||
detail.
|
||||
: **downlink_throughput_bps** : Most recent sample value. See bulk history
|
||||
|
|
Loading…
Reference in a new issue