示例#1
0
def LocateHW(self):
    global devTrainer, devAntDongle
    if debug.on(debug.Application): logfile.Write("Scan for hardware")

    #---------------------------------------------------------------------------
    # Get ANT dongle
    #---------------------------------------------------------------------------
    if not devAntDongle:
        devAntDongle, msg = ant.GetDongle()
        SetDongleMsg(self, msg)

    #---------------------------------------------------------------------------
    # Get Trainer and find trainer model for Windows and Linux
    #---------------------------------------------------------------------------
    if debug.on(debug.Application): logfile.Write("Get USB trainer")
    if not devTrainer:
        if clv.SimulateTrainer:
            SetTacxMsg(self, "Simulated Trainer")
        else:
            devTrainer = usbTrainer.GetTrainer()
            if not devTrainer:
                SetTacxMsg(self, "Trainer not detected")
            else:
                SetTacxMsg(self, "Trainer detected")
                usbTrainer.InitialiseTrainer(devTrainer)  #initialise trainer

    #---------------------------------------------------------------------------
    # Done
    #---------------------------------------------------------------------------
    if debug.on(debug.Application): logfile.Write("Scan for hardware - end")
    if devAntDongle and (clv.SimulateTrainer or devTrainer):
        return True
    else:
        return False
示例#2
0
# ------------------------------------------------------------------------------
ant.EnumerateAll()

# ------------------------------------------------------------------------------
# Open dongle; either the defined one or default
#
# Note, it does not matter which dongle you open.
# The dongle itself means a connection to the ANT+ network
# Each application starting can use any ANT+ dongle
# ------------------------------------------------------------------------------
if clv.dongle > 0:
    p = clv.dongle  # Specified on command line
else:
    p = None  # Take the default

devAntDongle, msg = ant.GetDongle(p)
logfile.Console(msg)

if devAntDongle and not clv.SimulateTrainer:
    #---------------------------------------------------------------------------
    # We are going to look what MASTER devices there are
    #---------------------------------------------------------------------------
    logfile.Console(
        "ExplorANT: We're in slave mode, listening to master ANT+ devices")

    #---------------------------------------------------------------------------
    # Initialize dongle
    #---------------------------------------------------------------------------
    ant.Calibrate(devAntDongle)  # calibrate ANT+ dongle

    #---------------------------------------------------------------------------