From 68b3ba0e68376630d0ce37c80048b3c107661007 Mon Sep 17 00:00:00 2001 From: travisutk Date: Thu, 8 Jul 2010 15:31:13 +0000 Subject: [PATCH] Reading status works. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@667 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/GoodFETEM260.py | 25 ++++++++++++++++--------- client/goodfet.em260 | 4 ++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/client/GoodFETEM260.py b/client/GoodFETEM260.py index b41d76f..7bc51ac 100644 --- a/client/GoodFETEM260.py +++ b/client/GoodFETEM260.py @@ -58,7 +58,9 @@ class GoodFETEM260(GoodFETSPI): def info(self): """Read the info bytes.""" version=self.EM260spiversion(); - print "Version %2i" % (version &0x7F); + status=self.EM260spistatus(); + print "Version: %i" % (version); + print "Status: %s" % (["dead","alive"][status]); def EM260spiversion(self): """Read the SPI version number from EM260.""" data=self.EM260trans([0x0A,0xA7]); @@ -71,13 +73,18 @@ class GoodFETEM260(GoodFETSPI): if not version&0x80: print "Version misread."; return 0; - return version; + return version&0x7F; def EM260spistatus(self): - """Read the info bytes.""" - data=self.EM260trans([0x0B,0xA7]); - s=""; - for foo in data: - s=s+"%02x " % ord(foo); - print s; - + """Read the status bit.""" + data=self.EM260trans([0x0B,0xA7]); + status=ord(data[0]); + + if status==0x00: + return self.EM260spistatus(); + if status==0x02: + return self.EM260spistatus(); + if not status&0xC0: + print "Status misread."; + return 0; + return status&1; diff --git a/client/goodfet.em260 b/client/goodfet.em260 index 2cf5527..bc9454e 100755 --- a/client/goodfet.em260 +++ b/client/goodfet.em260 @@ -36,9 +36,9 @@ client.SPIsetup(); if(sys.argv[1]=="info"): client.info(); - client.info(); - client.info(); if(sys.argv[1]=="test"): + print "Grabbing info three times." + client.info(); client.info(); client.info(); if(sys.argv[1]=="dump"): -- 2.20.1