polar icon indicating copy to clipboard operation
polar copied to clipboard

Feedback -- Polar Loop 2

Open awik32 opened this issue 5 years ago • 10 comments

Hi,

I wanted to provide some feedback, in particular to report that I was now able to use polar_ftp to do a complete sync with my Polar Loop 2. It failed with the previous version I tried.

Now, I just need to figure out how I can convert and use the data.

Cheers, Albert Wik.

awik32 avatar Dec 11 '20 16:12 awik32

The README.md claims: "The device path is currently not auto-detected and should be specified ...". On my system (Linux Mint 19.3) it seems to be auto-detected just fine. -aw

awik32 avatar Dec 11 '20 16:12 awik32

Now, I get this error:

$ ./polar_physdata2txt ~/Polar/27A9EB2F/U/0/S ~/Polar/physdata.txt
Converting Polar user physical data in '/home/aw/Polar/27A9EB2F/U/0/S' to TXT format as '/home/aw/Polar/physdata.txt'...
Traceback (most recent call last):
	3: from ./polar_physdata2txt:46:in `<main>'
	2: from ./polar_physdata2txt:46:in `open'
	1: from ./polar_physdata2txt:47:in `block in <main>'
./polar_physdata2txt:38:in `output_txt': undefined method `value' for nil:NilClass (NoMethodError)

-aw

awik32 avatar Dec 11 '20 16:12 awik32

Is there a way to use these scripts to configure the device? I mean things like setting the clock right. -aw

awik32 avatar Dec 13 '20 09:12 awik32

Hi Albert

Cool, I've added the Loop 2 to the README, thanks for reporting back!

The README.md claims: "The device path is currently not auto-detected and should be specified ...". On my system (Linux Mint 19.3) it seems to be auto-detected just fine.

Yes, unless you have other USB ACM devices plugged in, the default device path should be good on current Linux distribs.

./polar_physdata2txt:38:in output_txt': undefined method value' for nil:NilClass (NoMethodError)

Fixed

Is there a way to use these scripts to configure the device? I mean things like setting the clock right.

This should be technically possible, there's a PbPFtpQuery message that can get/set system & local times. I have never tried, though.

cmaion avatar Dec 13 '20 14:12 cmaion

Thanks, the physdata script is working now. There are some items in it that are not accurate for me, eg. the resting heart rate and weight. If I edit the output text file, is there a way to get the changes onto the device?

there's a PbPFtpQuery message that can get/set system & local times. I have never tried, though.

How would I go about testing it?

-aw

awik32 avatar Dec 13 '20 14:12 awik32

Thanks, the physdata script is working now. There are some items in it that are not accurate for me, eg. the resting heart rate and weight. If I edit the output text file, is there a way to get the changes onto the device?

Technically, there should be a way. I would guess that a new PHYSDATA.BPB should be constructed with the new values (not super hard, this is a standard protobuf file and we know it's structure), and possibly uploaded it to the watch as /U/0/S/PHYSDATA.BPB (to be verified with what the Polar apps are actually doing).

I didn't implement the FTP upload part as I don't need it. If someone is willing to take a shot at it, that might not be ultra hard for the adventurous one (by reverse engineenering the USB protocol with wireshark -- as I already did the download side, I would guess that the upload side should be quite close).

there's a PbPFtpQuery message that can get/set system & local times. I have never tried, though.

How would I go about testing it?

Someone would have to implement it ;) (same story here, reverse engineering might be needed to ensure that it's properly done).

cmaion avatar Dec 14 '20 09:12 cmaion

Darned. I'm not a Ruby programmer (and Perl is first on my learning list). I was hoping to be able to use only Linux, but it seems I shall have to resort to my old Windows 7 install, which I have happily left behind, except for running iTunes occasionally to sync my iPod. I've been able to run it as a virtual machine for that purpose; hopefully the same is true of the Polar application.

-aw

awik32 avatar Dec 14 '20 11:12 awik32

Compared to Perl, Ruby would be much simpler to get into ;)

cmaion avatar Dec 14 '20 14:12 cmaion

With reference to: https://github.com/cmaion/polar/issues/30

No need to open a new issue.

You closed the previous issue about this problem: https://github.com/cmaion/polar/issues/27.

I did not know you wanted me to put it here...

As I said, could well be a USB cable/connection problem.

I've never had problems with that so far. It works with the Polar app in VMware. While that has failed on one occasion, I did not have to disconnect/reconnect the cable to resolve it.

Recovery from aborted transfer is not bullet proof as I don't have access to the protocol specs.

That's a real pity. Do they (Polar) consider it a trade-secret or something? They should be interested in Linux customers, especially as Linux is becoming more and more of an alternative on the desktop/laptop. Polar and Apple (iTunes) are the main troublemakers in my experience since switching to Linux in December 2019.

I guess that retrying a few times to empty buffers / unplugging&plugging the USB cable may solve your issue.

Right. After having charged and disconnected the device and worn it for some time, I tried again and it worked.

You said:

OK maybe the watch was in an unexpected/specific state left by Polar Flow.

Tomorrow, I'm going to try syncing with your polar_ftp first, before I do it with the Polar FlowSync.

-aw

awik32 avatar Jan 11 '21 16:01 awik32

Syncing using polar_ftp before Polar FlowSync has worked well from the point of my previous message (above) until today.

Today I got the following errors:

$ ./polar_ftp SYNC
Connected to Polar Loop 2 serial XXXXXXXX
Synchronizing to '/home/aw/Polar/XXXXXXXX'
Listing content of '/'
Listing content of '/SYS/'
Traceback (most recent call last):
	13: from ./polar_ftp:64:in `<main>'
	12: from /home/aw/src/polar/lib/polar_ftp.rb:125:in `sync'
	11: from /home/aw/src/polar/lib/polar_ftp.rb:72:in `recurse'
	10: from /home/aw/src/polar/lib/polar_ftp.rb:72:in `each'
	 9: from /home/aw/src/polar/lib/polar_ftp.rb:75:in `block in recurse'
	 8: from /home/aw/src/polar/lib/polar_ftp.rb:71:in `recurse'
	 7: from /home/aw/src/polar/lib/polar_ftp.rb:33:in `dir'
	 6: from /home/aw/src/polar/lib/polar_usb_hid.rb:37:in `request'
	 5: from /home/aw/src/polar/lib/polar_usb_hid.rb:45:in `read'
	 4: from /home/aw/src/polar/lib/polar_usb_hid.rb:45:in `loop'
	 3: from /home/aw/src/polar/lib/polar_usb_hid.rb:46:in `block in read'
	 2: from /home/aw/src/polar/lib/polar_usb_hid.rb:110:in `usb_read'
	 1: from /var/lib/gems/2.5.0/gems/libusb-0.6.4-x86_64-linux/lib/libusb/dev_handle.rb:465:in `interrupt_transfer'
/var/lib/gems/2.5.0/gems/libusb-0.6.4-x86_64-linux/lib/libusb/dev_handle.rb:549:in `submit_transfer': error TRANSFER_ERROR (LIBUSB::ERROR_IO)
$ ./polar_ftp SYNC
Connected to Polar Loop 2 serial XXXXXXXX
Synchronizing to '/home/aw/Polar/XXXXXXXX'
Listing content of '/'
Traceback (most recent call last):
	7: from ./polar_ftp:64:in `<main>'
	6: from /home/aw/src/polar/lib/polar_ftp.rb:125:in `sync'
	5: from /home/aw/src/polar/lib/polar_ftp.rb:71:in `recurse'
	4: from /home/aw/src/polar/lib/polar_ftp.rb:33:in `dir'
	3: from /home/aw/src/polar/lib/polar_usb_hid.rb:37:in `request'
	2: from /home/aw/src/polar/lib/polar_usb_hid.rb:45:in `read'
	1: from /home/aw/src/polar/lib/polar_usb_hid.rb:45:in `loop'
/home/aw/src/polar/lib/polar_usb_hid.rb:74:in `block in read': Expecting packet number 1, got 0 (PolarUsb::PolarUsbProtocolError)
PACKET: 11 f9 0 0 0 a 4f a b 4a 4f 55 52 4e 41 4c 2e 44 41 54 10 80 50 1a 13 a 7 8 e4 f 10 4 18 10 12 6 8 d 10 17 18 e 18 0 22 13 a 7 8 e4 f 10 4 18 10 12 6 8 d 10 17 18 e 18
$ ./polar_ftp SYNC
Connected to Polar Loop 2 serial XXXXXXXX
Synchronizing to '/home/aw/Polar/XXXXXXXX'
Listing content of '/'
Traceback (most recent call last):
	10: from ./polar_ftp:64:in `<main>'
	 9: from /home/aw/src/polar/lib/polar_ftp.rb:125:in `sync'
	 8: from /home/aw/src/polar/lib/polar_ftp.rb:71:in `recurse'
	 7: from /home/aw/src/polar/lib/polar_ftp.rb:33:in `dir'
	 6: from /home/aw/src/polar/lib/polar_usb_hid.rb:37:in `request'
	 5: from /home/aw/src/polar/lib/polar_usb_hid.rb:45:in `read'
	 4: from /home/aw/src/polar/lib/polar_usb_hid.rb:45:in `loop'
	 3: from /home/aw/src/polar/lib/polar_usb_hid.rb:46:in `block in read'
	 2: from /home/aw/src/polar/lib/polar_usb_hid.rb:110:in `usb_read'
	 1: from /var/lib/gems/2.5.0/gems/libusb-0.6.4-x86_64-linux/lib/libusb/dev_handle.rb:465:in `interrupt_transfer'
/var/lib/gems/2.5.0/gems/libusb-0.6.4-x86_64-linux/lib/libusb/dev_handle.rb:549:in `submit_transfer': error TRANSFER_ERROR (LIBUSB::ERROR_IO)

Then, after syncing with Polar FlowSync and then trying polar_ftp again, everything works just fine again.

-Albert.

awik32 avatar Jan 25 '21 15:01 awik32