Beispiel #1
0
 def test_read_command(self):
     buf = read_command(self.tmp)
     self.assertEquals(self.cmd1, buf)
     buf = read_command(self.tmp)
     self.assertEquals(self.cmd2, buf)
     buf = read_command(self.tmp)
     self.assertEquals(self.cmd3, buf)
     buf = read_command(self.tmp)
     self.assertIsNone(buf)
Beispiel #2
0
    def read_io(self):
        """
        Read from the IO.  Note that the INSTEON protocol is stateful, so we must
        keep track of stateful commands that we send, and then deal with that
        here.
        """
        logging.debug("Reading the interface of {0}.".format(self.name))
        buf = insteon_im_protocol.read_command(self.io_fd)

        if buf is not None:
            update_cmd = insteon_im_protocol.decode(buf)

            if not issubclass(type(update_cmd), im_commands.IMInsteonCommand):
                #If it's an im command, we should probably handle it

                frm = update_cmd.from_address
                update = InsteonIMUpdate(update_cmd, self.relative.get(frm, None))
                if update.relative is not None:
                    del self.relative[frm]

                self.update_model(hexlify(frm).decode(), update)