Problem sync Garmin GPS on Linux

I have an odd problem and am wondering if anyone else has seen it and maybe has a fix.

Most of the time my Garmin Vista HCX GPS is synced over a USB connection to Windows PCs. Window7 and then Windows 10. It works fine 99.999% of the time. Since the last GPS week rollover there are times when Win10 cannot sync with the GPS. The fix is to power cycle the GPS, do a sync whilst the Garmin welcome screen is displayed and after that you can sync whenever you like.

I have a few days away and want to handle the sync on a Linux laptop except it’s being problematic. I have a Win10 tablet I can use but taking a tablet and laptop is over the top.

The problem is gpsbabel is having problems communicating with the GPS. I have used gpsbabel before when my Win10 tablet was missing Garmin USB drivers. I used gpsbabel on my Raspberry Pi, the one that drives my Iridium modem, to handle the comms. gpsbabel on the Pi worked every time.

Now when I try I have a very short window when comms works. If the GPS is on and connected to the laptop and I try to upload or download routes/tracks etc. I will get a message saying no data and cannot init /dev/ttyUSB0. If I power cycle the GPS and issue the gpsbabel command when the Garmin welcome screen is displayed then the transfer works perfectly. As soon as the GPS menu screen comes up, comms no longer functions. /dev/ttyUSB0 is the Garmin GPS using the garmin_gps driver in the kernel and the command is “gpsbabel -r -t -i garmin -f /dev/ttyUSB0 -o gpx -F myroutes.gpx”

I haven’t tried blacklisting the garmin_gps driver and trying using the usb: pseudo device in gpsbabel with the command “gpsbabel -r -t -i garmin -f usb: -o gpx -F myroutes.gpx”

Computer is a 6 year old Dell i7 running Debian Linux 11.1 with kernel 5.10.0-9-amd64 and the GPS is a Garmin Vista HCx from 2008.

Has anyone seen anything like this or is it my particular setup and GPS device that are not playing nice.

1 Like

/dev/ttyUSB0 sounds like generic USB serial driver like FTDI or Profilic. This can change to /dev/ttyUSB1 etc. next time you plug in the USB-cable (use udevd to create fixed symbolic link).

There seems to be kernel module …/kernel/drivers/usb/serial/garmin_gps.ko too in my Raspberry Pi. Maybe unload other serial drivers if this is needed?

What do your get with lsusb? dmesg is also useful when USB is plugged in.

Longer command to list more properties for udev.

udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0

or in older systems

udevinfo -a -p find /sys -name dev | grep ttyUSB0

73, Jaakko ac1bb/oh7bf

You can set up a udev rule to make sure the same device name is available each time it is plugged in. I don’t remember the syntax, but I could go and look it up if you like.

Edit: unfortunately I don’t have a gps to try it out on…

I’ve been doing some playing about here. Of course it should be some simple debugging but like everything simple and software I started at 4pm and its 945pm now and things are not properly sorted.

I confirmed that it was still broken on the laptop (Debian 11)

I powered up the Raspberry Pi I have used before to drive my GPS. Can’t remember the static IP address it has so I can’t connect. It runs a turnkey app, connect Iridium modem power up Pi, wait 3 minutes and then you can connect to the access point with your phone and access the webserver to send spots. Find old phone with the links to the webpages, find IP address. Ah of course it was that.

Connect up laptop to Pi access point, plug in GPS, ssh to PI, read GPS help file I wrote back in 2016. Run commands and gpsbabel talks to GPS but wont write out file. Well that’s odd but I remembered that there was something else but never wrote it down. Idiot! See that gpsbabel is v 1.5.3 and we’re on gpsbabel v 1.7.0 on the laptop.

Right, I’ll get an old version and try that. No old versions packaged for Debian 11. Ponder why software development is as b-awful today as it was when I started in the late 70s. Nothing ever works or is simple.

Have a glass of Malbec, things look better.

I’ll build my own version and add some debug. Fire up Linux development machine. git clone … to get gpsbabel source. Try to figure out why website build instructions don’t work. Because “software development” that’s why the instructions are wrong. Hey who never added the extra command to his own notes? :blush:

Figure out you run the build_and_test script. Much activity till we get a build error. Install lisbusb-dev and restart. A few mins later same error. Install libusb-1.0.0-dev and restart. Different error Oh gawd have to install QT5. Big download and restart. Error about missing packages. Google for 10mins, add missing serial package and restart. It takes a few mins to build and fail. Add more QT packages, restart and build.

Stops with an error packaging. Hey who cares if I can make a package of this, did it build the damn program, gpsbabel. Yes it did. Does it run? Yes it does. Ah job done.

Nope. Connect gps to dev system (Dell microdesktop i5 Debian 11). Chech gps is found. Issue magic command “Can’t INIT /dev/ttyUSB0”. Try under sudo, still no dice. Now I remember using the Pi. You let it boot, then plug in the GPS, then remove the driver then issue the raw usb command.

gpsbabel -r -t -i garmin -f usb: -F myfile.gpx

Beep… “Transfer complete” appears on GPS and we’re done. No, no output file. Then I remember the missing step… use the alternative command line format

gpsbabel -r -t -i garmin -o gpx usb: myfile.gpx

Beep and we have a file on disk. It’s working.

Reconnect everything to Pi and get a shell on it and try second format command and it too works 100%.

So the file I built works. Copy it to the laptop. Plug in GPS, remove garmin_gps driver, issue new style command on my own built version does exactly the same as the packaged distro version.

I started to sob looking at how much time I had spent on this. But what it tells me is there is an issue with this laptop setup.

gpsbabel 1.5.3 on an old Debian 8 on a Raspberry Pi works perfectly.
gpsbabel 1.7.0 (selfbuilt) on Debian 11 on a Dell i5 works perfectly.
gpsbabel 1.7.0 (packaged version) on same machine works perfectly.
gpsbabel 1.7.0 (selfbuilt) on Debian 11 on the laptop fails
gpsbabel 1.7.0 (packaged version) on the laptop fails.

So it’s the laptop setup. I tried a few cables in case the laptop was being sniffy. It will be something in the permissions, setup of the laptop which is subtly different. But at least I know my version I built works. Shame I had to install about 200mb of QT5 rubbish to get here. Every other USB “thing” works on the laptop so I don’t know why this is such a pain.

Of course the only machine I want this to work on is the laptop.

I’ve been doing software development for a living since 1983 full time and I think I have some clue about it. It’s taken me 2 Sunday afternoons/evenings to get as far as knowing something in the laptop is broken. And I should point out I’ve been working professionally with USB drivers and USB semiconductor design since 2009.

If it’s taken me this long to get nowhere, how the hell is Joe Average User meant to do this?

I need a drink!

2 Likes

Ho! Ho! Ho! And it’s fixed…

It’s all to do with power management on the laptop. USB autosuspend is enabled on the laptop and set to 2 seconds. This is seen by the GPS and after 2 seconds it powers down its USB port. This is why I could send and receive data just after connecting the GPS… I had a 2 second window to send the command before the GPS USB suspended.

With a quick “echo -1 > /sys/module/usbcore/parameters/autosuspend” you can disable the suspend and all of a sudden the damn gpsbabel command works perfectly.

I have aged significantly in trying to fix a simple problem. :sob:

5 Likes

After reading this, we can easily understand why dealing with computers is sometimes so much exasperating for most of us, poor users…
I spent quite a too long time on Saturday morning to get an audio file I recorded on my smartphone copied into my laptop. They would no be sent from my phone by email, whatsapp, bluetooth or any other method because of their big size.
Photos and videos got automatically transferred, but not other files like these audios.
Browsing the smartphone folders and files can’t be done as I have done so many times in the past with other phones. Why do we loose things everytime they move forward with their b. software?
At the end, I managed to copy those audio files to the micro-SD card, then extract the card from the phone, plug it into the laptop and after one time to first try and a second definitive time, the job got done.
Of course, after extracting the micro-SD card, I had to reenter the 2 SIM cards PIN numbers, which I didn’t remember and I had to find out.
As I said, exasperating…

73,

Guru

1 Like

I’ve seen that! (a few years ago, I’d forgotten until I read your solution, sorry!)

Downloading update maps to my Tom Tom satnav. The update software downloads the map file to HDD, but only if it sees the satnav present on USB. No traffic on usb until the download is complete.
On my HP desktop, the download would fail after 30 mins.
After much tinkering, I found that the HP default power plan turned off USB after 30 mins. Update app lost sight of Tomtom. Download aborted.

I now have an alternative power plan configured to keep everything running for such occasions…

1 Like

What I have learnt over years of doing this Adrian is to look for the patterns. I had a GPS that was failing in a strange way on Linux and fine on Windows. It’s not Linux per se but something about the setup so try it on another Linux setup. I should have tried the standard Debian version of gpsbabel on my Linux development machine first but I was diverted that it may be problem between versions of gpsbabel by seeing it work on the RPi. The rest was figuring out how to build a large project that uses qt5 (a cross platform development system).

Frustrations with the build out of the way, I could see that gpsbabel was perfect on one Debian 11 computer ( a desktop) and not on another Debian 11 computer (a laptop). At that point years of problem solving subconsciously started shouting POWER SAVING. It’s something laptops spend all their time doing so their batteries last longer. Once you start looking into power saving a Google for that and USB throws up info about autosuspend. The rest is easy. It’s getting to point of knowing what to look for that is painful.

What’s silly is the desktop is one of these tiny things, it’s really laptop technology in a tiny desktop case. In fact there is a PSU on the floor which is as big as the computer!

3020

2 Likes