cagnulein / qdomyos-zwift

Zwift bridge for smart treadmills and bike/cyclette
https://www.qzfitness.com/
GNU General Public License v3.0
420 stars 116 forks source link

[REQ] DIRCON Client #782

Open IProgrammedOnce opened 2 years ago

IProgrammedOnce commented 2 years ago

Useful to avoid using bluetooth and also for research.

IProgrammedOnce commented 2 years ago

Here is some capture data which I hope can help. A short 50 second workout of 10 seconds each of 100, 110, 120, 130, 140 watts using ERG. The watts did jump around a bit. The folder has serial capture and Wireshark capture of the dircon adapter .88 and the laptop .29

QuickTest1_capture.zip

cagnulein commented 2 years ago

debug-Tue__May_10_00_54_34_2022.log first qz log with serial on linux

cagnulein commented 2 years ago

"Current Speed: 24.37" "Current Cadence: 93" "Current Distance: 0.121908" "Current Watt: 95" "Current KCal: 3.30517" "Current CrankRevs: 8" "Last CrankEventTime: 64248"

In this line "02 68 50 0b 11 00 00 44 00 85 09 ba 00 5f 00 0f 03 02 68 50 13 08 00 00 34 00 5f 00 52 ca 9d 0d 00 00 bb 53 69 05 97 54 07 03" splittin to one "02 68 50 0b 11 00 00 44 00 85 09 ba 00 5f 00 0f 03"

Watt 95 so 0x5F, so it's the 13th and 14th byte

Tue. May 10 00:57:34 2022 1652169454347 Debug: serial RX: "02 68 50 0b 11 00 00 44 00 6e 0b c6 00 a0 01 64 03 02 68 50 13 08 00 00 34 00 a0 01 b0 ee c3 0d 00 00 9b ab 79 05 11 7c 07 03" Tue. May 10 00:57:34 2022 1652169454376 Debug: bluetooth.cpp void bluetooth::debug(const QString&) " << 44 00 6e 0b c6 00 a0 01" Tue. May 10 00:57:34 2022 1652169454377 Debug: bluetooth.cpp void bluetooth::debug(const QString&) "Current Speed: 29.26" Tue. May 10 00:57:34 2022 1652169454379 Debug: bluetooth.cpp void bluetooth::debug(const QString&) "Current Cadence: 99" Tue. May 10 00:57:34 2022 1652169454380 Debug: bluetooth.cpp void bluetooth::debug(const QString&) "Current Distance: 0.201498" Tue. May 10 00:57:34 2022 1652169454382 Debug: bluetooth.cpp void bluetooth::debug(const QString&) "Current Watt: 416" Tue. May 10 00:57:34 2022 1652169454384 Debug: bluetooth.cpp void bluetooth::debug(const QString&) "Current KCal: 6.76911" Tue. May 10 00:57:34 2022 1652169454385 Debug: bluetooth.cpp void bluetooth::debug(const QString&) "Current CrankRevs: 19" Tue. May 10 00:57:34 2022 1652169454386 Debug: bluetooth.cpp void bluetooth::debug(const QString&) "Last CrankEventTime: 5599"

02 68 50 0b 11 00 00 44 00 6e 0b c6 00 a0 01 64 03

wattage is right here 0x1a0 = 416 cadence could be the byte after 64 = 100 speed is 0xb6e = 2926 so 29.26

@IProgrammedOnce everything is very clear!!!

02 68 50 13 08 00 00 34 00 a0 01 b0 ee c3 0d 00 00 9b ab 79 05 11 7c 07 03

on this frame i don't know which other values are coming through

IProgrammedOnce commented 2 years ago

Some more log files. Hopefully the names explain.

On 2 I was still wearing my HRM belt and had it in use on Zwift but disabled it in QZ.

On 2 I had real dircon selected in Zwift for all categories except HRM.

On 1 I had only cadence for real dircon so that the dircon serial data would be active. Hopefully it is all or nothing and it doesn't send just cadence but that will be interesting to see as well. Power and Controllable were QZdircon.

Hopefully this will allow some compatibility. debug_notWearingHRM_PwrCntrlCadenceRealDircon.zip debug_noHRMQZ_PwrCntrQZdir_CadenceRealDircon.zip debug_noHRMQZ_PwrCntrCadenceRealDircon.zip

cagnulein commented 2 years ago

debug-Tue__May_10_22_04_18_2022.zip first session with parser! watt and speed both work, cadence is wrong

cagnulein commented 2 years ago

cadence fixed @IProgrammedOnce :)

cagnulein commented 2 years ago

Serial TO KICKR debug-Tue__May_10_22_13_30_2022.zip

cagnulein commented 2 years ago

debug-RS232_Wed__May_11_22_10_35_2022.zip serial from and to KICKR

cagnulein commented 2 years ago

CapturePluggingInKickrAlreadyZwiftPaired.txt

IProgrammedOnce commented 2 years ago

And another capture for comparison. Seems like a bit more junk (or is it not junk.....) before it settled down CapturePluggingInKickrNoZwift.txt

IProgrammedOnce commented 2 years ago

Some more captures and log files. I had both the data analyzer which can record and time stamp the bidirectional traffic and the serial adapter connected. This allows recording the data before QZ is online and there should be matching data in both the analyzer log and the debug log.

Without understanding how QZ is set up right now and just from looking at the data, it almost appears that QZ is like a telemarketer. The phone rings and the speech starts with no interaction. You (Kickr) keeps saying "Excuse me, excuse me" but the scripted conversation continues. Looking at the captures above there is interaction and possibly response in kind from the moment there is power up. Some of the TX RX pairs have the same time stamp so appear to be instantly returned unless they are that accurately timed at the same moment.

I am recording at 500kS/S so the resolution should be very good.

KickrPowered_StartQZ_serial.txt QZrunningPowerupKickr_Serial.txt

IProgrammedOnce commented 2 years ago

For whatever reason Github would not let me add these files to the above post so here are the matching QZ debug logs. The captures should contain the same data but not from the same start moment so some alignment will be required.

KickrPowered_StartQZ_serial.zip QZrunningPowerupKickr_Serial.zip

IProgrammedOnce commented 2 years ago

New build. [Uploading debug-Wed__May_18_13_58_21_2022.zip…]()

IProgrammedOnce commented 2 years ago

As Github will not let me add another file by editing the above post from a different computer here is the matching capture. May_18_13_58_21_Capture.txt

IProgrammedOnce commented 2 years ago

Debug file to match above capture.

debug-Wed__May_18_13_58_21_2022.zip

cagnulein commented 2 years ago

@IProgrammedOnce checking this https://github.com/cagnulein/qdomyos-zwift/issues/782#issuecomment-1128596707 that i'm using as a reference, i see that in the very begininning there is a handshake

FromKickr   data    3.509428    82uS        0x02    
FromKickr   data    3.509524    82uS        0x01    
FromKickr   data    3.509618    82uS        0x01    
FromKickr   data    3.509714    82uS        0x00    
FromKickr   data    3.509808    82uS        0x00    
FromKickr   data    3.509902    82uS        0x03    
To__Kickr   data    3.51013     82uS        0x02    
To__Kickr   data    3.510224    82uS        0x01    
To__Kickr   data    3.51032     82uS        0x01    
To__Kickr   data    3.510414    82uS        0x00    
To__Kickr   data    3.510508    82uS        0x00    
To__Kickr   data    3.510604    82uS        0x03    
FromKickr   data    3.510902    82uS        0x02    
FromKickr   data    3.510988    82uS        0x01    
FromKickr   data    3.511082    82uS        0x10    
FromKickr   data    3.511176    82uS        0x03    
FromKickr   data    3.511272    82uS        0x00    
FromKickr   data    3.511366    82uS        0x10    
FromKickr   data    3.51146     82uS        0x02    
FromKickr   data    3.511556    82uS        0x03    

it's very clear to me that to the 020101000003 must be the same answer from the other side. Infact, looking to the last log https://github.com/cagnulein/qdomyos-zwift/issues/782#issuecomment-1130551827 ,

To__Kickr   data    5.508466    82uS        0x02
To__Kickr   data    5.508554    82uS        0x01
To__Kickr   data    5.50864     82uS        0x01
To__Kickr   data    5.508728    82uS        0x00
To__Kickr   data    5.508814    82uS        0x00
To__Kickr   data    5.5089      82uS        0x03
FromKickr   data    5.575222    82uS        0x02
FromKickr   data    5.575316    82uS        0x01
FromKickr   data    5.575412    82uS        0x01
FromKickr   data    5.575506    82uS        0x00
FromKickr   data    5.5756      82uS        0x00
FromKickr   data    5.575696    82uS        0x03
To__Kickr   data    5.5905      82uS        0x02
To__Kickr   data    5.590586    82uS        0x01
To__Kickr   data    5.590672    82uS        0x01
To__Kickr   data    5.59076     82uS        0x00
To__Kickr   data    5.590846    82uS        0x00
To__Kickr   data    5.590932    82uS        0x03

the only main difference is the timing. The native DIRCON is answering in 0.01s Maybe this is the root cause? What do you think?

IProgrammedOnce commented 2 years ago

Actually it is about 0.0002s wow.

So I decided to do some captures of the handshake between Kickr and Dircon. It occurred to me that maybe I was not capturing it the same way as QZ is implementing. With QZ the Kickr is on, then when QZ runs it tries to connect. So this time I had the Kickr plugged in and then while capturing plugged the dircon into the kickr. It kind of looks like it might even send some programming or something by the length of some of the sends. KickrOn_PlugInDircon_1.txt KickrOn_PlugInDircon_2.txt KickrOn_PlugInDircon_3.txt KickrOn_PlugInDircon_4.txt

IProgrammedOnce commented 2 years ago

I realized all the previous ones were without ethernet. Not sure if it makes a difference.

KickrOn_PlugInDircon_5_Ethernet connected.txt

IProgrammedOnce commented 2 years ago

May20.txt

IProgrammedOnce commented 2 years ago

Debug file to match above capture.

debug-Fri__May_20_16_30_28_2022.zip

cagnulein commented 2 years ago

OMG @IProgrammedOnce I just had time now to check this log! It worked! So it was a matter of timing! We're close!

IProgrammedOnce commented 2 years ago

debug-Wed__May_25_00_29_45_2022.zip

IProgrammedOnce commented 2 years ago

debug-Wed__May_25_01_28_21_2022.zip

IProgrammedOnce commented 2 years ago

debug-Wed__May_25_01_48_19_2022.zip

cagnulein commented 2 years ago

ok perfect, i need to add other frames from the https://github.com/cagnulein/qdomyos-zwift/issues/782#issuecomment-1128596707

IProgrammedOnce commented 2 years ago

debug-Wed__May_25_02_25_44_2022.zip

cagnulein commented 2 years ago

thanks, pushed another one :) it's ready for your morning :D

IProgrammedOnce commented 2 years ago

debug-Wed__May_25_02_38_08_2022.zip

cagnulein commented 2 years ago

thanks, pushed another one https://github.com/cagnulein/qdomyos-zwift/commit/0216ce1170630327c8836ca89ad6ed96e224f212 i improved the init9 phase

IProgrammedOnce commented 2 years ago

debug-Wed__May_25_03_02_03_2022.zip

IProgrammedOnce commented 2 years ago

debug-Wed__May_25_03_08_15_2022.zip

cagnulein commented 2 years ago

thanks, pushed another one. but please don't follow me in my craziness, for me it's just a puzzle game so i can't stop it :D anyway i'm going to eat so i neet to stop it for 2h

IProgrammedOnce commented 2 years ago

debug-Wed__May_25_03_23_55_2022.zip

cagnulein commented 2 years ago

@IProgrammedOnce sorry for the delay. Fixed the issue https://github.com/cagnulein/qdomyos-zwift/commit/fa5677d550dfdbbf17113245ad15adb4e0276887 Pull it and build it when you have time Thanks!

IProgrammedOnce commented 2 years ago

debug-Fri__May_27_09_58_46_2022.zip

cagnulein commented 2 years ago

Ok another piece is ok, I need to fix the next one. Thanks

Il giorno ven 27 mag 2022 alle 19:03 IProgrammedOnce < @.***> ha scritto:

debug-Fri__May_27_09_58_46_2022.zip https://github.com/cagnulein/qdomyos-zwift/files/8788245/debug-Fri__May_27_09_58_46_2022.zip

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/qdomyos-zwift/issues/782#issuecomment-1139804479, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALYWA3XRBAGTK73QFIV2LVMD543ANCNFSM5UB4LOVQ . You are receiving this because you were assigned.Message ID: @.***>

-- Roberto Viola Software engineer and open source enthusiast http://robertoviola.cloud

cagnulein commented 2 years ago

@IProgrammedOnce sorry again for the delay. I fixed the run frame, I forgot a byte. Please pull it and try when you have time. Thanks

IProgrammedOnce commented 2 years ago

QZ did not wake the kickr. After a number of seconds I spun the cranks to wake it. debug-Tue__May_31_04_13_23_2022.zip

cagnulein commented 2 years ago

@IProgrammedOnce ok now the communication is perfect but probably i'm using a sniff as base that doesn't wake up the kickr? i'm using this one https://github.com/cagnulein/qdomyos-zwift/issues/782#issuecomment-1128596707

IProgrammedOnce commented 2 years ago

Only difference is I was pedaling. I went into settings and back out but the data screen did not appear. I was surprised when I came home to see the kickr did not go to sleep today. Bluetooth is flashing so it did not pair to QZ. debug-Tue__May_31_21_31_03_2022.zip

cagnulein commented 2 years ago

@IProgrammedOnce like the https://github.com/cagnulein/qdomyos-zwift/issues/782#issuecomment-1128596707 did you collect a log from kickr and dircon without QZ during a small ride? I guess we're missing this piece

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

cagnulein commented 2 years ago

@IProgrammedOnce when you will be ready to test it again let me know. No rush from my side!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

IProgrammedOnce commented 2 years ago

I think in the past when I did this capture it was before I figured out how to copy the text to Notepad++. The last ones were files that had to be opened in Logic.

Powerup_to_Riding_Capture.txt

cagnulein commented 2 years ago

thanks @IProgrammedOnce i will check this in the next days!

cagnulein commented 2 years ago

@IProgrammedOnce I didn't forget about this (it's that with the baby it's a crazy world). Check now this https://zwiftinsider.com/kickr-update-2022/

A dircon client it would be mandatory to talk with it I guess ;)

IProgrammedOnce commented 2 years ago

My road bike is off the trainer for summer anyway. Let me know if you need any data.

On Tue., Sep. 13, 2022, 05:54 Roberto Viola, @.***> wrote:

@IProgrammedOnce https://github.com/IProgrammedOnce I didn't forget about this (it's that with the baby it's a crazy world). Check now this https://zwiftinsider.com/kickr-update-2022/

A dircon client it would be mandatory to talk with it I guess ;)

— Reply to this email directly, view it on GitHub https://github.com/cagnulein/qdomyos-zwift/issues/782#issuecomment-1245372803, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYHL2AFDKMMRXDPVIQD3LTTV6B2RFANCNFSM5UB4LOVQ . You are receiving this because you were mentioned.Message ID: @.***>