Librem 5 - Record a GPS track

Helo,

how can I record a GPS track?

Readily via command line.

Thank you!

2 Likes

You can read NMEA data from the GNSS module via socat:

sudo socat unix:///var/run/gnss-share.sock -

Afterwards you can use gpsbabel to convert it into other formats like GPX.

9 Likes

And how to read the currect x and y position on map as a string?

@dos:

This doesn’t work for me.

I output the data to nmea.data:

$GPTXT,DEFAULT LIV CONFIGURATION2B
$GPRMC,132102.050,V,5121.20976,N,00757.54187,E,0.0,0.0,311023,N
75
$GPGGA,132102.050,5121.20976,N,00757.54187,E,0,00,99.0,377.10,M,0.0,M,6E
$GPVTG,0.0,T,M,0.0,N,0.0,K,N
02
$GNGSA,A,1,99.0,99.0,99.01E
$GNGSA,A,1,99.0,99.0,99.0
1E
$GPGSV,3,1,10,13,71,297,30,54,068,14,53,121,05,52,227,7A
$GPGSV,3,2,10,22,45,147,15,32,297,20,27,194,07,24,066,79
$GPGSV,3,3,10,18,14,309,08,11,038,7D
$GLGSV,2,1,08,78,81,142,68,80,126,69,44,318,79,31,207,60
$GLGSV,2,2,08,77,30,039,67,27,135,85,13,336,86,07,020,65
$GPGLL,5121.20976,N,00757.54187,E,132102.050,V,N
40
$PSTMCPU,99.94,-1,49
42
$GPRMC,132103.000,V,5121.20976,N,00757.54187,E,0.0,0.0,311023,N
71
$GPGGA,132103.000,5121.20976,N,00757.54187,E,0,00,99.0,377.10,M,0.0,M,6A
$GPVTG,0.0,T,M,0.0,N,0.0,K,N
02
$GNGSA,A,1,99.0,99.0,99.0
1E
$GNGSA,A,1,99.0,99.0,99.0
1E
$GPGSV,3,1,10,13,71,297,30,54,068,14,53,121,05,52,227,7A
$GPGSV,3,2,10,22,45,147,15,32,297,20,27,194,07,24,066,79
$GPGSV,3,3,10,18,14,309,08,11,038,7D
$GLGSV,2,1,08,78,81,142,68,80,126,69,44,318,79,31,207,60
$GLGSV,2,2,08,77,30,039,67,27,135,85,13,336,86,07,020,65
$GPGLL,5121.20976,N,00757.54187,E,132103.000,V,N
44
$PSTMCPU,100.00,-1,49
7E
$GPRMC,132104.000,V,5121.20976,N,00757.54187,E,0.0,0.0,311023,N
76
$GPGGA,132104.000,5121.20976,N,00757.54187,E,0,00,99.0,377.10,M,0.0,M,6D
$GPVTG,0.0,T,M,0.0,N,0.0,K,N
02
$GNGSA,A,1,99.0,99.0,99.0
1E
$GNGSA,A,1,99.0,99.0,99.0
1E
$GPGSV,3,1,10,13,71,297,30,54,068,14,53,121,05,52,227,7A
$GPGSV,3,2,10,22,45,147,15,32,297,20,27,194,07,24,066,79
$GPGSV,3,3,10,18,14,309,08,11,038,7D
$GLGSV,2,1,08,78,81,142,68,80,126,69,44,318,79,31,207,60
$GLGSV,2,2,08,77,30,039,67,27,135,85,13,336,86,07,020,65
$GPGLL,5121.20976,N,00757.54187,E,132104.000,V,N
43
$PSTMCPU,91.26,-1,49
43
$GPRMC,132105.000,V,5121.20976,N,00757.54187,E,0.0,0.0,311023,N
77
$GPGGA,132105.000,5121.20976,N,00757.54187,E,0,00,99.0,377.10,M,0.0,M,6C
$GPVTG,0.0,T,M,0.0,N,0.0,K,N
02
$GNGSA,A,1,99.0,99.0,99.0
1E
$GNGSA,A,1,99.0,99.0,99.0
1E
$GPGSV,3,1,10,13,71,297,30,54,068,14,53,121,05,52,227,7A
$GPGSV,3,2,10,22,45,147,15,32,297,20,27,194,07,24,066,79
$GPGSV,3,3,10,18,14,309,08,11,038,7D
$GLGSV,2,1,08,78,81,142,68,80,126,69,44,318,79,31,207,60
$GLGSV,2,2,08,77,30,039,67,27,135,85,13,336,86,07,020,65
$GPGLL,5121.20976,N,00757.54187,E,132105.000,V,N
42
$PSTMCPU,27.44,-1,49
4A
$GPRMC,132106.000,V,5121.20976,N,00757.54187,E,0.0,0.0,311023,N
74
$GPGGA,132106.000,5121.20976,N,00757.54187,E,0,00,99.0,377.10,M,0.0,M,6F
$GPVTG,0.0,T,M,0.0,N,0.0,K,N
02
$GNGSA,A,1,99.0,99.0,99.0
1E
$GNGSA,A,1,99.0,99.0,99.0
1E
$GPGSV,3,1,10,13,71,297,30,54,068,14,53,121,05,52,227,*7A
$GPGSV,3,2,10,22,45,147,15,32,297,20,27,194,07,24,066,*79
$GPGSV,3,3,10,18,14,309,08,11,038,*7D
$GLGSV,2,1,08,78,81,142,68,80,126,69,44,318,79,31,207,60
$GLGSV,2,2,08,77,30,039,67,27,135,85,13,336,86,07,020,65
$GPGLL,5121.20976,N,00757.54187,E,132106.000,V,N
41
$PSTMCPU,17.96,-1,49
46

Then I try to convert it with gpsbabel:

gpsbabel -i nmea -f test.nmea -o gpx,gpxver=1.1 -F "outputfilename.gpx"

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.0" creator="GPSBabel - https://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/0">
  <time>2023-10-31T13:22:28.255Z</time>
  <trk/>
</gpx>

And it shows an file without GPS data.

1 Like

There’s no valid GPS fix in this data you posted.

To elaborate on that for the benefit of @snakecatcher, or anyone else, one is looking for $GPGLL messages that have an A in the status field (not a V).

1 Like

So, what I have to do now to bring it work?

The app ‘Pure Maps’ works, it asks me to accept that Location information is fetched and then it works.

I don’t know why ‘Gnome Maps’ doesn’t work. It asks me nothing and shows me a wrong position about ~1 km far away from my position.

What I have to do now?

Edit:

This helps me to get Gnome Maps work: Getting Gnome Maps to work
Now the position is at the right position.

Don’t know what I have to do now, to record a GPS track.

1 Like

Are you dead-set on operating from the command line or just looking for something that can reliably capture GPS data? If the latter, this has been working well for me: Jogger | LinuxPhoneApps

It’ll take a lot of the guesswork out of the equation, if you don’t mind delegating data capture to an app.

1 Like

Persevere with the sudo socat thing, probably pipe it through grep so you only see $GPGLL records, and follow the procedure of being outside with a clear view of the sky for enough minutes to do the initial download and get that first valid fix. It may take 20 minutes or so.

Don’t worry about recording tracks or any apps whatsoever that rely on getting a location from GNSS until you get that first valid fix.

Is it true, that the fix is loaded every time new? When I restart the phone?

The app Jogger does what I wanted.

1 Like

The fix and the download are two different things. The download is a one-off (although it may need to be updated after some weeks). The download is stored in non-volatile storage on the GNSS chip (so, no, it is unaffected by restarting the phone). The fix has to be obtained each time you want to know where you are but can be quite quick.

The first valid fix is just used to confirm that it is actually now working.

Is it possible to extract the GPSX track from Jogger?

Not currently (you can export workouts as XML which includes the track data and could be converted to GPX but not directly).

GPX export is something I was thinking of adding though so possibly in a future version.

Jogger doesn’t work any more for me. When the app tries to establish my gps position, it shows a position 1 km far away from my position.

Gnome Maps and Pure Maps works. So why not Jogger?

1 Like

Maybe not using the best geodetic reference frame?

1 Like

Have you configured so that your phone will not try to access other sources of location information if GNSS is not working? (I recommend doing that anyway.)

1 Like

Most likely this issue: #8 - Location accuracy - baarkerlounger/jogger - Codeberg.org - a bug in an older version of xdg-desktop-portal which still ships with Byzantium.

Check apt show xdg-desktop-portal | grep Version if it shows 1.8.1 you’ll be affected. I’m using a newer version from debian backports as a workaround until Crimson is released.

PureMaps is not affected because it doesn’t use portals, Gnome Maps is affected if you install from Flathub but not if you installed via apt.

1 Like