scubajorgen / TomTomWatch

Tool for exporting GPS files from TomTom Sports Watches
85 stars 18 forks source link

Problem claiming USB interface #1

Closed heikojansen closed 7 years ago

heikojansen commented 7 years ago

Hi,

I wanted to give your app a try because unlike ttwatch it seems to support route uploads, but it does not connect to the watch (a Runner 3 Cardio).

I have ryanbinns/ttwatch installed and it works fine (it can connect to the watch and modify data). ttwatchd is not running. I have the udev rules set up as ttwatch recommends, so everything that follows is done as normal user (i.e.: not "root")

I start your app and it logs this to my shell: e 2017-09-09 18:37:42 ERROR: No valid USB device found

When I connect my watch, the output changes: e 2017-09-09 18:37:43 ERROR: USB Error: USB error 6: Unable to claim interface: Resource busy

I do not know what else might claim the usb interface. lsof reports nothing:

> ll /dev/tomtom
lrwxrwxrwx 1 root root 7  9. Sep 18:42 /dev/tomtom -> hidraw1
> ll /dev/hidraw1
crw-rw---- 1 root users 249, 1  9. Sep 18:42 /dev/hidraw1
> lsof | grep tomtom
> lsof | grep hidraw1
>

My environment: openSUSE Tumbleweed x86_64 openjdk version "1.8.0_144" OpenJDK Runtime Environment (IcedTea 3.5.1) (suse-2.1-x86_64) OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)

If I remove the udev rules, reboot and try again your app complains about insufficient rights, so the udev setup should be ok.

Digging on the internet turned up a few hints. This one looked particularly interesting: https://groups.google.com/d/msg/usb4java/bVgfpCgKDJ0/wBhpa2CotLkJ But I´m a Java noob so wasn't able to verify that myself.

Would be cool, if you could have a look. Thx

scubajorgen commented 7 years ago

Same problem here on slackware. This will be sort of out of my reach, because I use libusb for using (and claiming) the USB. On google I found that probably the kernel driver claimed the USB device and probably ttwatch uses the kernel driver. I have to look in this further...

heikojansen commented 7 years ago

I thought you might modify https://github.com/scubajorgen/TomTomWatch/blob/master/src/main/java/net/studioblueplanet/usb/UsbConnection.java#L150 and give the solution a try that is proposed in the Google Groups message I linked to?

scubajorgen commented 7 years ago

Thanx for pointing out! I did not have a close enough look at the solutions you proposed when I reproduced the problem at my side. The solution you provided works. Incorporated it.