Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR_SEM_TIMEOUT error always and for anything #42

Open
sebastianzander opened this issue Aug 24, 2023 · 6 comments
Open

ERROR_SEM_TIMEOUT error always and for anything #42

sebastianzander opened this issue Aug 24, 2023 · 6 comments

Comments

@sebastianzander
Copy link

sebastianzander commented Aug 24, 2023

I am running Windows 10 with the latest Ruby version, in fact I just installed Ruby the first time and all dependencies should be up-to-date as well. I run your polar tool from an elevated PowerShell terminal, but no matter whether I request DIR or SYNC I always get such errors:

$ ruby .\polar_ftp --dev=//./COM3 DIR / results in:

Connected to ? serial ?
Synchronizing to 'C:/Users/live/Polar/unknown_serial'
Listing content of '/'
C:/Users/live/.local/share/gem/ruby/3.2.0/gems/rubyserial-0.6.0/lib/rubyserial/windows.rb:73:in `write': ERROR_SEM_TIMEOUT (RubySerial::Error)
        from D:/Development/Ruby/polar/lib/polar_usb_acm.rb:49:in `request'
        from D:/Development/Ruby/polar/lib/polar_ftp.rb:33:in `dir'
        from D:/Development/Ruby/polar/lib/polar_ftp.rb:71:in `recurse'
        from D:/Development/Ruby/polar/lib/polar_ftp.rb:129:in `sync'
        from ./polar_ftp:64:in `<main>'

I hardcoded the local sync directory since for some reason on my machine the device and serial are resolved as ? and Windows could, of course, not create a directory with a question mark.

I was only twice able to get the directory listings for / and /U/. I then wanted to list /U/0/ and since then I only received these semaphore function timeouts (ERROR_SEM_TIMEOUT). Any idea?

By the way: My ultimate goal was to extract more detailed GPS data from the watch, e.g. information about the precision of each recorded position. Not sure, however, whether Polar watches even record and/or store this information. Does anybody know this?

@cmaion
Copy link
Owner

cmaion commented Aug 25, 2023

Hi

Looks like an issue specific to Windows.
I just switched the serial port library used to another one (2f0d717). Pull and let me know if it works better for you!

As for precision of the GPS coordinates: the number of satellites used is recorded for each data point. Also time of first fix. See polar_training2test and dig into the protobuf/ files.

@sebastianzander
Copy link
Author

sebastianzander commented Aug 25, 2023

Hi, thanks for that quick push to master. Unfortunately, serialport also does not work. It just sits there at Listing content of '/' for hours. I can't even stop the process with Ctrl+C. If I disconnect the watch I get

D:/Development/Ruby/polar/lib/polar_usb_acm.rb:68:in `read': Permission denied (Errno::EACCES)
        from D:/Development/Ruby/polar/lib/polar_usb_acm.rb:68:in `read'
        from D:/Development/Ruby/polar/lib/polar_usb_acm.rb:51:in `request'
        from D:/Development/Ruby/polar/lib/polar_ftp.rb:33:in `dir'
        from polar_ftp:41:in `<main>'

I also once got

D:/Development/Ruby/polar/lib/polar_usb_acm.rb:68:in `read': Interrupt
        from D:/Development/Ruby/polar/lib/polar_usb_acm.rb:68:in `read'
        from D:/Development/Ruby/polar/lib/polar_usb_acm.rb:51:in `request'
        from D:/Development/Ruby/polar/lib/polar_ftp.rb:33:in `dir'
        from polar_ftp:41:in `<main>'

Is it possible to access the watch via Windows Subsystem for Linux? Out of the box it doesn't seems so; I cannot find /dev/ttyACM0 at least.

@cmaion
Copy link
Owner

cmaion commented Aug 28, 2023

Hi

Just pushed a new commit, give it a try.

@sebastianzander
Copy link
Author

sebastianzander commented Aug 28, 2023

Hey, only a little better. I can list some directories now, but I believe, the bigger the contents of the directory, the more unlikely it becomes that I can list its contents. But even if I could list the contents of e.g. /U/0 in order to get my training sessions, downloading bigger files would probably be the next hurdle. I tried GET /SYSCONF.BPB (6 bytes? big), but then I get this error:

Connected to ? serial ?
Downloading '/SYSCONF.BPB' as 'SYSCONF.BPB'
D:/Development/Ruby/polar/lib/polar_usb_acm.rb:50:in `write': Invalid argument (Errno::EINVAL)
        from D:/Development/Ruby/polar/lib/polar_usb_acm.rb:50:in `request'
        from D:/Development/Ruby/polar/lib/polar_ftp.rb:56:in `get'
        from polar_ftp:61:in `<main>'

I found a tutorial from Microsoft about how to Connect USB devices to Windows Subsystem for Linux. I will give it a try in the coming days.

@sebastianzander
Copy link
Author

Using usbipd-win under Windows and linux-tools-generic and hwdata under Ubuntu (Windows Subsystem for Linux) I am now able to list directory contents and download files easily. Also everything is way faster; at least the directory listing which I am able to compare to running it under Windows directly.

However, I had to revert your last two commits. I guess you are better off with rubyserial after all.

@cmaion
Copy link
Owner

cmaion commented Aug 30, 2023

ok good to know.
I have pushed another commit that you may want to try too, both on Windows directly & WSL (force serial flow control to HARD -- if it doesn't work on Windows, you might try NONE to disable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants