Issues with Raspberry Pi 3 and dAISy HAT

74 views
Skip to first unread message

Newcastle Lifeboat

unread,
Sep 6, 2020, 7:32:26 AM9/6/20
to kplex
Hi Folks.

Setting up an Raspberry Pi 3 with the dAISy HAT in my shed (plus closer to coast)

Steps so far are:

1. Downloaded Raspberry Pi Image from Downloads area.(Using Raspberry Pi OS (32-bit) with desktop)
2. Updated/Upgraded the build
3. Used the Shell script to configure the serial ports
4. Installed 'screen' to verify that system was working. 
5. Ran 'screen /dev/serial0 38400' from a terminal - YES. Brilliant!! Receiving AIS data
6. Installed Kplex

Now, this is where thing are going pear-shaped for me

I've been looking at the kplex.conf on my other pi in the school I work in which is happily working away over a network with an AIS receiver attached

As the is a HAT attached to the Pi, I'm not quite sure how to configure the kplex.conf file

I started with

[serial]
filename=/dev/serial0
direction=both
baud=38400


 At this point, I'm working it in stages to ensure everything is working and I understand what it's doing

I tried doing a tcpdump (and changing the device from eth0) using

sudo tcpdump -i /dev/serial0

but I only get an error message

tcpdump: /dev/serial0: No Such device exists
(SIOCGIFHWADDR: No such device

Can anyone offer advice on how to configure kplex to allow tcpdump to display AIS data onscreen before taking it to the next step and testing with Marinetraffic

Any assistance greatly appreciated

Declan

Keith Young

unread,
Sep 6, 2020, 11:29:10 AM9/6/20
to kplex
A few weeks ago I acquired a dAISy HAT in order to investigate the issue from the thread started by Richard Montgomery about sending data to Marinetraffic.  I agree it's a super-cute device which in the flat I'm renting is sat atop a pi 2 and gathering data from passing Thames traffic.  I'm still trying to work out the relationship between Marinetraffic's email notifications and traffic but I've learned a few things and sometime in the next few weeks will try and write those up.

To specifically address your question...

/dev/serial0 is a serial device and tcpdump works on network devices so it's not the tool you need.  In fact it's much easier than that.  If you have an ssh login to your pi, login in, stop kplex, then assuming your kplex.conf looks as it does above type:
kplex file:
kplex will add any interfaces you put on the command line to what is in the config file and you already have the serial interface in the config file.  "file:" without a filename argument and not direction argument will use standard input/output so what you should see is the same messages you saw using "screen".

Kill that with ctrl-C and you're ready for the next step.  Not interested in the detail and just want a config which works?  Add this to kplex.conf after the serial interface, reboot and looks for the pleasing green "Active" symbol on marinetraffic:

[udp]
address=<address marinetraffic gave you>
port=<port they gave you>
coalesce=yes
direction=out


..but for added interest read on..

 You can connect to marinetraffic via tcp or udp.  If you go tcp you want something which at a basic level looks like this:
[tcp]
address=<ip address marinetraffic gave you>
port=<port they gave you>
persist=fromstart

But things start to get a little more complex if you don't transmit much data.  Now you'd think that:
direction=out
..makes sense, right?  But here's the problem.  Because of an implementation detail, kplex only detects that an out-only connection has been dropped when it tries to send data but can't.  Marinetraffic reboot their services at regular intervals (hourly in the one I have, though I understand different machines on different occasions are restarted 3-hourly or 6-hourly).  If you have an outbound-only connection which is reset when marinetraffic reboots but you don't send any data for another hour kplex won't restart the connection, so you think you're "online no data" but marintraffic thinks you're "offline".  So what can you do? If you leave out "direction=out" then the "read" side of the connection *will* respond immediately to a dropped connection and restart the interface.  You might want to filter out all input though with:
ifilter=-all
The alternative is to give kplex something to send at regular intervals.  Not in 1.4 but in the current develop tree, you can configure a legal-but-meaningless sentence to be sent out of an interface at regular intervals (e.g. every 4 mins) with:
heartbeat=240

The other danger of low data rates for stations behind NAT routers is that some of them only maintain connection state for 5 mins, so if you get a lull in traffic the connection can time out.  "persist=fromstart" has a side effect of initialising tcp keepalives, packets which are sent simply to check the other end is still there but which have a side effect of keeping connections open over stateful firewalls and NAT routers.  kplex sets the period before these are sent much lower than the system default but for NAT routers with a 5 minute timeout it's still too long so you'd want to add:
keepidle=240
...to set the inactive period before keepalives are sent at 4 minutes (240 seconds).

So what would I do behind a NAT router with an unknown timeout with kplex 1.4?  perhaps:
[tcp]
address=<ip address marinetraffic gave you>
port=<port they gave you>
persist=fromstart
ifilter=-all
keepidle=240

If using the devlop tree I'd replace ifilter=all and  keepidle=240 with 
heartbeat=240
direction=out

But actually I'd prefer to go with the UDP option above.  It's lower overhead and there are fewer pitfalls.  The only downside for a low-data station is that if you don't transmit for an hour you're marked "offline" rather than "online no data", although in my experiments you can keep yourself "online no data" using the heartbeat option (again, not in the "production" 1.4 version), e.g.
heartbeat=900

Newcastle Lifeboat

unread,
Sep 6, 2020, 5:09:40 PM9/6/20
to kplex
Cheers Keith

I’ll give it all a good and see what happens. I suppose the ‘tcp’ in ‘tcpdump’ should have registered in the old grey matter. LOL!!

It’s all a learning curve for me. I use kplex in my setup at work as... it works!

I did look at the Raspberry Pi image at AISHUB but not able to work out how to set the default baud rate on the Raspberry Pi to 38400 as I’m still a novice at all this

Regards

Declan

Newcastle Lifeboat

unread,
Sep 9, 2020, 3:34:03 PM9/9/20
to kplex
Well. So far so good. System is up and running. Not producing much at moment as I need to get the aerial mounted outside on a pole but from inside the shed, I’ve picked up a vessel 10Nm away in Ardglass Harbour.

Hope to possibly pick up more coming from Kilkeel Harbour which is to the south of me but not sure if Mourne Mountains might get in way

Out of curiosity, if I stop the Kplex Service then run kplex file: does it still upload the info to (in my case) MarineTraffic

Declan

Sent from my iPhone

> On 6 Sep 2020, at 22:09, Newcastle Lifeboat <lifebo...@gmail.com> wrote:
>

Keith Young

unread,
Sep 12, 2020, 5:29:39 PM9/12/20
to kplex
Yes.

If you don't say "-f-" ("don't use a configuration file") you'll use your normal config file and anything else on the command line will be in addition to that

Newcastle Lifeboat

unread,
Sep 12, 2020, 6:28:45 PM9/12/20
to kplex
Cheers Keith

I've managed to install the vhf aerial outside the shed on a pole. As I am in Newcastle, Co Down, I managed to pick up the Irish Lights vessel Granuaile on a track from Carlingford Lough (picked up just off a place called Annalong) and just lost it around the mouth of Strangford Lough. At moment, very little vessel activity close in to me - fishing vessels are a bit to far north in the channel between Isle of Man and N. Ireland. Might consider getting the aerial extended a little higher if the fence can take it although that would only get me a max of 15m above sea level. Will add a third bracket depending on size of pole I can obtain from my local TV shop.

As this setup at home is difference from my setup at work (network) Is it possible to set the config file to allow me to set up a local workstation with Shipplotter on it to plot what is being received from the dAISy setup. I'm intrigued to see what it is 'Seeing' locally.

Regards

Declan

Keith Young

unread,
Sep 13, 2020, 5:21:04 PM9/13/20
to kplex
As this setup at home is difference from my setup at work (network) Is it possible to set the config file to allow me to set up a local workstation with Shipplotter on it to plot what is being received from the dAISy setup. I'm intrigued to see what it is 'Seeing' locally.

I'm not familiar with shipplotter  but a quick google suggests that it can act as a tcp client or server.  If you're leaving the pi running and during up ship plotter occasionally it probably better to make kplex run as a tcp server and get ship plotter to connect to it rather than have kplex constantly trying to reconnect to ship plotter when your PC is turned off.  So add the following stanza to the kplex configuration file:
[tcp]
mode=server
direction=out

The shipplotter documentation wasn't apparent but you then want to tell ship plotter to connect to port 10110 (this is default but configurable) on the pi.

I do something similar with mine: I use navionics on an iPad connected to the pi to see the data I'm collecting

Newcastle Lifeboat

unread,
Sep 14, 2020, 5:47:25 PM9/14/20
to kplex
Cheers Keith.

Have it up and running now. Thanks for your patience with me.

Added in the above settings to the kplex file and In the I/O Settings in Ship Plotter, I just needed to tick the client box of TCP/IP Input with the port 10110 and set the remote IP address to that of the Raspberry Pi.

Must be atmospherics. I'm picking up the Stena Mersey - Coming out of Belfast Lough plus 4 other vessels local(ish) to my area.  LOL!!!

Declan

Keith Young

unread,
Sep 15, 2020, 5:28:34 AM9/15/20
to kplex
Great!  Thanks for the feedback Declan.  It's always good to know people are actually using the stuff I write :-)
Reply all
Reply to author
Forward
0 new messages