1
1
#-------------------------------------------------------------------------------
2
2
# Version info
3
3
#-------------------------------------------------------------------------------
4
- __version__ = "2021-04-13"
4
+ __version__ = "2021-12-02"
5
+ # 2021-12-02 default command line value for HRM was False, changed to None
6
+ # HRM=0 has another meaning than "HRM not specified"
7
+ # same applied to all other integer command-line variables
5
8
# 2021-04-13 added: mph
6
9
# 2021-04-13 If AntRequired and self.antDeviceID == -1, a message is given
7
10
# 2021-03-24 changed: command line help + validation
@@ -205,20 +208,20 @@ def __init__(self):
205
208
parser .add_argument ('-b' , dest = 'ble' , help = constants .help_b , required = False , action = 'store_true' )
206
209
else :
207
210
pass # If -b is requested but not available, then an error is appropriate
208
- parser .add_argument ('-B' , dest = 'DeviceNumberBase' , metavar = '0...65535' , help = constants .help_B , required = False , default = False , type = int )
209
- parser .add_argument ('-c' , dest = 'CalibrateRR' , metavar = '0...100' , help = constants .help_c , required = False , default = False , type = int )
211
+ parser .add_argument ('-B' , dest = 'DeviceNumberBase' , metavar = '0...65535' , help = constants .help_B , required = False , default = None , type = int )
212
+ parser .add_argument ('-c' , dest = 'CalibrateRR' , metavar = '0...100' , help = constants .help_c , required = False , default = None , type = int )
210
213
# parser.add_argument ('-C', dest='CtrlCommand', metavar='ANT+DeviceID', help=constants.help_C, required=False, default=False, type=int)
211
214
parser .add_argument ('-C' , dest = 'CtrlCommand' , metavar = 'ANT+DeviceID' , help = argparse .SUPPRESS , required = False , default = False , type = int )
212
- parser .add_argument ('-d' , dest = 'debug' , metavar = '0...255' , help = constants .help_d , required = False , default = False , type = int )
213
- parser .add_argument ('-D' , dest = 'antDeviceID' , metavar = 'USB-DeviceID' , help = constants .help_D , required = False , default = False , type = int )
215
+ parser .add_argument ('-d' , dest = 'debug' , metavar = '0...255' , help = constants .help_d , required = False , default = None , type = int )
216
+ parser .add_argument ('-D' , dest = 'antDeviceID' , metavar = 'USB-DeviceID' , help = constants .help_D , required = False , default = None , type = int )
214
217
parser .add_argument ('-e' , dest = 'homeTrainer' , help = constants .help_e , required = False , action = 'store_true' )
215
218
# -h help!!
216
219
if UseGui :
217
220
parser .add_argument ('-g' , dest = 'gui' , help = constants .help_g , required = False , action = 'store_true' )
218
221
else :
219
222
parser .add_argument ('-g' , dest = 'g_IgnoredIfDefined' , help = argparse .SUPPRESS , required = False , action = 'store_true' )
220
223
parser .add_argument ('-G' , dest = 'GradeAdjust' , metavar = '% / % / %' , help = constants .help_G , required = False , default = False )
221
- parser .add_argument ('-H' , dest = 'hrm' , metavar = 'ANT+DeviceID' , help = constants .help_H , required = False , default = False , type = int )
224
+ parser .add_argument ('-H' , dest = 'hrm' , metavar = 'ANT+DeviceID' , help = constants .help_H , required = False , default = None , type = int )
222
225
parser .add_argument ('-i' , dest = 'imperial' , help = constants .help_i , required = False , action = 'store_true' )
223
226
if UseGui or OnRaspberry :
224
227
parser .add_argument ('-l' , dest = 'StatusLeds' , help = constants .help_l , required = False , action = 'store_true' )
@@ -235,12 +238,12 @@ def __init__(self):
235
238
parser .add_argument ('-O' , dest = 'OutputDisplay' , metavar = 'see text' , help = constants .help_O , required = False , default = False )
236
239
else :
237
240
parser .add_argument ('-O' , dest = 'O_IgnoredIfDefined' , help = argparse .SUPPRESS , required = False , default = False )
238
- parser .add_argument ('-p' , dest = 'factor' , metavar = '%' , help = constants .help_p , required = False , default = False , type = int )
241
+ parser .add_argument ('-p' , dest = 'factor' , metavar = '%' , help = constants .help_p , required = False , default = None , type = int )
239
242
parser .add_argument ('-P' , dest = 'PowerMode' , help = constants .help_P , required = False , action = 'store_true' )
240
243
parser .add_argument ('-r' , dest = 'Resistance' , help = constants .help_r , required = False , action = 'store_true' )
241
244
parser .add_argument ('-R' , dest = 'Runoff' , metavar = 'see text' , help = constants .help_R , required = False , default = False )
242
245
parser .add_argument ('-s' , dest = 'simulate' , help = constants .help_s , required = False , action = 'store_true' )
243
- #scs parser.add_argument ('-S', dest='scs', metavar='ANT+ DeviceID',help=constants.help_S, required=False, default=False, type=int)
246
+ #scs parser.add_argument ('-S', dest='scs', metavar='ANT+ DeviceID',help=constants.help_S, required=False, default=None, type=int)
244
247
parser .add_argument ('-T' , dest = 'Transmission' , metavar = 'see text' , help = constants .help_T , required = False , default = False )
245
248
self .ant_tacx_models = ['Bushido' , 'Genius' , 'Vortex' , 'Magneticbrake' , 'Motorbrake' ]
246
249
parser .add_argument ('-t' , dest = 'TacxType' , help = constants .help_t , required = False , default = False , \
@@ -331,7 +334,7 @@ def __init__(self):
331
334
#-----------------------------------------------------------------------
332
335
# Get DeviceNumberBase
333
336
#-----------------------------------------------------------------------
334
- if self .args .DeviceNumberBase :
337
+ if self .args .DeviceNumberBase != None :
335
338
try :
336
339
self .DeviceNumberBase = int (self .args .DeviceNumberBase )
337
340
except :
@@ -342,7 +345,7 @@ def __init__(self):
342
345
# Not limitted to a range here, because can be different for different
343
346
# types of brakes, although initially only used for Magnetic Brake
344
347
#-----------------------------------------------------------------------
345
- if self .args .CalibrateRR :
348
+ if self .args .CalibrateRR != None :
346
349
try :
347
350
self .CalibrateRR = float (self .args .CalibrateRR .replace (',' , '.' ))
348
351
except :
@@ -434,7 +437,7 @@ def __init__(self):
434
437
#-----------------------------------------------------------------------
435
438
# Get debug-flags, used in debug module
436
439
#-----------------------------------------------------------------------
437
- if self .args .debug :
440
+ if self .args .debug != None :
438
441
try :
439
442
self .debug = int (self .args .debug )
440
443
except :
@@ -443,7 +446,7 @@ def __init__(self):
443
446
#-----------------------------------------------------------------------
444
447
# Get antDeviceID
445
448
#-----------------------------------------------------------------------
446
- if self .args .antDeviceID :
449
+ if self .args .antDeviceID != None :
447
450
try :
448
451
self .antDeviceID = int (self .args .antDeviceID )
449
452
except :
@@ -457,7 +460,10 @@ def __init__(self):
457
460
# - next: pair with the defined ANT+ HRM monitor
458
461
# the number can be found with ExplorANT
459
462
#-----------------------------------------------------------------------
460
- if self .args .hrm :
463
+ # 2021-12-02 False==0 and therefore False is a bad default if zero is
464
+ # a valid value. Therefore default changed to None
465
+ #-----------------------------------------------------------------------
466
+ if self .args .hrm != None :
461
467
try :
462
468
self .hrm = int (self .args .hrm )
463
469
except :
@@ -470,7 +476,7 @@ def __init__(self):
470
476
# - next: pair with the defined ANT+ SCS
471
477
# the number can be found with ExplorANT
472
478
#-----------------------------------------------------------------------
473
- #scs if self.args.scs:
479
+ #scs if self.args.scs != None :
474
480
#scs try:
475
481
#scs self.scs = int(self.args.scs)
476
482
#scs except:
@@ -479,7 +485,7 @@ def __init__(self):
479
485
#-----------------------------------------------------------------------
480
486
# Get powerfactor
481
487
#-----------------------------------------------------------------------
482
- if self .args .factor :
488
+ if self .args .factor != None :
483
489
try :
484
490
self .PowerFactor = int (self .args .factor ) / 100
485
491
# I would expect +/- 15% would be enough for compensation, but
@@ -650,48 +656,47 @@ def __init__(self):
650
656
def print (self ):
651
657
try :
652
658
v = self .debug # Verbose: print all command-line variables with values
653
- if self .autostart : logfile .Console ("-a" )
654
- if self .PedalStrokeAnalysis :logfile .Console ("-A" )
655
- if self .ble : logfile .Console ("-b" )
656
- if v or self .args .DeviceNumberBase : logfile .Console ("-B %s" % self .DeviceNumberBase )
657
- if v or self .args .CalibrateRR : logfile .Console ("-c %s" % self .CalibrateRR )
659
+ if self .autostart : logfile .Console ("-a" )
660
+ if self .PedalStrokeAnalysis : logfile .Console ("-A" )
661
+ if self .ble : logfile .Console ("-b" )
662
+ if v or self .args .DeviceNumberBase != None : logfile .Console ("-B %s" % self .DeviceNumberBase )
663
+ if v or self .args .CalibrateRR != None : logfile .Console ("-c %s" % self .CalibrateRR )
658
664
if v or self .CTRL_SerialL or self .CTRL_SerialR :
659
665
logfile .Console ("-C %s/%s" % (self .CTRL_SerialL , self .CTRL_SerialR ) )
660
- if v or self .args .debug : logfile .Console ("-d %s (%s)" % (self .debug , bin (self .debug ) ) )
661
- if v or self .args .antDeviceID : logfile .Console ("-D %s" % self .antDeviceID )
666
+ if v or self .args .debug != None : logfile .Console ("-d %s (%s)" % (self .debug , bin (self .debug ) ) )
667
+ if v or self .args .antDeviceID != None : logfile .Console ("-D %s" % self .antDeviceID )
662
668
if v or self .args .GradeAdjust :
663
- if self .GradeAdjust == 1 : logfile .Console ("-G defines Grade = antGrade * %s" \
664
- % (self .GradeFactor ) )
665
- if self .GradeAdjust == 2 : logfile .Console ("-G defines Grade = antGrade * %s [* %s (downhill)]" \
666
- % (self .GradeFactor , self .GradeFactorDH ) )
667
- if self .GradeAdjust == 3 : logfile .Console ("-G defines Grade = (antGrade - %s) * %s [* %s (downhill)]" \
668
- % (self .GradeShift , self .GradeFactor , self .GradeFactorDH ) )
669
- if self .gui : logfile .Console ("-g" )
670
- if self .homeTrainer : logfile .Console ("-e" )
671
- if v or self .args .hrm : logfile .Console ("-H %s" % self .hrm )
672
- if self .StatusLeds : logfile .Console ("-l" )
669
+ if self .GradeAdjust == 1 : logfile .Console ("-G defines Grade = antGrade * %s" \
670
+ % (self .GradeFactor ) )
671
+ if self .GradeAdjust == 2 : logfile .Console ("-G defines Grade = antGrade * %s [* %s (downhill)]" \
672
+ % (self .GradeFactor , self .GradeFactorDH ) )
673
+ if self .GradeAdjust == 3 : logfile .Console ("-G defines Grade = (antGrade - %s) * %s [* %s (downhill)]" \
674
+ % (self .GradeShift , self .GradeFactor , self .GradeFactorDH ) )
675
+ if self .gui : logfile .Console ("-g" )
676
+ if self .homeTrainer : logfile .Console ("-e" )
677
+ if v or self .args .hrm != None : logfile .Console ("-H %s" % self .hrm )
678
+ if self .StatusLeds : logfile .Console ("-l" )
673
679
if OnRaspberry and (v or self .args .gpioLayout ):
674
680
logfile .Console ("-L %s/%s/%s/%s/%s/%s" % (self .rpiButton , self .rpiTacx , self .rpiShutdown , self .rpiCadence , self .rpiBLE , self .rpiANT ) )
675
- if self .manual : logfile .Console ("-m" )
676
- if self .manualGrade : logfile .Console ("-M" )
677
- if self .imperial : logfile .Console ("-i" )
678
- if not self .args .calibrate : logfile .Console ("-n" )
679
- if v or self .args .factor : logfile .Console ("-p %s" % self .PowerFactor )
680
- if v or self .args .OutputDisplay : logfile .Console ("-O %s" % self .OutputDisplay )
681
- if self .args .PowerMode : logfile .Console ("-P" )
682
- if self .args .Resistance : logfile .Console ("-r" )
683
- if v or self .args .Runoff : logfile .Console ("-R defines Runoff: maxSpeed=%s dip=%s minSpeed=%s targetTime=%s power=%s" % \
681
+ if self .manual : logfile .Console ("-m" )
682
+ if self .manualGrade : logfile .Console ("-M" )
683
+ if self .imperial : logfile .Console ("-i" )
684
+ if not self .args .calibrate : logfile .Console ("-n" )
685
+ if v or self .args .factor != None : logfile .Console ("-p %s" % self .PowerFactor )
686
+ if v or self .args .OutputDisplay : logfile .Console ("-O %s" % self .OutputDisplay )
687
+ if self .args .PowerMode : logfile .Console ("-P" )
688
+ if self .args .Resistance : logfile .Console ("-r" )
689
+ if v or self .args .Runoff : logfile .Console ("-R defines Runoff: maxSpeed=%s dip=%s minSpeed=%s targetTime=%s power=%s" % \
684
690
(self .RunoffMaxSpeed , self .RunoffDip , self .RunoffMinSpeed , self .RunoffTime , self .RunoffPower ) )
685
- if self .args .simulate : logfile .Console ("-s" )
686
- #scs if v or self.args.scs: logfile.Console("-S %s" % self.scs )
687
- if v or self .args .TacxType : logfile .Console ("-t %s" % self .TacxType )
688
- # if v or self.args.Transmission != constants.Transmission:
691
+ if self .args .simulate : logfile .Console ("-s" )
692
+ #scs if v or self.args.scs != None: logfile.Console("-S %s" % self.scs )
693
+ if v or self .args .TacxType : logfile .Console ("-t %s" % self .TacxType )
689
694
if v or self .args .Transmission :
690
- logfile .Console ('-T %s x %s (start=%sx%s)' % \
695
+ logfile .Console ('-T %s x %s (start=%sx%s)' % \
691
696
(self .Cranckset , self .Cassette , \
692
697
self .Cranckset [self .CrancksetStart ], \
693
698
self .Cassette [self .CassetteStart ]) )
694
- if self .exportTCX : logfile .Console ("-x" )
699
+ if self .exportTCX : logfile .Console ("-x" )
695
700
696
701
except :
697
702
pass # May occur when incorrect command line parameters, error already given before
0 commit comments