"""Open the serial port"""
self.serialport = serial.Serial(
port,
- 9600,
+ #9600,
+ 115200,
parity = serial.PARITY_NONE
)
#Drop DTR, which is !RST, low to begin the app.
self.serialport.flushOutput()
#Read and handle the initial command.
- time.sleep(1);
+ #time.sleep(1);
self.readcmd(); #Read the first command.
if(self.verb!=0x7F):
print "Verb is wrong. Incorrect firmware?";
def setBaud(self,baud):
rates=[9600, 9600, 19200, 38400];
self.data=[baud];
- print "Changing baud."
+ print "Changing FET baud."
self.serialport.write(chr(0x00));
self.serialport.write(chr(0x80));
self.serialport.write(chr(1));
self.serialport.write(chr(baud));
- print "Changed baud."
+ print "Changed host baud."
self.serialport.setBaudrate(rates[baud]);
+ time.sleep(1);
+ self.serialport.flushInput()
+ self.serialport.flushOutput()
+
+ print "Baud is now %i." % rates[baud];
return;
def monitortest(self):
"""Self-test several functions through the monitor."""
def MSP430flashtest(self):
self.MSP430masserase();
i=0x2500;
- while(i<0x2600):
+ while(i<0xFFFF):
if(self.MSP430peek(i)!=0xFFFF):
print "ERROR: Unerased flash at %04x."%i;
- self.MSP430writeflash(i,0x0000);
+ self.MSP430writeflash(i,0xDEAD);
i+=2;
def MSP430masserase(self):
"""Erase MSP430 flash memory."""
self.writecmd(0x11,0xE3,0,None);
def MSP430writeflash(self,adr,val):
"""Write a word of flash memory."""
+ if(self.MSP430peek(adr)!=0xFFFF):
+ print "FLASH ERROR: %04x not clear." % adr;
data=[adr&0xFF,(adr&0xFF00)>>8,val&0xFF,(val&0xFF00)>>8];
self.writecmd(0x11,0xE1,4,data);
rval=ord(self.data[0])+(ord(self.data[1])<<8);
if(val!=rval):
print "FLASH WRITE ERROR AT %04x. Found %04x, wrote %04x." % (adr,rval,val);
- sys.exit(1);
+
def MSP430dumpbsl(self):
self.MSP430dumpmem(0xC00,0xfff);
def MSP430dumpallmem(self):