This has a number of advantages in my particular install:
- It allows me to log the AIS data stream.
- It allows me to view the AIS on both Expedition and Nobeltec software at the same time.
- It allows me to simultaneously access the AIS stream from my iPad. I've tested it with Digital Yacht's iAIS app, but it should work with other apps running on the iPad.
The code really is very simple - it reads an entire line from the serial, detects any new clients and then forwards it to all TCP clients that have connected to it. Then loop. As a bonus it will cache the last received 200 AIS messages and send those immediately to any client that connects. This in the hope that this contains a number of VDM type 5 and 24 messages so that the client can show static AIS data immediately.
You can download the nmea_to_tcp script here. I'm releasing this under the GPL v3.
To use this code you must have a computer that has a PHP5 CGI interpreter. On Microsoft Windows you may want to remove the first line of the
nmea_to_tcp
script, as this instructs a Linux system to use the PHP interpreter. You may need to install the DIO direct I/O package.Connect you AIS receiver to a serial port, and then start the script with the name of that serial port as it's first argument, for instance
nmea_to_tcp /dev/ttyUSB0
on Linux; it is probably something like nmea_to_tcp //./com1
on Microsoft Windows.That's all. You should now be able to connect to the system at TCP port 2000.