Juha
Juha

Reputation: 51

GPSD - How to create a virtual GPS Source with lat/lon as input

I have a system that uses gpsd as a source for positioning. I need to integrate it with another system that gives me latitude, longitude & time.

I was able to generate NMEA sentences using nmealib:

user@locahost :~/Desktop/nmealib$ build/samples_generate 
$GPGGA,154400.00,5000.0000,N,3600.0000,E,3,01,0.0,10.9,M,0.0,M,0.0,0000*7d
$GPGSA,A,3,00,00,00,00,00,00,00,00,00,00,00,00,0.0,0.0,0.0*32
$GPGSV,1,1,01,00,00,000,00,00,00,000,00,00,00,000,00,00,00,000,00*78

My goal was then to pipe this to gpsd.

Option 1: with a FIFO file:

mkfifo /tmp/mkfifo    
gpsd /tmp/mkfifo    
./samples_generate > /tmp/mkfifo

Option 2: with a TCP socket:

gpsd tcp://localhost:8888
/samples_generate | nc -p 8888

On both situation, gpsd gave an error.

In essence, I would like to have similar functionality to gpsfake, but without using a logfile, instead using the stdout from my script.

Do you have any idea on how to realise this setup?

Upvotes: 3

Views: 1368

Answers (2)

superlinux
superlinux

Reputation: 470

I only want to add more to the correct answer .

If you happen to own a WWAN modem card then do the following.

save the following lines in file as a shell script and make it executable. let say it's named wwan-gps.sh . Please use the command mmcli --list-modems to know the modem index number. Here the index is zero (look at mmcli -m 0 in the script)

while true; do
clear
mmcli -m 0 --location-get | tail -n +2|  sed 's#.*\$#$#'
sleep 2
done;

then run the following command as root from the same current directory as wwan-gps.sh :

stdbuf -oL ./wwan-gps.sh | gpsd -n -N -D 5 /dev/stdin

Also, if you you are one of those who use the sky map program kstars, this MUST help you. in the devices section of kstars , look for GPSD and make sure that you install the indi drivers

Upvotes: 0

Juha
Juha

Reputation: 51

I found out how to pipe the data:

stdbuf -oL build/samples_generate | gpsd -n -N /dev/stdin
  • stdbuf -oL makes output of samples_generate line buffered, otherwise the text could be buffered and written in large chunks instead of line per line

Hope this helps someone with the same issue.

GPSMON log of the working setup

Upvotes: 2

Related Questions