90
print "Usage:\n %s [<serialdevice> [<baud>]]" % (sys.argv[0],)
92
usage = "%prog [options] [<serialdevice> [<baud>]]"
93
opts = optparse.OptionParser(usage)
94
opts.add_option("-f", "--file",
95
action="store_false", dest="serial", default=True,
96
help="read from file instead of serialdevice")
97
opts.add_option("-n", "--no-adjust",
98
action="store_false", dest="adjustbaud", default=True,
99
help="don't adjust times by serial rate")
100
options, args = opts.parse_args()
99
serialport = sys.argv[1]
100
if len(sys.argv) > 2:
101
baud = int(sys.argv[2])
104
opts.error("Too many arguments")
110
ADJUSTBAUD=options.adjustbaud
103
ser = serial.Serial(serialport, baud, timeout=0)
113
# Read from serial port
115
ser = serial.Serial(serialport, baud, timeout=0)
118
ser = open(serialport, 'rb')
121
fcntl.fcntl(ser, fcntl.F_SETFL
122
, fcntl.fcntl(ser, fcntl.F_GETFL) | os.O_NONBLOCK)
105
124
logname = time.strftime("seriallog-%Y%m%d_%H%M%S.log")
106
125
f = open(logname, 'wb')