Example #1
0
 def read_file(self, filename):
     if filename.endswith('.srec'):
         srec = lib.srec.Srec()
         srec.encode_file(filename)
         size = sum([len(i[1]) for i in srec.buffers])
         self._dbg.info("Loaded %d Bytes from %s file" % (size, filename))
         return srec.buffers
     with open(filename, 'rb') as f:
         data = list(f.read())
         self._dbg.info("Loaded %d Bytes from %s file" % (len(data), filename))
         return [(None, data)]
     raise lib.stlinkex.StlinkException("Error reading file")
Example #2
0
 def read_file(self, filename):
     if filename.endswith('.srec'):
         srec = lib.srec.Srec()
         srec.encode_file(filename)
         size = sum([len(i[1]) for i in srec.buffers])
         self._dbg.info("Loaded %d Bytes from %s file" % (size, filename))
         return srec.buffers
     with open(filename, 'rb') as f:
         data = list(f.read())
         self._dbg.info("Loaded %d Bytes from %s file" % (len(data), filename))
         return [(None, data)]
     raise lib.stlinkex.StlinkException("Error reading file")