jvde-github / AIS-catcher

AIS receiver for RTL SDR dongles, Airspy R2, Airspy Mini, Airspy HF+, HackRF, SDRplay and SoapySDR
https://aiscatcher.org
GNU General Public License v3.0
499 stars 76 forks source link

Provide static GPS data to OpenCPN at a fixed location #164

Closed g7ruh closed 1 year ago

g7ruh commented 1 year ago

Jasper

I have had a play with netcat and echo to input a static location for the AIS-catcher web display. That works and provides my location so range and bearing work in the list view.

When I use the -x option to feed via a bash script every e.g. 5 seconds, I get

GGA: lat = 50.12345, lon = -1.12345 GGA: lat = 50.12345, lon = -1.12345 GGA: lat = 50.12345, lon = -1.12345 GGA: lat = 50.12345, lon = -1.12345 every time it gets a string from the script:

echo '$GNGGA,100505.000,xxxxxxxx,N,yyyyyyyyyyyy,W,2,17,0.65,25.1,M,47.6,M,,*54' | nc xxx.xx.xx.xx nnnnn -u -q0

regardless of the -o 0 or -q settings. Is this expected function?

Is it possible to output the $G... string every x seconds in its native format along with the !A.... data so that OpenCPN will receive and decode the string and accept it as its current location. The default on OpenCPN is to expect a continual valid GPS stream (as it is designed to be live for navigation). I have found that providing a new location message every 5 seconds mostly works, and every 2 seconds does work.

That way it will feed OpenCPN with its default settings. I have tried modifying the time-out time before OpenCPN declares the location invalid, but without much success. The config seems to be a bit of a black art.

In OpenCPN, the GPS icon top right shows green status:

image

and my vessel shows red:

image

Ideal would be to specify as a config line option:

AIS-catcher -k GNGGA,100505.000,xxxxxxxx,N,yyyyyyyyyyyy,W,2,17,0.65,25.1,M,47.6,M,,*54 <number of seconds repeat interval>

less perfect would be to have the string in a text file for AIS-catcher to read:

AIS-catcher -k <file name.txt> <repeat interval>

even less perfect is a script to echo the string to a port direct to OpenCPN, my current solution.

By now you are quite likely wondering why, when I have said I want to use AIS-catcher as my go-to solution. It is true but sometimes I use OpenCPN for demonstrating stuff and having it fed via AIS-catcher makes it a subsidiary solution.

Why did I use -k for the examples above? One of the letters you have yet to use :)

Thanks for considering this,

Regards Roger

jvde-github commented 1 year ago

I have removed the lat/lon comments in the output. They were there for the user benefit but if they are confusing best to remove.

I understand the suggestions on the output. AIS-catcher is set up to take input from GPS, not to process and multi-plex it. Somehow I think this script is an appropriate solution for such a specific requirements which is essentially an OpenCPN issue.

I will have a think how we can get the GPS NMEA strings in the output.

Regards, Jasper

g7ruh commented 1 year ago

"I will have a think how we can get the GPS NMEA strings in the output."

Thanks Jasper,

Taking the thought a little further: You have covered pretty much all use cases by having inputs and outputs, TCP and UDP and recovery from e.g. link failures.

By having the ability to allow pass-through of NMEA strings, whatever source, for other software to source or sink, you can provide a one-stop solution for folks who use boats for pleasure and want to integrate all their boat-related devices. Those devices, helm control, depth sounding etc, I understand use NMEA strings as a common platform. The functionality would be a bit like Kplex. Kplex has not been updated for more than 3.5 years and has a few bugs identified but not yet fixed.

I am not suggesting it gets overly complicated, thereby adding support issues. I am just thinking that the functionality (multiplex-wise) is nearly complete, allowing pass-through makes it so. It may need simple filtering as per my example above, a specific string and a timer for limiting the amount of traffic.

This is the sort of thing plug-ins can be created for, using the core functionality as above, where a third party can develop those plug-ins for supporting different peripheral devices.

Just some thoughts for you to consider if you think them useful in AIS-catcher.

Regards Roger

jvde-github commented 1 year ago

Ok, so:

echo '$GPGGA, 161229.487, 3723.2475, N, 12158.3416, W, 1, 07, 1.0, 9.0, M, , , , 0000*18' | ./AIS-catcher -r txt .

now will print the NMEA string to screen as well. Adding -o 3 will show it as JSON and adding -o 0 will not show it at all.

If you run JSON input for GPS, e.g. via GPSD server, will print NMEA on screen (with -o 1/2) or the original JSON otherwise, e.g.:

AIS-catcher -t gpsd localhost 2947 -o 1

You can filter out GPS NMEA lines from the output by using a filter:

AIS-catcher -t gpsd localhost 2947 -o 2 FILTER on GPS off

Next step is to include GPS in TCP outputs and UDP outputs by default.... And to get the bugs out :-)

EDIT: also TCP and UDP will pull through GPS. I think this is much as I will do on this topic, apart from documenting advanced routing

g7ruh commented 1 year ago

Jasper,

Brilliant, thank you. I have simplified my setup with your enhancements. I use UDP broadcast and feed the static GPS string to AIS-catcher via a script with one "echo" statement and a sleep 5.

My AIS-catcher .conf file is also simplified by using broadcast on the local LAN with the static location being picked up from the script input feed, providing "-N SHARE_LOC on" is set.

For anyone who wants to use OpenCPN, AIS-catcher is a simple and low memory and CPU usage solution as a source of AIS data. This maybe because they have maritime charts rather than simple web-based mapping.

Thanks for all the work you have put in enhancing aspects of AIS-catcher, it has come togther very nicely.

Regards Roger

PS, I like the pop-up too:

image