Commit bdabdf28 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Improve calibrator error handling

parent fe853aa5
...@@ -112,9 +112,11 @@ class ChinaIO: ...@@ -112,9 +112,11 @@ class ChinaIO:
analogIn = self.io.analogIn() analogIn = self.io.analogIn()
analogOut = self.io.analogOut() analogOut = self.io.analogOut()
if len(analogIn) != 4: 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: 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(): for i,c in analogIn.items():
if c.bits != 18: if c.bits != 18:
raise Exception('analogIn[%d] is not 18 bit (%d)' % (i, c.bits)) raise Exception('analogIn[%d] is not 18 bit (%d)' % (i, c.bits))
......
...@@ -80,20 +80,25 @@ class SerialIOConfig: ...@@ -80,20 +80,25 @@ class SerialIOConfig:
self.cond = threading.Condition() self.cond = threading.Condition()
pass pass
def getConfig(self, what):
if what in self.config:
return self.config[what]
return []
def digitalIn(self): def digitalIn(self):
return self.config[DigitalIn] return self.getConfig(DigitalIn)
def digitalOut(self): def digitalOut(self):
return self.config[DigitalOut] return self.getConfig(DigitalOut)
def analogIn(self): def analogIn(self):
return self.config[AnalogIn] return self.getConfig(AnalogIn)
def analogOut(self): def analogOut(self):
return self.config[AnalogOut] return self.getConfig(AnalogOut)
def counter(self): def counter(self):
return self.config[Counter] return self.getConfig(Counter)
def __str__(self): def __str__(self):
return "%s" % self.config return "%s" % self.config
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment