Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
exe build
  • Loading branch information
john-38787364 committed Oct 24, 2017
1 parent ad9c91a commit 4a6ba56
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
16 changes: 16 additions & 0 deletions .gitignore
@@ -0,0 +1,16 @@

*.pyc
build/antifier/antifier.exe.manifest
build/antifier/out00-Analysis.toc
build/antifier/out00-EXE.toc
build/antifier/out00-PKG.pkg
build/antifier/out00-PKG.toc
antifier.spec
build/antifier/out00-PYZ.pyz
build/antifier/out00-PYZ.toc
build/antifier/out00-Tree.toc
build/antifier/out01-Tree.toc
build/antifier/warnantifier.txt
build/antifier/xref-antifier.html
*.pyc
trainer.pyc
23 changes: 4 additions & 19 deletions ant.py
Expand Up @@ -153,36 +153,21 @@ def get_ant(debug):
dev_ant = usb.core.find(idVendor=0x0fcf, idProduct=ant_pid) #get ANT+ stick
dev_ant.set_configuration() #set active configuration
try:#check if in use
print "Trying to write to %s dongle" % ant_pid
if debug: print "Trying to write to %s dongle" % ant_pid
dev_ant.write(0x01, send)#probe with reset command
reply = read_ant(dev_ant)
matching = [s for s in reply if "a4016f" in s]#look for an ANT+ reply
if matching:
found_available_ant_stick = True
msg = "Using %s dongle" % dongles[ant_pid]
print msg
if debug: print msg
except usb.core.USBError:#cannot write to ANT dongle
print "ANT dongle in use"
if debug: print "ANT dongle in use"
found_available_ant_stick = False
except AttributeError:#could not find dongle
print "Could not find %s dongle" % ant_pid
if debug: print "Could not find %s dongle" % ant_pid
found_available_ant_stick = False

#if found_available_ant_stick == False:
#found_available_ant_stick = True
#try:
#dev_ant = usb.core.find(idVendor=0x0fcf, idProduct=0x1008) #get ANT+ stick (suunto)
#dev_ant.set_configuration() #set active configuration
#try:#check if in use
#dev_ant.write(0x01, send)# probe with reset command
#print "Using Suunto dongle..."
#except usb.core.USBError:
##print "Suunto Device is in use"
#found_available_ant_stick = False
#except AttributeError:
##print "No Suunto Device found"
#found_available_ant_stick = False

if found_available_ant_stick == False:
dev_ant = False

Expand Down
19 changes: 10 additions & 9 deletions antifier.py
Expand Up @@ -353,7 +353,7 @@ def Stop(self):
def ScanForHW(self):
global dev_trainer, dev_ant, simulatetrainer
#get ant stick
print "get ant stick"
if debug:print "get ant stick"
if not dev_ant:
dev_ant, msg = ant.get_ant(debug)
if not dev_ant:
Expand All @@ -363,7 +363,7 @@ def ScanForHW(self):


self.PowerFactorVariable.set(powerfactor)
print "get trainer"
if debug:print "get trainer"
#find trainer model for Windows and Linux
if not dev_trainer:
#find trainer
Expand All @@ -383,13 +383,13 @@ def Start(self):
def run():
global dev_ant, dev_trainer, simulatetrainer, switch

print "reset ant stick"
if debug:print "reset ant stick"
ant.antreset(dev_ant)#reset dongle
print "calibrate ant stick"
if debug:print "calibrate ant stick"
ant.calibrate(dev_ant)#calibrate ANT+ dongle
print "calibrate ant stick FE-C"
if debug:print "calibrate ant stick FE-C"
ant.master_channel_config(dev_ant)#calibrate ANT+ channel FE-C
print "calibrate ant stick HR"
if debug: print "calibrate ant stick HR"
ant.second_channel_config(dev_ant)#calibrate ANT+ channel HR


Expand All @@ -414,7 +414,9 @@ def run():
#[01] bits 0-3 inst power MSB bits 4-7 trainer status bit, [30] flags bit field
last_measured_time = time.time() * 1000
while switch == True:
print "Running", round(time.time() * 1000 - last_measured_time)
if eventcounter % 51 == 0:
ant.antreset(dev_ant)
if debug == True: print "Running", round(time.time() * 1000 - last_measured_time)
last_measured_time = time.time() * 1000
if eventcounter >= 256:
eventcounter = 0
Expand Down Expand Up @@ -465,8 +467,7 @@ def run():
hexspeed = hex(int(speed*1000*1000/3600))[2:].zfill(4)
newdata = '{0}{1}{2}{3}{4}'.format(newdata[:24], hexspeed[2:], ' ' , hexspeed[:2], newdata[29:]) # set speed
newdata = '{0}{1}{2}'.format(newdata[:36], ant.calc_checksum(newdata), newdata[38:])#recalculate checksum
if debug == True: print datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3],"FE DATA",newdata


else:#send specific trainer data
newdata = '{0}{1}{2}'.format('a4 09 4e 00 19 ', hex(eventcounter)[2:].zfill(2), ' 5a b0 47 1b 01 30 6d 00 00') # increment event count
if cadence >= 254:
Expand Down
Binary file added dist/antifier.exe
Binary file not shown.

0 comments on commit 4a6ba56

Please sign in to comment.