我正在寻求帮助以了解如何开发一个完整且功能齐全的 NTRIP 客户端以接收 RTCM 更正。 我正在使用 Python 3.4,目前在 Windows 7 上。搜索网络,我找到了一些示例代码,并用它来编写一个基本的客户端。问题是……它不起作用。
我可以使用 rtk 更正服务。该服务处于事件状态并且正在运行。
这是我的代码片段。
dummyNMEA = "$GPGGA,143741.356,7839.493,S,07627.626,W,0,00,,,M,,M,,*45"
username = my_username #username for RTCM correction service
password = my_password #password for RTCM correction service
port = 2101 #port for the service
'''Generate an encoding of the username:password for the service.
The string must be first encoded in ascii to be correctly parsed by the
base64.b64encode function.'''
pwd = base64.b64encode("{}:{}".format(username, password).encode('ascii'))
#The following decoding is necessary in order to remove the b' character that
#the ascii encoding add. Othrewise said character will be sent to the net and misinterpreted.
pwd = pwd.decode('ascii')
print("Header sending... \n")
header =\
"GET /mountpoint HTTP/1.1\r\n" +\
"Host my_host\r\n" +\
"Ntrip-Version: Ntrip/1.0\r\n" +\
"User-Agent: ntrip.py/0.1\r\n" +\
"Accept: */*" +\
"Connection: close\r\n" +\
"Authorization: Basic {}\r\n\r\n".format(pwd)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((my_host,int(port)))
s.send(header.encode('ascii'))
print("Waiting answer...\n")
data = s.recv(2048).decode('ascii')
print(data)
s.send(dummyNMEA.encode('ascii'))
data = s.recv(2048).decode('ascii')
print(data)
s.close()
现在,代码部分起作用了。请求转到 rtk 服务器,我得到了正确的身份验证。我收到来自 ntrip 协议(protocol)的正确答案:
ICY 200 还行 服务器:“挂载点的服务器” 日期:“日期”
在此之后,我必须发送 NMEA GGA 语句,以便开始接收 RTCM 更正。我用生成器创建了各种虚拟 NMEA 句子并测试了发送它们。我发送了句子,然后……没有任何反应。我没有收到服务器的答复。
有人有想法吗?也许我在编码句子时做错了什么?
我读到也许我应该连续发送 NMEA 语句,但我是 Python 编程的新手,我不确定如何使用套接字来做到这一点。
英语不是我的母语,所以请原谅我的错误:)
谢谢大家。
请您参考如下方法:
当您发送 GGA 时,它是否覆盖了您的 rtk 校正服务?我以前这样做过,发送了网络覆盖范围之外的虚拟位置,没有任何返回,甚至没有错误消息,只是没有更正。
干杯, 史蒂夫。
