Getting Position-Report data from OpenCPN

Position-report data for Sailmail can be obtained from OpenCPN, either from OpenCPN running on the same computer or via a wired or WiFi network. This is done by creating a new network connection, using OpenCPN’s “Connections” settings tab. Data can be sent either via UDP or a TCP connection, see below.

To make data available from OpenCPN, click the Settings button and then select the “Connections” tab. The input connections should already be configured (for example COM4 in the example window below). Be sure that data input is correctly configured and working before setting up any data output.

To share data from OpenCPN, click “Add Connection” on the connections page, and then select “Network”. To create a TCP server, select “TCP”, leave the Address box blank, and enter a TCP data port: 2947 is the OpenCPN default which works fine, alternately 10110 is a port reserved specifically for NMEA data. Any port number can be used that is not already in use; it is best to stick to numbers above 2000, and below 30000. UN-check “Receive input” and check “Output on this port”. OpenCPN will send all data by default with the Talker-ID of “EC”, and there is generally no need to change those settings or the filters. Click Apply to save the settings.

Alternately, UDP broadcast can be used but first read the notes below. Select “UDP”, and to broadcast to all devices on the network enter the broadcast address of 255.255.255.255. Alternately, to send to another program on the same computer enter the address 127.0.0.1. Enter a UDP Data Port, 2947 is the OpenCPN default but see the note above. And again, UN-check “Receive input” and check “Output on this port”, and click “Apply” or OK to save settings and close. It is always a good idea to re-open and verify the settings.

Another option is to set up both Data Server and a UDP connection. This is literally as simple as setting up both connections as described above. This allows other programs to connect either via TCP or UDP based on capabilities and network configuration. The same port number can be used for both connections, as TCP and UDP ports are separate.

In Airmail, open the Position Report window (from Airmail’s Window menu), find “Data input” near the bottom, and click on the “Setup” button. This opens a Data-Input Window. Click “Settings” or “Advanced settings”, select TCP (or UDP), and enter the same port number as used for the source above.¬†For TCP, if that source is the same computer then leave the address box blank or enter “127.0.0.1” or “localhost”, and if the TCP source is a different computer or device then enter its IP address. For UDP leave the address blank.

Note that Airmail prior to 3.5.060 doesn’t gracefully share UDP ports. Sending data from OpenCPN to Airmail on the same computer will work fine (and should be reliable), but trying to send to multiple receiving programs may not work– Airmail may not be able to open the port. Updating Airmail or using the TCP server option above will avoid this issue.

Note also that a “UDP Broadcast” as described above will generally not be forwarded through a WiFi network. UDP can be directed to a specific IP address (instead of being broadcast), and this will generally work. This is not an issue with most wired network connections, and using a TCP client/server connection will avoid the whole issue.