CVS: python/msp430 bsl.py,1.1,1.2

Chris Liechti <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/python/msp430
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8903/python/msp430

Modified Files:
	bsl.py 
Log Message:
progress bar support

Index: bsl.py
===================================================================
RCS file: /cvsroot/mspgcc/python/msp430/bsl.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- bsl.py	29 Feb 2004 23:06:36 -0000	1.1
+++ bsl.py	29 Oct 2004 18:02:33 -0000	1.2
@@ -575,6 +575,7 @@
         self.data           = None
         self.maxData        = self.MAXDATA
         self.cpu            = None
+        self.showprogess    = 0
 
 
     def preparePatch(self):
@@ -640,15 +641,26 @@
         #Verify block
         self.verifyBlk(addr, blkout, action & self.ACTION_VERIFY)
 
+    def progess_update(self, count, total):
+        """Textual progress output. Override in subclass to implement a different output"""
+        sys.stderr.write("\r%d%%" % (100*count/total))
+        sys.stderr.flush()
+
     #segments:
     #list of tuples or lists:
     #segements = [ (addr1, [d0,d1,d2,...]), (addr2, [e0,e1,e2,...])]
     def programData(self, segments, action):
         """programm or verify data"""
         if DEBUG > 1: sys.stderr.write("* programData()\n")
+        #count length if progress updates have to be done
+        if self.showprogess:
+            total = 0
+            for seg in segments:
+                total = total + len(seg.data)
         for seg in segments:
             currentAddr = seg.startaddress
             pstart = 0
+            count = 0
             while pstart<len(seg.data):
                 length = self.MAXDATA
                 if pstart+length > len(seg.data):
@@ -657,6 +669,9 @@
                 pstart = pstart + length
                 currentAddr = currentAddr + length
                 self.byteCtr = self.byteCtr + length #total sum
+                count = count + length
+                if self.showprogess:
+                    self.progess_update(count, total)
 
     def uploadData(self, startaddress, size, wait=0):
         """upload a datablock"""



-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.