def run(dout, prog_dev, ethresh=20., interval=3.0, passes=10): if not os.path.exists(dout): os.mkdir(dout) ''' if '27C16' in prog_dev: size = 16 * 1024 / 8 elif '27C32' in prog_dev: size = 32 * 1024 / 8 elif '27C64' in prog_dev: size = 64 * 1024 / 8 elif '27C128' in prog_dev: # 16384 size = 128 * 1024 / 8 elif '27C256' in prog_dev: size = 256 * 1024 / 8 else: assert 0, prog_dev ''' prog = Minipro(device=prog_dev) size = len(prog.read()) subprocess.check_call('python patgen.py --size %u %s/0s.bin' % (size, dout), shell=True) dts = [] dt_halfs = [] for passn in xrange(passes): fnout = '%s/iter_%02u.jl' % (dout, passn) print('') print('Writing to %s' % fnout) print('Writing') subprocess.check_call("minipro -p '%s' -w %s/0s.bin" % (prog_dev, dout), shell=True) print('Wrote') dt, dt_half = eprom_etime.run(fnout, prog_dev=prog_dev, ethresh=ethresh, interval=interval) dts.append(dt) dt_halfs.append(dt_half) print('') tavg = 1.0 * sum(dts) / len(dts) stdev = np.std(dts) thalf_avg = 1.0 * sum(dt_halfs) / len(dt_halfs) thalf_stdev = np.std(dt_halfs) print('%s @ %u passes' % (prog_dev, passn)) print(' 120%% erase avg: %0.1f sec, stdev: %0.1f sec' % (tavg, stdev)) for dt in dts: print(" %0.1f" % dt) print(' 50%% erase avg: %0.1f sec, stdev: %0.1f sec' % (thalf_avg, thalf_stdev)) for dt in dt_halfs: print(" %0.1f" % dt) fnout = '%s/sweep.jl' % (dout,) with open(fnout, 'w') as fout: j = {'tavg': tavg} fout.write(json.dumps(j) + '\n')
def run(fnout, prog_dev, ethresh=20., interval=3.0): prog = Minipro(device=prog_dev) with open(fnout, 'w') as fout: j = {'type': 'header', 'prog_dev': prog_dev, 'date': datetime.datetime.utcnow().isoformat(), 'interval': interval, 'ethresh': ethresh} fout.write(json.dumps(j) + '\n') tstart = time.time() tlast = None thalf = None passn = 0 nerased = 0 while True: if tlast is not None: while time.time() - tlast < interval: time.sleep(0.1) tlast = time.time() now = datetime.datetime.utcnow().isoformat() passn += 1 fw = prog.read() erased, erase_percent = is_erased(fw, prog_dev) if erased: nerased += 1 else: nerased = 0 pcomplete = 100.0 * nerased / passn j = {'iter': passn, 'date': now, 'fw': binascii.hexlify(zlib.compress(fw)), 'pcomplete': pcomplete, 'erase_percent': erase_percent, 'erased': erased} fout.write(json.dumps(j) + '\n') signature = binascii.hexlify(md5.new(fw).digest())[0:8] print('%s iter %u: erased %u w/ erase_percent %0.3f%%, sig %s, erase completion: %0.1f' % (now, passn, erased, erase_percent, signature, 100. * pcomplete / ethresh)) if thalf is None and erase_percent >= 50: thalf = tlast dt_half = thalf - tstart print('50%% erased after %0.1f sec' % (dt_half,)) if pcomplete >= ethresh: break dt = tlast - tstart print('120%% erased after %0.1f sec' % (dt,)) j = {'type': 'footer', 'etime': dt, 'half_etime': dt_half} fout.write(json.dumps(j) + '\n') return dt, dt_half
l = bytearray(l) r = bytearray(r) ret = bytearray() if len(l) != len(r): raise ValueError() for i in xrange(len(l)): ret.append(op(l[i], r[i])) return str(ret) if __name__ == '__main__': parser = argparse.ArgumentParser(description='I leave all that I own to my cat guppy') args = parser.parse_args() m = Minipro(device='87C51') baseline = m.read() or_buff = None frame = 0 while True: c = nextc() if c == 'q': break elif c == 'r': baseline = m.read() or_buff = None this = m.read() if 0: out = buff_op(baseline, this, lambda l, r: (l - r) % 0x100) if 1:
from uvscada.minipro import Minipro import md5 import binascii import subprocess import time m = Minipro(device='87C51') hs = {} i = 0 while True: subprocess.check_call('clear') print i print hs h = binascii.hexlify(md5.new(m.read()).digest()) print h hs[h] = hs.get(h, 0) + 1 #time.sleep(0.1) i += 1
raise ValueError() for i in xrange(0, len(l), 2): li = struct.unpack('<H', l[i:i + 2])[0] ri = struct.unpack('<H', r[i:i + 2])[0] resi = op(li, ri) ret += struct.pack('<H', resi) return str(ret) if __name__ == '__main__': parser = argparse.ArgumentParser( description='I leave all that I own to my cat guppy') args = parser.parse_args() m = Minipro(device='PIC16C57') baseline = m.read() or_buff = None ref = open('pic16c57_test1.bin') frame = 0 while True: c = nextc() if c == 'q': break elif c == 'r': baseline = m.read() or_buff = None this = m.read() diff = buff_op(baseline, this, lambda l, r: (l - r) % 0x1000)