~ubuntu-branches/ubuntu/utopic/seabios/utopic-proposed

« back to all changes in this revision

Viewing changes to scripts/readserial.py

  • Committer: Package Import Robot
  • Author(s): Michael Tokarev
  • Date: 2014-05-31 12:29:13 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20140531122913-1107keyljv7hf4w6
Tags: 1.7.5-1
* new upstream release
* dropped all patches taken from upstream
* disabled more features (XEN & USB_UAS) from the 128k bios build to fit
* set upstream source URL (Closes: #740471) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
import select
14
14
import optparse
15
15
 
 
16
from python23compat import as_bytes
 
17
 
16
18
# Reset time counter after this much idle time.
17
19
RESTARTINTERVAL = 60
18
20
# Number of bits in a transmitted byte - 8N1 is 1 start bit + 8 data
25
27
    data = data * 80
26
28
    while 1:
27
29
        st = time.time()
28
 
        outfile.write(data)
 
30
        outfile.write(as_bytes(data))
29
31
        outfile.flush()
30
32
        et = time.time()
31
33
        sys.stdout.write(
85
87
            msg = "\n\n======= %s (adjust=%.1fus)\n" % (
86
88
                time.asctime(time.localtime(datatime)), byteadjust * 1000000)
87
89
            sys.stdout.write(msg)
88
 
            logfile.write(msg)
 
90
            logfile.write(as_bytes(msg))
89
91
        lasttime = datatime
90
92
 
91
93
        # Translate unprintable chars; add timestamps
92
 
        out = ""
 
94
        out = as_bytes("")
93
95
        for c in d:
94
96
            if isnewline:
95
97
                delta = datatime - starttime - (charcount * byteadjust)
113
115
                continue
114
116
            out += c
115
117
 
116
 
        sys.stdout.write(out)
 
118
        if (sys.version_info > (3, 0)):
 
119
            sys.stdout.buffer.write(out)
 
120
        else:
 
121
            sys.stdout.write(out)
117
122
        sys.stdout.flush()
118
123
        logfile.write(out)
119
124
        logfile.flush()
156
161
        try:
157
162
            import serial
158
163
        except ImportError:
159
 
            print """
 
164
            print("""
160
165
Unable to find pyserial package ( http://pyserial.sourceforge.net/ ).
161
166
On Linux machines try: yum install pyserial
162
167
Or: apt-get install python-serial
163
 
"""
 
168
""")
164
169
            sys.exit(1)
165
170
        ser = serial.Serial(serialport, baud, timeout=0)
166
171
    else: