Support for debugging strings, closer to a clean MSP430X2 implementation.
[goodfet] / client / GoodFET.py
index 5645f52..abfc16e 100755 (executable)
@@ -60,14 +60,26 @@ class GoodFET:
         self.readcmd(blocks);  #Uncomment this later, to ensure a response.
     def readcmd(self,blocks=1):
         """Read a reply from the GoodFET."""
         self.readcmd(blocks);  #Uncomment this later, to ensure a response.
     def readcmd(self,blocks=1):
         """Read a reply from the GoodFET."""
-        self.app=ord(self.serialport.read(1));
-        self.verb=ord(self.serialport.read(1));
-        self.count=ord(self.serialport.read(1));
-        self.data=self.serialport.read(self.count*blocks);
-        #print "READ %02x %02x %02x " % (self.app, self.verb, self.count);
-        return self.data;
+        while 1:
+            self.app=ord(self.serialport.read(1));
+            self.verb=ord(self.serialport.read(1));
+            self.count=ord(self.serialport.read(1));
+            self.data=self.serialport.read(self.count*blocks);
+            #print "READ %02x %02x %02x " % (self.app, self.verb, self.count);
+            
+            #Debugging string; print, but wait.
+            if self.app==0xFF and self.verb==0xFF:
+                print "DEBUG %s" % self.data;
+            else:
+                return self.data;
         
     #Monitor stuff
         
     #Monitor stuff
+    def out(self,byte):
+        """Write a byte to P5OUT."""
+        self.writecmd(0,0xA1,1,[byte]);
+    def dir(self,byte):
+        """Write a byte to P5DIR."""
+        self.writecmd(0,0xA0,1,[byte]);
     def peekbyte(self,address):
         """Read a byte of memory from the monitor."""
         self.data=[address&0xff,address>>8];
     def peekbyte(self,address):
         """Read a byte of memory from the monitor."""
         self.data=[address&0xff,address>>8];