Beispiel #1
0
 def status(self):
     if self._value is None:
         raise MissingResponse()
     if self._value.error:
         return ["response received with framing error"]
     v = self._value[7:0]
     l = []
     for b in self.bits:
         if v & 0x01 and b:
             l.append(b)
         v = (v >> 1)
     return l
Beispiel #2
0
    def send(self, command, timeout=2000):
        self.backend.write(self.construct(command))
        frame = None
        backoff = 0.010

        if command.response is not None:
            for i in range(7):
                frame = self.extract(self.backend.read(timeout=timeout))
                if isinstance(frame, HassebDALIUSBNoAnswer):
                    self.backend.write(self.construct(command))
                if isinstance(frame, BackwardFrame):
                    if command.response:
                        return command.response(frame)
                    return frame
                backoff += backoff
                sleep(backoff)
            raise MissingResponse()
        return None
Beispiel #3
0
 def value(self):
     if self._value is None and self._expected:
         raise MissingResponse()
     if self._value and self._value.error and not self._error_acceptable:
         raise ResponseError()
     return self._value