Fix timing in readserial.py - use 10 bits per byte.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 5 Dec 2009 19:23:27 +0000 (14:23 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 5 Dec 2009 19:23:27 +0000 (14:23 -0500)
There is also a start bit, so 8N1 serial should use 10 bits to a byte.

tools/readserial.py

index fec2811a7e557ef9333c8817c70a288162b1abb5..4b47b1434ed4bb7fdacba6610bc087cc8ccce934 100755 (executable)
@@ -18,6 +18,9 @@ RESTARTINTERVAL = 60
 # Alter timing reports based on how much time would be spent writing
 # to serial.
 ADJUSTBAUD = 1
+# Number of bits in a transmitted byte - 8N1 is 1 start bit + 8 data
+# bits + 1 stop bit.
+BITSPERBYTE = 10
 
 def readserial(infile, logfile, baudrate):
     lasttime = 0
@@ -54,7 +57,7 @@ def readserial(infile, logfile, baudrate):
             if isnewline:
                 delta = curtime - starttime
                 if ADJUSTBAUD:
-                    delta -= float(charcount * 9) / baudrate
+                    delta -= float(charcount * BITSPERBYTE) / baudrate
                 out += "%06.3f: " % delta
                 isnewline = 0
             oc = ord(c)