From 3ddc9f638c3ed78fd65617a78d68ffa22eab6623 Mon Sep 17 00:00:00 2001 From: Julien Pfefferkorn Date: Sat, 29 Feb 2020 15:14:06 +0100 Subject: [PATCH] Issue #21 - Init msg only with new protocol Fixes #21 Only send an initialization message to the trainer device, if it talks using the new protocol. --- pythoncode/FortiusAnt.py | 3 --- pythoncode/usbTrainer.py | 23 +++++++++++------------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/pythoncode/FortiusAnt.py b/pythoncode/FortiusAnt.py index e05db5f2..852d871b 100644 --- a/pythoncode/FortiusAnt.py +++ b/pythoncode/FortiusAnt.py @@ -269,9 +269,6 @@ def LocateHW(self): else: devTrainer, msg = usbTrainer.GetTrainer() SetTacxMsg(self, msg) - if devTrainer: - SetTacxMsg(self, msg) - usbTrainer.InitialiseTrainer(devTrainer) #initialise trainer #--------------------------------------------------------------------------- # Done diff --git a/pythoncode/usbTrainer.py b/pythoncode/usbTrainer.py index cb932f80..ab6b2a95 100644 --- a/pythoncode/usbTrainer.py +++ b/pythoncode/usbTrainer.py @@ -465,24 +465,23 @@ def GetTrainer(): if dev != False: dev.set_configuration() if trainer_type == tt_iMagic: dev.set_interface_altsetting(0, 1) + + #------------------------------------------------------------------------------- + # I n i t i a l i s e T r a i n e r + # will not read cadence until initialisation byte is sent + #------------------------------------------------------------------------------- + if dev != False && LegacyProtocol == False: + data = struct.pack (sc.unsigned_int, 0x00000002) + if debug.on(debug.Data2): + logfile.Write ("InitialiseTrainer data=%s (len=%s)" % (logfile.HexSpace(data), len(data))) + dev.write(0x02,data) + #--------------------------------------------------------------------------- # Done #--------------------------------------------------------------------------- logfile.Write(msg) if debug.on(debug.Function):logfile.Write ("GetTrainer() returns, trainertype=" + hex(trainer_type)) return dev, msg - -#------------------------------------------------------------------------------- -# I n i t i a l i s e T r a i n e r -#------------------------------------------------------------------------------- -def InitialiseTrainer(dev): - # will not read cadence until initialisation byte is sent - data = struct.pack (sc.unsigned_int, 0x00000002) - - if debug.on(debug.Data2): - logfile.Write ("InitialiseTrainer data=%s (len=%s)" % (logfile.HexSpace(data), len(data))) - - dev.write(0x02,data) #------------------------------------------------------------------------------- # S e n d T o T r a i n e r