AIS Direwolf and aprs.fi

421 views
Skip to first unread message

OH1KH Saku

unread,
Jul 19, 2021, 2:22:46 AM7/19/21
to aprs.fi
HI!

Does anyone use Direwolf AIS capture to feed aprs.fi?
What I am looking for is some kind of linux solution for Direwolf kiss2jsonais.

I was testing DireWold AIS yesterday and it seems to decode over 50% better than gnuais. Well, the computer with Direwolf was also faster than with gnuais but I like also  upgrade the program as gnuais has not been developed in years.
How ever gnuais has direct support for aprs.fi, but using Direwold for same job needs some kind of converter to get AIVDM frames to json format.

Perhaps it could be done by copying json.c from gnuais, but C is not my strongest languages. and the json of gnuas seems to be tied  to curl somehow.  I would prefer Perl for that job. If there just would be a aisjson module.

Any comments?

OH1KH Saku

unread,
Jul 20, 2021, 3:53:29 AM7/20/21
to aprs.fi

Answer to myself:

I made a perl script that connects to Direwolf kiss tcp port and reads KISS/NMEA lines that Direwolf sends.

[0.3 08:51:47] AIS>APDW16:{DA!AIVDM,1,1,,A,15N4cJ`000rrjq@H@0i2hbuN0L0U,0*31
As it is a kiss frame the beginning of line is "garbage" and at the end of line there is byte 0xC0

Perl script cuts this line using "{DA" as delimiter. The tail part is then cleaned to remove 0xC0 to get clean NMEA line and after that the line is pushed as UDP datagram to MarineTraffic address and two ports of localhost address for ais_json script and local monitoring. I.E. three UDP frames are generated from one NMEA line.

Finally happened to find this with extensive Googling: https://github.com/sycophantic/ais_json
It is a Python script that can read an UDP datagram that has ais-NMEA line and push it to aprs.fi using jsonAIS format.
Before this ais_json.py works one must install libais with "pip install libais"

Ais_json may have some kind of bug. That could be seen from aprs.fi with ship name and/or destination sometimes having tails filled with "@". How ever this can also be wrong configured AIS transmitter of ship because it does not happen with all ships. That's why small modification was added to replace all "@"s with " "s in ship name and destination strings.


This setup seems to work now as expected.
Received NMEA frames count increased from around 15 messages/minute to value around 75 messages/minute !

Heikki Hannikainen

unread,
Jul 22, 2021, 5:12:12 AM7/22/21
to aprs.fi

Hi,

There is also a second bug in there: it sends every UDP frame as one JSON
AIS post, making an awful lot of requests to aprs.fi, when the data rate
on the AIS channel is high. aprs.fi will start throttling the requests at
some point, causing lost packets.

Make it buffer the packets for some 15-30 seconds and then send them all
in a single POST, with only the most recent position of each vessel once.
gnuais sends an export to aprs.fi every 60 seconds.

Thanks for the effort!
> --
> You received this message because you are subscribed to the Google Groups "aprs.fi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to aprsfi+un...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/aprsfi/b4f61861-4bd6-47e2-a565-4cb0fabd7181n%40googlegroups.com.
>
>

- Hessu

OH1KH Saku

unread,
Jul 22, 2021, 10:21:17 PM7/22/21
to aprs.fi
Yep!
Noticed that also.
Unfortunately Python is out of my knowledge, just did try to make some other changes unsuccessfully , so it leaves only one  choice; shut down ais feed to aprs.fi.

OH1KH Saku

unread,
Jul 22, 2021, 10:27:29 PM7/22/21
to aprs.fi
It is now turned off.

OH1KH Saku

unread,
Jul 26, 2021, 10:12:15 AM7/26/21
to aprs.fi
Hi!
I have now tried to learn a new language, Python. Hzzz.... it blows my mind! It is stupid, language or I am too old to learn...
Perhaps I started wrong way when used existing ais_json.py as base.

How ever now I have program that sends block of messages in every 30secs. Only thing that I could not do, even when tried hard, is to replace existing json nmea message with fresh one received if mmsi is same.
All I can do is to find duplicate mmsi and not add latest message that leaves the oldest message to be sent to aprs.fi in the post block.

On the other hand it could happen that decoder does not hear all transmissions from certain mmsi that makes  almost same effect as sending the oldest heard message  during 30sec block.

Well it seems to work as ships appear to map, but i do not know is it now formatted ok or not. No errors returned, anyway.

BTW:
 gnuais does not compile any more with Fedora 33 making "multiple definition of 'my'". Reason that prevents to compare DireWolf and gnuais reception in same computer.


Reply all
Reply to author
Forward
0 new messages