Hi so l have a code running on my pi to get the corrections.That is getting corrections from my base station, as l undesrstand the messages have to be bundled in a certain format Serialization · MAVLink Developer Guide
import serial
import socket
from pymavlink import mavutil
NTRIP caster details
caster_ip = “rtk2go.com”
caster_port = 2101
mount_point = “”
username = “”
password = “”
Serial port configuration
serial_port = “/dev/ttyACM1”
serial_baud = 57600
Connect to the NTRIP caster
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((caster_ip, caster_port))
Directly format the username and password for the HTTP request
request = (
f"GET /{mount_point} HTTP/1.0\r\n"
f"User-Agent: NTRIP PythonClient/0.1\r\n"
f"Authorization: Basic {username}:{password}\r\n"
“\r\n”
)
s.sendall(request.encode(‘utf-8’))
Open serial port
ser = serial.Serial(serial_port, serial_baud)
MAVLink connection to Pixhawk
the_connection = mavutil.mavlink_connection(serial_port, baud=serial_baud)
Wait for heartbeat to confirm connection
the_connection.wait_heartbeat()
print(“Heartbeat from system (system %u component %u)” % (the_connection.target_system, the_connection.target_component))
Forward NTRIP data to Pixhawk as MAVLink GPS_RTCM_DATA messages
try:
while True:
data = s.recv(1024)
if not data:
break
# Print received data for debugging
print("Received data from NTRIP:", data)
print("Length of received data:", len(data))
# Send the correction data as MAVLink GPS_RTCM_DATA message
# Split data into chunks that fit into MAVLink payload (up to 280 bytes per message)
for i in range(0, len(data), 280):
chunk = data[i:i+280] # Chunk size set to 280 bytes
chunk_len = len(chunk)
if chunk_len > 0: # Check if the chunk is not empty
the_connection.mav.gps_rtcm_data_send(
0, # flags parameter, usually 0
chunk_len,
chunk
)
# Print the data sent to Pixhawk
print("Sent to Pixhawk:", chunk)
else:
print("Empty chunk. Skipping...")
finally:
s.close()
ser.close()
l aint getting them though on the auto pilot