From 6fd147a38081eadf8b730726391e885f6177e963 Mon Sep 17 00:00:00 2001 From: travisutk Date: Thu, 8 Jul 2010 21:00:41 +0000 Subject: [PATCH] Neighbor count. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@678 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/GoodFETEM260.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/client/GoodFETEM260.py b/client/GoodFETEM260.py index 6bfb1ed..6a0286f 100644 --- a/client/GoodFETEM260.py +++ b/client/GoodFETEM260.py @@ -56,10 +56,10 @@ class GoodFETEM260(GoodFETSPI): self.seq&0xFF,0x00, ]+frame+[ 0xA7]); - #s="EZSP< "; - #for foo in data: - # s=s+"%02x " % ord(foo); - #print s; + s="EZSP< "; + for foo in data: + s=s+"%02x " % ord(foo); + print s; if ord(data[0])!=0xFE: print "EZSP error: 0x%02x" % ord(data[0]); @@ -83,14 +83,14 @@ class GoodFETEM260(GoodFETSPI): self.EZSPtrans([0x46,adr&0xFF,1,val&0xFF]); return val; def rand16(self): - """Read a byte from the given address.""" + """Read a random 16-bit word.""" data=self.EZSPtrans([0x49]); if data==None: print "Insufficient random data."; return 0; return ord(data[6])+(ord(data[7])<<8); - + def info(self): """Read the info bytes.""" print "Ember EM26 Z-Stack SPI Module."; @@ -98,6 +98,9 @@ class GoodFETEM260(GoodFETSPI): status=self.EM260spistatus(); print "Version: %i" % (version); print "Status: %s" % (["dead","alive"][status]); + print "" + print "Node ID: %04x" % (self.getNodeID()); + print "Connected to %2i neighbors." % self.neighborCount(); def EM260spiversion(self): """Read the SPI version number from EM260.""" data=self.EM260trans([0x0A,0xA7]); @@ -125,3 +128,18 @@ class GoodFETEM260(GoodFETSPI): print "Status misread."; return 0; return status&1; + + #Everything after here is ZigBee. + + def getNodeID(self): + """Read the EZSP node id.""" + + data=self.EZSPtrans([0x27]); + return ord(data[5])+(ord(data[6])<<8); + def neighborCount(self): + """Read the count of neighbors, used for iterating the neighbor table.""" + + data=self.EZSPtrans([0x7A]); + return ord(data[5]); + + -- 2.20.1