From 55ba411db8e8e04e7294a55bddc0af9cd9104a97 Mon Sep 17 00:00:00 2001 From: sparky8512 <76499194+sparky8512@users.noreply.github.com> Date: Sun, 7 Mar 2021 09:22:52 -0800 Subject: [PATCH] Go back to using message number for alert bits SpaceX has been using inconsistent field ordering when adding alerts, so field index cannot be used to consistently identify the specific alerts. Message number is more appropriate for that, anyway, but is not guaranteed to be a low enough number to fit into a bit field. Oh well, in the unlikely event that SpaceX switches to larger message numbers, they just won't show up in the alerts bit field (but will still show up in alert_detail). This does make the bit ordering in alerts inconsistent with prior versions of these tools, but I've never actually seen one of these alerts report true, so hopefully this doesn't impact anyone. The alerts are still sorted by index number in the alert_detail text output, which is a problem for CSV output, but I think ordering by message number instead would be pointlessly complex. alert_detail is not a great fit for CSV output anyway, due to its variable length, so just added a warning about that in the text script module doc. --- dish_grpc_text.py | 5 +++++ starlink_grpc.py | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dish_grpc_text.py b/dish_grpc_text.py index 77f6923..06fe99e 100644 --- a/dish_grpc_text.py +++ b/dish_grpc_text.py @@ -4,6 +4,11 @@ This script pulls the current status info and/or metrics computed from the history data and prints them to stdout either once or in a periodic loop. By default, it will print the results in CSV format. + +Note that using this script to record the alert_detail group mode as CSV +data is not recommended, because the number of alerts and their relative +order in the output can change with the dish software. Instead of using +the alert_detail mode, you can use the alerts bitmask in the status group. """ from datetime import datetime diff --git a/starlink_grpc.py b/starlink_grpc.py index 921c2f8..b7c02f2 100644 --- a/starlink_grpc.py +++ b/starlink_grpc.py @@ -107,14 +107,16 @@ their nature, but the field names are pretty self-explanatory. : **alert_motors_stuck** : Alert corresponding with bit 0 (bit mask 1) in *alerts*. -: **alert_thermal_throttle** : Alert corresponding with bit 1 (bit mask 2) in +: **alert_thermal_shutdown** : Alert corresponding with bit 1 (bit mask 2) in *alerts*. -: **alert_thermal_shutdown** : Alert corresponding with bit 2 (bit mask 4) in +: **alert_thermal_throttle** : Alert corresponding with bit 2 (bit mask 4) in *alerts*. : **alert_unexpected_location** : Alert corresponding with bit 3 (bit mask 8) in *alerts*. : **alert_mast_not_near_vertical** : Alert corresponding with bit 4 (bit mask 16) in *alerts*. +: **slow_ethernet_speeds** : Alert corresponding with bit 5 (bit mask 32) in + *alerts*. General history data -------------------- @@ -555,7 +557,8 @@ def status_data(context=None): for field in status.alerts.DESCRIPTOR.fields: value = getattr(status.alerts, field.name) alerts["alert_" + field.name] = value - alert_bits |= (1 if value else 0) << (field.index) + if field.number < 65: + alert_bits |= (1 if value else 0) << (field.number - 1) return { "id": status.device_info.id,