starlink-grpc-tools/dump_dish_status.py
sparky8512 f5f1bbdb84 Clean up the simple example script and add new one
This adds an example script for the starlink_grpc module. It's a kinda silly thing, but I threw it together to better understand some of the status data, so I figured I'd upload it, since the other example is for direct grpc usage (or for starlink_json if parseJsonHistory can be considered an example).

Rename dishDumpStatus so pylint will stop complaining about the module name. The only script left with my old naming convention now is parseJsonHistory.py.
2021-02-01 20:47:18 -08:00

23 lines
821 B
Python

#!/usr/bin/python3
"""Simple example of get_status request use grpc call directly."""
import grpc
import spacex.api.device.device_pb2
import spacex.api.device.device_pb2_grpc
# Note that if you remove the 'with' clause here, you need to separately
# call channel.close() when you're done with the gRPC connection.
with grpc.insecure_channel("192.168.100.1:9200") as channel:
stub = spacex.api.device.device_pb2_grpc.DeviceStub(channel)
response = stub.Handle(spacex.api.device.device_pb2.Request(get_status={}))
# Dump everything
print(response)
# Just the software version
print("Software version:", response.dish_get_status.device_info.software_version)
# Check if connected
print("Connected" if response.dish_get_status.state ==
spacex.api.device.dish_pb2.DishState.CONNECTED else "Not connected")