Mercurial > ~darius > hgwebdir.cgi > ZigBee
diff zb.py @ 8:9f0808b13454
Use non-blocking serial access. Add __str__ method for RX packets.
author | darius@inchoate.localdomain |
---|---|
date | Sun, 04 Nov 2007 21:10:21 +1030 |
parents | 579dedf5a1f1 |
children | d147529ad2db |
line wrap: on
line diff
--- a/zb.py Thu Nov 01 16:32:17 2007 +1030 +++ b/zb.py Sun Nov 04 21:10:21 2007 +1030 @@ -70,6 +70,10 @@ PKT_DESC = "RX Packet: 16 bit address" ADDR_SIZE = 2 + def __str__(self): + return "0x%0*x (%ddBm) -> %s" % (self.ADDR_SIZE * 2, self.sender, + self.rssi, str(self.payload)) + def getsender(self): value = 0 for i, j in zip(reversed(range(self.ADDR_SIZE)), range(0, self.ADDR_SIZE * 8, 8)): @@ -292,7 +296,8 @@ s = serial.Serial(port='/dev/cuad0', baudrate=9600, bytesize=8, parity='N', \ stopbits=1, rtscts=0) -s.setTimeout(0.1) +# Non-blocking +s.timeout = 0 #s.write('+++') #s.readline(eol='\r')