X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETEM260.py;h=68565060ec689984b7ddd55fad324a8b87fd0aae;hp=6a0286f82c02440f2d5c1f5f0e0607614b99c44e;hb=980462162e42727dcde1199284fa41a5a38136b0;hpb=6fd147a38081eadf8b730726391e885f6177e963 diff --git a/client/GoodFETEM260.py b/client/GoodFETEM260.py index 6a0286f..6856506 100644 --- a/client/GoodFETEM260.py +++ b/client/GoodFETEM260.py @@ -64,8 +64,8 @@ class GoodFETEM260(GoodFETSPI): if ord(data[0])!=0xFE: print "EZSP error: 0x%02x" % ord(data[0]); if ord(data[4])==0x58: - print "EZSP Invalid Command"; - return None; + print "EZSP Invalid Command because 0x%02x" % ord(data[5]); + return data; if frame[0]!=ord(data[4]): print "EZSP warning: Command 0x%02x returned type 0x%02x." % ( frame[0],ord(data[4])); @@ -99,6 +99,7 @@ class GoodFETEM260(GoodFETSPI): print "Version: %i" % (version); print "Status: %s" % (["dead","alive"][status]); print "" + self.setVersion(); print "Node ID: %04x" % (self.getNodeID()); print "Connected to %2i neighbors." % self.neighborCount(); def EM260spiversion(self): @@ -141,5 +142,22 @@ class GoodFETEM260(GoodFETSPI): data=self.EZSPtrans([0x7A]); return ord(data[5]); - - + def setRadioChannel(self,channel): + """Set the radio channel.""" + + data=self.EZSPtrans([0x9A, channel&xFF]); + return ord(data[5]); + def setVersion(self,version=2): + """Set the requested EZSP protocol version.""" + + data=self.EZSPtrans([0x00, version]); + newversion=ord(data[5]); + if version==newversion: + print "Version set." + print "Protocol %i, stack type %i, Stack Version 0x%02x%02x." % ( + newversion, + ord(data[6]), + ord(data[8]), + ord(data[7])); + else: + self.setVersion(newversion);