diff --git a/china_io-2019/python/calibrator.py b/china_io-2019/python/calibrator.py index dcd2be6b6919aa8823bcf7ca0ec252bb30c02059..51423c5770ef23ecacbcba47a7dcad864a9abdbc 100755 --- a/china_io-2019/python/calibrator.py +++ b/china_io-2019/python/calibrator.py @@ -112,9 +112,11 @@ class ChinaIO: analogIn = self.io.analogIn() analogOut = self.io.analogOut() if len(analogIn) != 4: - raise Exception('Did not find 4 analogIn channels') + raise Exception('Did not find 4 analogIn channels (%d)' % + (len(analogIn))) if len(analogOut) != 2: - raise Exception('Did not find 2 analogOut channels') + raise Exception('Did not find 2 analogOut channels (%d)' + (len(analogOut))) for i,c in analogIn.items(): if c.bits != 18: raise Exception('analogIn[%d] is not 18 bit (%d)' % (i, c.bits)) diff --git a/china_io-2019/python/serialio.py b/china_io-2019/python/serialio.py index c2ff52622f61b65055ce249a4c860a98eafe23da..b91007265a8ee9826270ccd5fdee927650502ad5 100644 --- a/china_io-2019/python/serialio.py +++ b/china_io-2019/python/serialio.py @@ -80,20 +80,25 @@ class SerialIOConfig: self.cond = threading.Condition() pass + def getConfig(self, what): + if what in self.config: + return self.config[what] + return [] + def digitalIn(self): - return self.config[DigitalIn] + return self.getConfig(DigitalIn) def digitalOut(self): - return self.config[DigitalOut] + return self.getConfig(DigitalOut) def analogIn(self): - return self.config[AnalogIn] + return self.getConfig(AnalogIn) def analogOut(self): - return self.config[AnalogOut] + return self.getConfig(AnalogOut) def counter(self): - return self.config[Counter] + return self.getConfig(Counter) def __str__(self): return "%s" % self.config