23 res += l |
24 res += l |
24 i = 0 |
25 i = 0 |
25 return res |
26 return res |
26 |
27 |
27 |
28 |
|
29 if __name__=='__main__': |
|
30 import optparse |
|
31 opt = optparse.OptionParser("A simple tool for dumping the current trace") |
|
32 opt.add_option('-f', '--filename', default=None, |
|
33 dest='filename', |
|
34 help='Output filename. If not set, write to stdout') |
|
35 opt.add_option('-d', '--device', default='/dev/ttyUSB0', |
|
36 dest='device', |
|
37 help='Device of the RS232 connection (default: /dev/ttyUSB0)', |
|
38 ) |
|
39 opt.add_option('-m', '--mode', default='binary', |
|
40 dest='mode', |
|
41 help='Dumping mode (may be "binary" [default], "ascii" or "ansi")', |
|
42 ) |
|
43 opt.add_option('-a', '--address', default=0, |
|
44 dest='address', |
|
45 help='GPIB address of the device', |
|
46 ) |
|
47 options, argv = opt.parse_args(sys.argv) |
28 |
48 |
29 import optparse |
49 cnx = open_connection(device=options.device, |
30 opt = optparse.OptionParser() |
50 address=int(options.address), mode=1) |
31 opt.add_option('-f', '--filename', default=None, |
51 res = read_trace(cnx, mode=options.mode) |
32 dest='filename', |
|
33 help='Output filename. If not set, write to stdout') |
|
34 opt.add_option('-d', '--device', default='/dev/ttyUSB0', |
|
35 dest='device', |
|
36 help='Device of the RS232 connection (default: /dev/ttyUSB0)', |
|
37 ) |
|
38 opt.add_option('-m', '--mode', default='binary', |
|
39 dest='mode', |
|
40 help='Dumping mode (may be "binary" [default], "ascii" or "ansi")', |
|
41 ) |
|
42 opt.add_option('-a', '--address', default=0, |
|
43 dest='address', |
|
44 help='GPIB address of the device', |
|
45 ) |
|
46 options, argv = opt.parse_args(sys.argv) |
|
47 |
52 |
48 cnx = open_connection(device=options.device, |
53 if options.filename: |
49 address=int(options.address), mode=1) |
54 open(options.filename, 'w').write(res) |
50 res = read_trace(cnx, mode=options.mode) |
55 else: |
51 |
56 print res |
52 if options.filename: |
|
53 open(options.filename, 'w').write(res) |
|
54 else: |
|
55 print res |
|
56 |
57 |