Last active
July 24, 2024 07:29
-
-
Save esutton/49a1591de7c2f7dc8257e4a61efa4b9f to your computer and use it in GitHub Desktop.
HTPP Get NTRIP Server SOURCETABLE
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 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) | |
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() |
Thanks.
Your welcome. I hope it was helpful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to support Python 3