Created
December 7, 2022 16:28
-
-
Save esutton/9935b650f48d02d1ef66f0f916e4d087 to your computer and use it in GitHub Desktop.
Get NTRIP mountpoints or SOURCETABLE using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#****************************** | |
# get-ntrip-source-table.py | |
# | |
# Get a NTRP server's SOURCETABLE mount points | |
# | |
# Verify host and port using wget or curl | |
# ` | |
# curl --http0.9 rtgpsout.unavco.org:2101 | |
# curl --http0.9 ok.smartnetna.com:10000 | |
# | |
# wget ok.smartnetna.com:10000 | |
# cat index.html | |
# | |
# wget -q -S -O - ok.smartnetna.com:10000 | |
# SOURCETABLE 200 OK | |
# Server: GNSS Spider 7.8.0.9445/1.0 | |
# Date: Mon, 05 Dec 2022 17:03:50 GMT | |
# Content-Type: text/plain | |
# Content-Length: 1109 | |
# | |
# STR;RTCM3_IMAX;RTCM3_IMAX;RTCM 3;;2;GPS+GLO;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM3_ViRS;RTCM3_ViRS;RTCM 3;;2;GPS+GLO;SmartNet North America;;41.26;-96.14;1;1;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM3_MAX;RTCM3_MAX;RTCM 3;;2;GPS+GLO;SmartNet North America;;41.26;-96.14;1;1;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM2_DGPS_IMAX;RTCM2_DGPS_IMAX;RTCM 2;;2;GPS;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;MSM_VIRS;MSM_VIRS;RTCM 3;;2;GPS+GLO+GAL+BDS;SmartNet North America;;41.26;-96.14;1;1;Leica GNSS Spider;none;B;Y;9600; | |
# STR;MSM_IMAX;MSM_IMAX;RTCM 3;;2;GPS+GLO+GAL+BDS;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM3_NEAR;RTCM3_NEAR;RTCM 3;;2;GPS+GLO;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM2_DGPS_NEAR;RTCM2_DGPS_NEAR;RTCM 2;;2;GPS;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;MSM_NEAR;MSM_NEAR;RTCM 3;;2;GPS+GLO+GAL+BDS;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# ` | |
# | |
################################# | |
# Get SOURCETABLE from an NTRIP server to discover mount points. | |
# | |
# Example: | |
# | |
# GET / HTTP/1.0 | |
# Host: ok.smartnetna.com:10000 | |
# User-Agent: MyAppName | |
# Accept: */* | |
# | |
# | |
# SOURCETABLE 200 OK | |
# Server: GNSS Spider 7.2.1.7804/1.0 | |
# Date: Wed, 05 Dec 2018 20:55:04 GMT Standard Time | |
# Content-Type: text/plain | |
# Content-Length: 1101 | |
# | |
# STR;RTCM3_IMAX;RTCM3_IMAX;RTCM 3;;2;GPS & GLO;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM3_ViRS;RTCM3_ViRS;RTCM 3;;2;GPS & GLO;SmartNet North America;;41.26;-96.14;1;1;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM3_NEAR;RTCM3_NEAR;RTCM 3;;2;GPS & GLO;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM3_MAX;RTCM3_MAX;RTCM 3;;2;GPS & GLO;SmartNet North America;;41.26;-96.14;1;1;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM2_DGPS_IMAX;RTCM2_DGPS_IMAX;RTCM 2;;2;GPS;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;RTCM2_DGPS_NEAR;RTCM2_DGPS_NEAR;RTCM 2;;2;GPS;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;MSM_NEAR;MSM_NEAR;RTCM 3;;2;GPS+GLO+GAL+BDS;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# STR;MSM_VIRS;MSM_VIRS;RTCM 3;;2;GPS+GLO+GAL+BDS;SmartNet North America;;41.26;-96.14;1;1;Leica GNSS Spider;none;B;Y;9600; | |
# STR;MSM_IMAX;MSM_IMAX;RTCM 3;;2;GPS+GLO+GAL+BDS;SmartNet North America;;41.26;-96.14;1;0;Leica GNSS Spider;none;B;Y;9600; | |
# ENDSOURCETABLE | |
################################# | |
import socket | |
UserAgent = 'MyAppName' | |
# ok.smartnetna.com is commercial | |
# https://www.smartnetna.com/ | |
Server = 'ok.smartnetna.com' | |
Port = 10000 | |
Station = 'RTCM3_NEAR' | |
# rtgpsout.unavco.org is free but requires registration to us | |
# SOURCETABLE returns hundreds of NTRIP mount points | |
# http://www.unavco.org/instrumentation/networks/status/all/realtime | |
# Server = 'rtgpsout.unavco.org' | |
# Port = 2101 | |
# Station = 'WMOK_RTCM3' | |
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
server_address = (Server, Port) | |
client_socket.connect(server_address) | |
request_header = ('GET / HTTP/1.0\r\n' + | |
'Host: %s:%s\r\n' + | |
'User-Agent: %s\r\n' + | |
'Accept: */*\r\n' + | |
'\r\n') % (Server, Port, UserAgent) | |
print("**********************") | |
print("* request_header *") | |
print("**********************") | |
print(request_header) | |
request_header = bytes(request_header, encoding='utf-8') | |
client_socket.send(request_header) | |
# A large SOURCETABLE will arrive in multiple packets | |
response = b'' | |
while True: | |
recv = client_socket.recv(1024) | |
if not recv: | |
break | |
response += recv | |
print("**********************") | |
print("* response *") | |
print("**********************") | |
# response contains a bunch of '\r\n' terminated lines | |
response = str(response, 'UTF-8') | |
print (response) | |
client_socket.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Include curl example to get SOURCETABLE in comments