lkarsten / fdxread

Nexus FDX decoder for Garmin GND10
GNU General Public License v2.0
15 stars 4 forks source link

How to connect fdxread to nmea sleuth/opencpn (Was: netcat) #6

Closed ygageot closed 7 years ago

ygageot commented 7 years ago

From a dump file, I tried to pipe fdxread nmea output with only $GPRMC to OpenCPN or Chrome extension NMEA Sleuth without success. Can you insert in the documentation an example ?

Thanks

lkarsten commented 7 years ago

Hi.

Not a whole lot of documentation ready, but let me try to explain.

These NMEA consuming programs are often made to either read from serial ports or from a TCP socket.

(virtual) Serial ports can only be opened by one program at the time, and are complicated beasts, so I don't want to do that. Making a TCP server that they can connect to and receive NMEA0183 over, is certainly possible.

Netcat ("nc") is a program for creating and communicating over TCP sockets. By piping the output from stdout into netcat, we can ship the data over the network. In this case we just want to ship it to another server on localhost, that does the "fan-out" to multiple reading programs when/if they connect. My current favourite for such multiplexing/fan-out is kplex by Keith Young. See http://www.stripydog.com/kplex/ .

Kplex, after installed, can be started with the following command:

$ kplex tcp:direction=both,mode=server,address=127.0.0.1,port=10110

This creates a listening TCP server on 10110, where connecting clients can write data in (which is sent to all other clients) and read what the others have said. If a client disconnects, the others remain.

In a shell, run ./fdxread --pace 1 dumps/dhregatta-baerum-2016-08-22.dump | nc 127.0.0.1 10110. The parsing warnings should appear slowly, but the NMEA0183 is sent to kplex.

To verify that this part works you can use a new shell/window and connect manually to kplex: nc localhost 10110 will connect, read the NMEA0183 coming through from fdxread and output it to the screen. Ctrl+c to stop. You can start/stop this as many times and as many concurrent ones as you wish.

Now NMEA Sleuth can be configured to connect to kplex just like our verification netcat. Options -> Settings. Pick the "NMEA" tab, set "Source" to "IP Address", and fill out the IP and port on the right panel. IP address is 127.0.0.1, and port is 10110. Press Save, and then start it with the "open" button on the main screen.

Right now the position, depth and date are being read correctly. I think libfdx/formats_nmea.py needs some love to get the other data we know about formatted correctly for NMEA Sleuth. I've only written fdx->nmea0183 for what OpenCPN and my test scripts could handle.

For OpenCPN 4.4.0, it is mostly the same procedure. Options -> Connections -> "Add connection" of type "Network" using TCP to 127.0.0.1 and (here: dataport) 10110. Note that OpenCPN will write waypoint NMEA back into kplex if you have an active route, which may be picked up by NMEA Sleuth and others. I haven't looked at it in detail. A workaround is to make kplex have a direction=out port in addition that opencpn connects to.

Anyway, that was a short getting started guide. Hope it helps.

ygageot commented 7 years ago

Thank you for your efficient help.

FDX1a.pdf FSX1.pdf

lkarsten commented 7 years ago

Looking good! :)