Friday 27 April 2018

Raspberry Pi as an NMEA Multiplexer

So I got an AIS 'transponder'. They call them transponders - it says it on the box. But it isn't actually a transponder. A transponder transmits in response to a probe. AIS 'transponders' are beacons. They transmit even if nothing is probing them.

Anyway, I want the AIS targets displayed on the chart plotter and the chart plotter only has one NMEA input which is already used for depth so I need a multiplexer.

I'm using a Pi3 with USB/Serial adaptors. The plan was to use all of the four USB sockets with one adaptor going to the AIS transponder, one to the chart plotter, one to the DSC VHF radio and one to the depth device.

But one of my USB ports doesn't work. So I'm sharing one device for the depth and the VHF. The input comes from the depth unit and the output goes to the VHF. I don't have anything to get the DSC targets from the radio but that's OK for now.

There are (at least) two choices for software NMEA multiplexors on Linux. The most mature is kplex. The alternative is Signal K. I'm using both but I'm only using kplex in anger.

There are problems.

  1. The wifi is configured as a hotspot. It doesn't always start-up properly. I've put a 10s delay in the init.d script for now and that seems to fix it but its a hack.
  2. I can't work out how to make the USB/Serial ports always end up on the same device names.
There is lots of advice on the internet about USB naming. The answer is to write some UDEV rules to sort it out. This works OK for the single PL2303 device but I haven't come up with anything for the two indistinguishable Cxxxx devices.

I think I need to make kplex auto-baud and auto detect the type of device from the sentences it outputs.