#!/usr/bin/env python ram=0 count=0 total=0 sfr=False startsfr=0 stopsfr=0 totsfr=0 actrec=False actrecend=False import sys, os if len(sys.argv) > 1: if os.path.isfile(sys.argv[1]): f=open(sys.argv[1], 'r') for line in f.readlines(): if "Section Info" in line and count==0: count=count+1 if count > 3: if line == "\r\n": break ls = line.split() if ls[3] == 'data' and (ls[1]=='idata' or ls[1]=='udata') and not ls[0].startswith('SFR_'): ram=ram+int(ls[4], 16) if ls[3] == 'data' and ls[0].startswith('SFR_BANKED') and not sfr: startsfr=int(ls[2], 16) sfr=True if ls[3] == 'data' and not ls[0].startswith('SFR_BANKED') and sfr: stopsfr=int(ls[2], 16) sfr=False totsfr=totsfr+stopsfr-startsfr if ls[3] == 'data' and ls[1]=='actrec' and not actrec: actrec=int(ls[2], 16) actrecend=actrec if ls[3] == 'data' and ls[1]=='actrec' and actrec: actrecend=int(ls[2], 16) if ls[0].startswith('SFR_UNBANKED') and ls[3] == 'data': total=total+int(ls[2], 16) if count > 0: count=count+1 actrectot=actrecend-actrec totram=total-totsfr print 'TOTAL RAM:', ram, 'OF', totram, " - Free: ", totram-ram , " - Usage:", str(int(ram*100/totram))+'%' print 'ACTREC RAM:', actrectot, 'REALLY FREE:', totram-ram-actrectot, 'REAL USAGE:', str(int((ram+actrectot)*100/totram))+'%'