aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2009-12-12 13:28:38 -0500
committerKevin O'Connor <kevin@koconnor.net>2009-12-12 13:28:38 -0500
commit58db9c492da57b2b71af2200f39d2262d719c142 (patch)
tree72d4c2bc8c5260fc49fe87a3283a1c6b058d5d9e
parent7cefbfa227fdfb961e3b10535fbc151e5652014c (diff)
downloadseabios-hppa-58db9c492da57b2b71af2200f39d2262d719c142.zip
seabios-hppa-58db9c492da57b2b71af2200f39d2262d719c142.tar.gz
seabios-hppa-58db9c492da57b2b71af2200f39d2262d719c142.tar.bz2
Enhance readserial.py to try to account for host time offsets.
Try to account for time related to the host sending blocks of data to the script.
-rwxr-xr-xtools/readserial.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/readserial.py b/tools/readserial.py
index 4b47b14..052016d 100755
--- a/tools/readserial.py
+++ b/tools/readserial.py
@@ -24,6 +24,9 @@ BITSPERBYTE = 10
def readserial(infile, logfile, baudrate):
lasttime = 0
+ byteadjust = 0.0
+ if ADJUSTBAUD:
+ byteadjust = float(BITSPERBYTE) / baudrate
while 1:
# Read data
try:
@@ -37,31 +40,32 @@ def readserial(infile, logfile, baudrate):
lasttime = 0
if len(res[0]) == 1:
continue
- curtime = time.time()
d = infile.read(4096)
+ datatime = time.time()
+
+ datatime -= len(d) * byteadjust
# Reset start time if no data for some time
- if curtime - lasttime > RESTARTINTERVAL:
- starttime = curtime
+ if datatime - lasttime > RESTARTINTERVAL:
+ starttime = datatime
charcount = 0
isnewline = 1
msg = "\n\n======= %s (adjust=%d)\n" % (
- time.asctime(time.localtime(curtime)), ADJUSTBAUD)
+ time.asctime(time.localtime(datatime)), ADJUSTBAUD)
sys.stdout.write(msg)
logfile.write(msg)
- lasttime = curtime
+ lasttime = datatime
# Translate unprintable chars; add timestamps
out = ""
for c in d:
if isnewline:
- delta = curtime - starttime
- if ADJUSTBAUD:
- delta -= float(charcount * BITSPERBYTE) / baudrate
+ delta = datatime - starttime - (charcount * byteadjust)
out += "%06.3f: " % delta
isnewline = 0
oc = ord(c)
charcount += 1
+ datatime += byteadjust
if oc == 0x0d:
continue
if oc == 0x00: