Skip to content

ROV CTD UDP Client

To get the ROV CTD data from the logging system, you will want to send a message to a UDP message to a specific port to get the headers associated with the comma-separated values in the data and then send another message to get the data itself. There are two UDP servers you can connect to, one is on the navproc machine itself and one is on the navproc API server. We recommend the API server unless you need the data from navproc directly or the API server is not responding. The hostnames for for the UDP servers are rcnavproc1.rc.mbari.org for the navproc machine itself and coredata-rcsn.rc.mbari.org for the navproc API server. The port for both is 54007.

Message Structure

The header you will get from the UDP message will look like the following:

LOGHOST.SYSTEM.UTC, ROV.CTD.INWATER, ROV.CTD.TEMPERATURE.UTC, ROV.CTD.TEMPERATURE, ROV.CTD.CONDUCTIVITY, ROV.CTD.PRESSURE, ROV.CTD.ANALOG1, ROV.CTD.ANALOG2, ROV.CTD.ANALOG3, ROV.CTD.ANALOG4, ROV.PRESSURE.UTC, ROV.PRESSURE, ROV.POSITION.LAT, ROV.POSITION.LON, SHIP.GPS.LAT, ROV.CTD.POWER, LOGHOST.SYSTEM.CLOCKTIME.YEAR, LOGHOST.SYSTEM.CLOCKTIME.YEARDAY, LOGHOST.SYSTEM.CLOCKTIME.TIMESTRING, LOGHOST.SYSTEM.CLOCKTIME.TIMEZONE

and the data will look something like this:

1760123445, 0, 1759960021, 15.3889, 0.09939, NO_PROV, 2.4587, 1.9701, 3.4485, 0.0006, 1760123445, 0.0, 36.802113, -121.787082, 36.8, 0, 2025, 283, 19:10:45, +0

Python

Here is an example Python script that sends the header message first, then asks for the data:

import socket

def send_udp_message(host, port, message):
    """
    Send a UDP message and receive a response
    """
    # Create a UDP socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    try:
        # Set a timeout so we don't wait forever for a response
        sock.settimeout(5.0)

        # Send the message
        print(f"\nSending: '{message}'")
        sock.sendto(message.encode('utf-8'), (host, port))

        # Receive the response
        data, server = sock.recvfrom(4096)  # Buffer size of 4096 bytes
        print(f"Received from {server}:")
        print(data.decode('utf-8'))

        return data.decode('utf-8')

    except socket.timeout:
        print("No response received (timeout)")
        return None

    except Exception as e:
        print(f"Error: {e}")
        return None

    finally:
        sock.close()

def main():
    host = "coredata-rcsn.rc.mbari.org"
    port = 54007

    print(f"Connecting to {host}:{port}")

    # Send "header" message
    send_udp_message(host, port, "header")

    # Send "data" message
    send_udp_message(host, port, "data")

if __name__ == "__main__":
    main()