OpenMarine

Full Version: Python client to query SignalK server for GPS position
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm looking for a simple python script to read GPS data from the SignalK server. A simple script asking for a lat/long
string to get the current position, returning and then exit.

I have another RPi serving the SSB radio. This would benefit from having an automated position update with automatic 
conversion to ham radio grid syntax. 
The PAT software has (not fully implemented yet) an entry for gpsd, but my OpenPlotter does not run gpsd, hence the
wish for requesting it from SignalK.
Code:
import ujson, requests
resp = requests.get('http://localhost:3000/signalk/v1/api/vessels/self/navigation/position/value', verify=False)
data = ujson.loads(resp.content)
print(data)
print(data['longitude'])
print(data['latitude'])

this should print:

Code:
{"longitude":24.7344517,"latitude":59.7205103}
24.7344517
59.7205103