# HG changeset patch # User David Douard # Date 1197313539 -3600 # Node ID 9af1509775b6e32a02d491d9b240d187f3c24090 initial import diff -r 000000000000 -r 9af1509775b6 dump_as_ascii.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dump_as_ascii.py Mon Dec 10 20:05:39 2007 +0100 @@ -0,0 +1,76 @@ +import sys +import time +import serial + +MODE = {'binary': 'DDBN', + 'ascii': 'DDAS', + 'ansi': 'DDAN', + } +class ConnectionError(Exception): + pass + +def read_trace(cnx, mode="binary"): + mode = mode.lower() + assert mode in MODE + mode = MODE[mode] + res = "" + cnx.write('%s\r'%mode) + i = 0 + while i<5: + l = cnx.readline() + if l.strip() == "": + i += 1 + time.sleep(0.1) + continue + #print "got a new line (%s chars) [i=%s]"%(len(l), i) + res += l + i = 0 + return res + +def open_connection(device="/dev/ttyUSB0", baudrate=115200, timeout=0.1, + address=0, mode=1): + p = serial.Serial(port=device, baudrate=baudrate, timeout=timeout) + + p.write('++addr %d\r'%address) # set address to 0 + p.write('++mode %d\r'%mode) # read listen only mode + p.write('++mode\r') + i = 0 + for i in range(10): + rmode = p.readline().strip() + if rmode != "": + break + time.sleep(timeout) + + if rmode == '' or int(rmode) != mode: + raise ConnectionError("Can't set GPIB mode to %s"%mode) + return p + + +import optparse +opt = optparse.OptionParser() +opt.add_option('-f', '--filename', default=None, + dest='filename', + help='Output filename. If not set, write to stdout') +opt.add_option('-d', '--device', default='/dev/ttyUSB0', + dest='device', + help='Device of the RS232 connection (default: /dev/ttyUSB0)', + ) +opt.add_option('-m', '--mode', default='binary', + dest='mode', + help='Dumping mode (may be "binary" [default], "ascii" or "ansi")', + ) +opt.add_option('-a', '--address', default=0, + dest='address', + help='GPIB address of the device', + ) +options, argv = opt.parse_args(sys.argv) + +cnx = open_connection(device=options.device, + address=int(options.address), mode=1) +res = read_trace(cnx, mode=options.mode) + +if options.filename: + open(options.filename, 'w').write(res) +else: + print res + diff -r 000000000000 -r 9af1509775b6 examples/dump.ansi Binary file examples/dump.ansi has changed diff -r 000000000000 -r 9af1509775b6 examples/dump.asc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/dump.asc Mon Dec 10 20:05:39 2007 +0100 @@ -0,0 +1,868 @@ +#I+8.670000E+02 ++2.000000E+00 ++8.010000E+02 ++8.010000E+02 ++1.000000E+00 ++0.000000E+00 ++3.000000E+00 ++0.000000E+00 ++1.000000E+00 ++1.000000E+00 ++1.000000E+00 ++1.000000E+00 ++2.497000E+03 +-1.092400E+04 ++2.025600E+04 +-1.299100E+04 +-1.119200E+04 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000000E+00 ++0.000000E+00 ++1.000000E+00 ++0.000000E+00 ++1.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000000E+00 ++4.500000E+01 ++4.500000E+01 ++0.000000E+00 ++0.000000E+00 ++1.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.250000E+02 ++6.324552E+01 ++0.000000E+00 ++1.000000E+03 ++1.000000E+03 ++1.000000E+00 ++1.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.0000000000000000E+00 ++0.0000000000000000E+00 ++1.690681E-05 ++1.699568E-06 ++0.000000E+00 ++3.994884E-07 ++9.983529E-08 ++9.980807E-08 ++3.991619E-07 ++3.991301E-07 ++3.991366E-07 ++9.979546E-07 ++1.696878E-06 ++1.697397E-06 ++3.695820E-06 ++6.795703E-06 ++1.779932E-05 ++4.252771E-05 ++9.233260E-05 ++3.562614E-04 ++1.671612E-03 ++1.396762E-02 ++5.558499E-01 ++1.934159E+01 ++2.299663E+01 ++1.238078E+00 ++1.986862E-02 ++2.031064E-03 ++4.188612E-04 ++1.275685E-04 ++3.857379E-05 ++1.779586E-05 ++8.502636E-06 ++4.003792E-06 ++2.604373E-06 ++1.000968E-06 ++1.000352E-06 ++3.999332E-07 ++1.998823E-07 ++1.998176E-07 ++9.988611E-08 ++9.987322E-08 ++9.987002E-08 ++9.987657E-08 ++1.208703E-05 ++7.294082E-05 ++2.888691E-05 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001329E-07 ++1.803602E-06 ++1.412901E-04 ++2.324724E-04 ++2.213096E-05 ++2.001728E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++8.004365E-07 ++8.503342E-06 ++5.201747E-06 ++1.000374E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001477E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.002297E-07 ++0.000000E+00 ++0.000000E+00 ++1.001354E-07 ++1.001231E-07 ++0.000000E+00 ++0.000000E+00 ++1.001438E-07 ++1.532599E-05 ++3.497171E-05 ++5.313287E-06 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.006204E-07 ++1.709394E-06 ++1.607908E-06 ++1.004455E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++5.320972E-06 ++1.786797E-05 ++4.015099E-06 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.006180E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.004300E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.006355E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.004758E-07 ++0.000000E+00 ++0.000000E+00 ++1.004541E-07 ++0.000000E+00 ++0.000000E+00 ++1.005164E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++8.053103E-07 ++6.136996E-06 ++1.810049E-06 ++0.000000E+00 ++1.004893E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.005017E-07 ++0.000000E+00 ++1.005789E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.004500E-07 ++1.004296E-07 ++1.004183E-07 ++0.000000E+00 ++0.000000E+00 ++1.004390E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.005906E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.003851E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++4.018441E-07 ++2.914557E-06 ++1.005517E-06 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.004079E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.003896E-07 ++1.003509E-07 ++0.000000E+00 ++5.014906E-07 ++2.908238E-06 ++2.908070E-06 ++1.002807E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.004685E-07 ++0.000000E+00 ++1.003435E-07 ++0.000000E+00 ++1.002514E-07 ++0.000000E+00 ++0.000000E+00 ++1.001748E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.002840E-07 ++1.003325E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001544E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++2.004328E-07 ++2.003479E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001126E-07 ++0.000000E+00 ++1.001746E-07 ++1.002172E-07 ++1.002675E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000533E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000798E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001046E-07 ++5.007008E-06 ++6.511899E-06 ++1.002332E-07 ++0.000000E+00 ++1.001345E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000061E-07 ++1.000091E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001193E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001320E-07 ++0.000000E+00 ++1.002027E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++2.002490E-07 ++1.301613E-06 ++2.002603E-06 ++2.002852E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001774E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.002389E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001801E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.002581E-07 ++0.000000E+00 ++0.000000E+00 ++5.008723E-07 ++1.302049E-06 ++1.001463E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001563E-07 ++1.001726E-07 ++0.000000E+00 ++1.002218E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001545E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001379E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000902E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++2.504433E-06 ++8.117029E-06 ++2.504351E-06 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000750E-07 ++1.000617E-07 ++1.000531E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001471E-07 ++1.001172E-07 ++0.000000E+00 ++0.000000E+00 ++1.000520E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000512E-07 ++1.000418E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++2.001301E-07 ++1.000821E-07 ++0.000000E+00 ++0.000000E+00 ++1.001562E-07 ++0.000000E+00 ++0.000000E+00 ++1.001412E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000786E-07 ++0.000000E+00 ++1.000840E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001240E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000324E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000227E-07 ++4.000826E-07 ++1.000211E-07 ++1.000239E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000969E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001567E-07 ++0.000000E+00 ++1.001454E-07 ++0.000000E+00 ++1.001409E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001593E-07 ++0.000000E+00 ++0.000000E+00 ++1.001906E-07 ++2.004089E-07 ++5.009696E-07 ++5.009235E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001610E-07 ++0.000000E+00 ++0.000000E+00 ++1.001570E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001700E-07 ++0.000000E+00 ++0.000000E+00 ++1.001934E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001715E-07 ++1.001729E-07 ++0.000000E+00 ++1.001784E-07 ++1.001825E-07 ++0.000000E+00 ++1.001935E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001875E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.001329E-07 ++1.001273E-07 ++0.000000E+00 ++2.002356E-07 ++2.002278E-07 ++1.001105E-07 ++0.000000E+00 ++1.001054E-07 ++0.000000E+00 ++1.000993E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000874E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++2.001263E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++9.998447E-08 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++9.990731E-08 ++0.000000E+00 ++0.000000E+00 ++9.990603E-08 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++9.990343E-08 ++0.000000E+00 ++0.000000E+00 ++9.990241E-08 ++0.000000E+00 ++0.000000E+00 ++9.988360E-08 ++0.000000E+00 ++9.986563E-08 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.996756E-07 ++0.000000E+00 ++0.000000E+00 ++9.984609E-08 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++9.991261E-08 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++9.997194E-08 ++0.000000E+00 ++0.000000E+00 ++1.000093E-07 ++4.000913E-07 ++1.000378E-07 ++0.000000E+00 ++1.000725E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000453E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++9.993816E-08 ++0.000000E+00 ++0.000000E+00 ++1.996468E-07 ++1.996106E-07 ++9.979730E-08 ++9.979936E-08 diff -r 000000000000 -r 9af1509775b6 examples/dump.bin Binary file examples/dump.bin has changed diff -r 000000000000 -r 9af1509775b6 examples/dump_1_21.bin Binary file examples/dump_1_21.bin has changed diff -r 000000000000 -r 9af1509775b6 examples/dump_1_21_ftop.ascii --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/dump_1_21_ftop.ascii Mon Dec 10 20:05:39 2007 +0100 @@ -0,0 +1,868 @@ +#I+8.670000E+02 ++2.000000E+00 ++8.010000E+02 ++8.010000E+02 ++1.000000E+00 ++0.000000E+00 ++3.000000E+00 ++0.000000E+00 ++1.000000E+00 ++1.000000E+00 ++1.000000E+00 ++1.000000E+00 ++2.497000E+03 +-1.092400E+04 ++2.025600E+04 +-1.299100E+04 +-1.119200E+04 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.000000E+00 ++0.000000E+00 ++1.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++2.000000E+00 ++4.500000E+01 ++4.500000E+01 ++0.000000E+00 ++0.000000E+00 ++1.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++2.500000E+01 ++6.324552E+01 ++0.000000E+00 ++1.000000E+03 ++1.000000E+03 ++1.000000E+00 ++1.000000E+00 ++0.000000E+00 ++0.000000E+00 ++9.9999999999999978E+02 ++9.9999999999999978E+02 ++0.000000E+00 ++1.713825E-07 ++1.714040E-07 ++0.000000E+00 ++0.000000E+00 ++1.714601E-07 ++1.714575E-07 ++0.000000E+00 ++1.714624E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++3.431862E-07 ++0.000000E+00 ++0.000000E+00 ++1.716427E-07 ++0.000000E+00 ++0.000000E+00 ++1.717546E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.718094E-07 ++0.000000E+00 ++1.718853E-07 ++0.000000E+00 ++1.718880E-07 ++3.439050E-07 ++3.440118E-07 ++1.720132E-07 ++1.720442E-07 ++1.720645E-07 ++1.720844E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.722338E-07 ++1.722486E-07 ++0.000000E+00 ++0.000000E+00 ++1.723076E-07 ++1.722568E-07 ++3.445938E-07 ++1.722838E-07 ++1.722980E-06 ++8.612534E-07 ++8.613550E-07 ++1.722374E-06 ++3.446098E-06 ++8.612544E-06 ++5.822159E-05 ++4.538305E-02 ++2.579506E+00 ++1.719975E+01 ++2.907775E+01 ++2.947580E+01 ++2.534770E+01 ++8.416452E+00 ++4.786861E-01 ++8.824243E-04 ++2.084822E-05 ++6.890805E-06 ++2.240150E-06 ++1.723160E-07 ++6.893719E-07 ++3.446193E-07 ++8.617178E-07 ++1.723281E-07 ++8.620016E-07 ++3.447547E-07 ++1.723835E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.724318E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++3.450118E-07 ++0.000000E+00 ++1.725144E-07 ++0.000000E+00 ++1.725703E-07 ++0.000000E+00 ++1.725706E-07 ++0.000000E+00 ++3.451953E-07 ++1.726642E-07 ++1.726675E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.727514E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.728572E-07 ++0.000000E+00 ++0.000000E+00 ++1.728758E-07 ++3.458026E-07 ++0.000000E+00 ++0.000000E+00 ++1.729459E-07 ++0.000000E+00 ++1.730163E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.731190E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.729540E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.727815E-07 ++0.000000E+00 ++0.000000E+00 ++1.727515E-07 ++1.381627E-06 ++7.080639E-06 ++8.634006E-06 ++1.053322E-05 ++7.080832E-06 ++1.381343E-06 ++3.453261E-07 ++1.726476E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.727036E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++3.450221E-07 ++1.724567E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.723539E-07 ++0.000000E+00 ++0.000000E+00 ++1.723135E-07 ++0.000000E+00 ++1.722458E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.720092E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.719538E-07 ++0.000000E+00 ++1.719232E-06 ++1.375146E-05 ++4.487544E-05 ++5.020029E-05 ++5.019911E-05 ++2.905487E-05 ++4.984700E-06 ++1.718924E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.719368E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.719551E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.720159E-07 ++1.720555E-07 ++1.720899E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.721214E-07 ++0.000000E+00 ++1.720696E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.716835E-07 ++0.000000E+00 ++1.716468E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.714888E-07 ++3.429494E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.714467E-07 ++1.713954E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.713996E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.714144E-07 ++1.713864E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++8.577350E-07 ++2.230062E-06 ++3.431363E-06 ++2.230936E-06 ++1.372634E-06 ++1.716238E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.717465E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.718452E-07 ++1.718265E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++3.432966E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.715937E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.714432E-07 ++1.714431E-07 ++1.713994E-07 ++1.714243E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.713905E-07 ++1.714023E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.714689E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.716643E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.717196E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.719864E-07 ++1.719845E-07 ++6.877509E-07 ++6.877407E-07 ++6.877980E-07 ++1.718881E-07 ++1.718577E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.717737E-07 ++1.717695E-07 ++0.000000E+00 ++3.434363E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.716723E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.720186E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.721383E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.723237E-07 ++0.000000E+00 ++1.724310E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.725116E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.724560E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.724096E-07 ++0.000000E+00 ++0.000000E+00 ++1.723753E-07 ++8.619686E-07 ++1.723783E-06 ++1.723588E-06 ++8.618275E-07 ++1.723545E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.725113E-07 ++1.725361E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.726737E-07 ++0.000000E+00 ++0.000000E+00 ++1.727053E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.728483E-07 ++1.729292E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.732201E-07 ++0.000000E+00 ++0.000000E+00 ++1.733000E-07 ++0.000000E+00 ++0.000000E+00 ++1.733592E-07 ++0.000000E+00 ++0.000000E+00 ++1.733418E-07 ++1.733545E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.732130E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.732206E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++3.464820E-07 ++1.732910E-06 ++5.024184E-06 ++7.796092E-06 ++7.797371E-06 ++4.331783E-06 ++8.665349E-07 ++0.000000E+00 ++1.732957E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.733404E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.735776E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.738570E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.741270E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.738436E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.736726E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.734290E-07 ++0.000000E+00 ++1.733892E-07 ++0.000000E+00 ++1.733803E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.733858E-07 ++0.000000E+00 ++0.000000E+00 ++1.733939E-07 ++1.733960E-07 ++0.000000E+00 ++0.000000E+00 ++1.734298E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.735119E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.734022E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.731902E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++3.458474E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++1.727999E-07 ++1.727737E-07 ++0.000000E+00 ++1.727757E-07 ++1.727815E-07 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 ++0.000000E+00 diff -r 000000000000 -r 9af1509775b6 examples/dump_1_21_ftop.bin Binary file examples/dump_1_21_ftop.bin has changed diff -r 000000000000 -r 9af1509775b6 load_gpib_plot.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/load_gpib_plot.py Mon Dec 10 20:05:39 2007 +0100 @@ -0,0 +1,54 @@ +import sys +import time +import serial +p = serial.Serial(port="/dev/ttyUSB0", baudrate=115200, timeout=0.1) + +p.write('++addr 5\r') # set address to 0 +p.write('++mode 0\r') # read listen only mode +p.write('++mode\r') +for i in range(10): + mode = p.readline().strip() + if mode != "": + break + time.sleep(0.1) +print "mode = ", mode +if mode == '': + print "strange" + sys.exit() + +res = "" +i=0 + +replies={ + "OE": "0", + "OH": "0,0,10000,7500", + "OI": "7470A", + "OP": "0,0,10000,7500", + "OO": "0,1,0,0,0,0,0,0", + "OF": "40,40", + "OS": "24", + } + +while i<15: + l = p.readline().strip() + if l == "": + i += 1 + for k, v in replies.items(): + if res.endswith(k) or res.endswith(k+';'): + print "got commend", k + p.write("%s"%v) + if k == "OS": + replies[k] = "16" + break + p.write('\r') + time.sleep(0.1) + continue + print "got a new line (%s chars) [i=%s]"%(len(l), i) + res += l + "\n" + i = 0 +print "over" +print "res = ", res + +open('out.gpib', 'w').write(res) + + diff -r 000000000000 -r 9af1509775b6 read_trace.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/read_trace.py Mon Dec 10 20:05:39 2007 +0100 @@ -0,0 +1,294 @@ +# -*- coding: utf-8 -*- + +import struct + + +def decode_float(s): + assert len(s) in [4,8] + # exponential term + e = ord(s[-1]) + if e & 0x80: + e = e - 256 + + # mantissa + m = [ord(x) for x in s[:-1]] + M = 0. + for i in range(len(s)-1): + #M += m[i]<<(i*8) + M += float(m[i])/2**((i+1)*8) + + #if m[0] & 0x80: + # M = M - 2^(len(s)) + + return M * 2**(e+1) + mm = str(M) + + mm = '0.'+mm + 'e' + str(e) + if len(s) == 8: + print "mm = ", mm + return eval(mm) + +def decode_string(s): + nb = ord(s[0]) + s = s[1:nb+2] + r = "" + for c in s: + if ord(c)>128: + c = chr(ord(c)-128) + r += c + return r + +EDSP = {0: "No data", + 1: "Frequency response", + 2: "Power spectrum 1", + 3: "Power spectrum 2", + 4: "Coherence", + 5: "Cross spectrum", + 6: "Input time 1", + 7: "Input time 2", + 8: "Input linear spectrum 1", + 9: "Input linear spectrum 2", + 10: "Impulse response", + 11: "Cross correlation", + 12: "Auto correlation 1", + 13: "Auto correlation 2", + 14: "Histogram 1", + 15: "Histogram 2", + 16: "Cumulative density function 1", + 17: "Cumulative density function 2", + 18: "Probability density function 1", + 19: "Probability density function 2", + 20: "Average linear spectrum 1", + 21: "Average linear spectrum 2", + 22: "Average time record 1", + 23: "Average time record 2", + 24: "Synthesis pole-zeros", + 25: "Synthesis pole-residue", + 26: "Synthesis polynomial", + 27: "Synthesis constant", + 28: "Windowed time record 1", + 29: "Windowed time record 2", + 30: "Windowed linear spectrum 1", + 31: "Windowed linear spectrum 2", + 32: "Filtered time record 1", + 33: "Filtered time record 2", + 34: "Filtered linear spectrum 1", + 35: "Filtered linear spectrum 2", + 36: "Time capture buffer", + 37: "Captured linear spectrum", + 38: "Captured time record", + 39: "Throughput time record 1", + 40: "Throughput time record 2", + 41: "Curve fit", + 42: "Weighted function", + 43: "Not used", + 44: "Orbits", + 45: "Demodulation polar", + 46: "Preview demod record 1", + 47: "Preview demod record 2", + 48: "Preview demod linear spectrum 1", + 49: "Preview demod linear spectrum 2", + } + +ECH = {0: "Channel 1", + 1: "Channel 2", + 2: "Channel 1&2", + 3: "No channel", + } + +EOVR = ECH + +EDOM = {0: 'Time', + 1: 'Frequency', + 2: 'Voltage (amplitude)', + } + +EVLT = {0: "Peak", + 1: "RMS", + 2: "Volt (indicates peak only)", + } + +EAMP = {0: "Volts", + 1: "Volts squared", + 2: "PSD (V²/Hz)", + 3: "ESD (V²s/Hz)", + 4: "PSD¹² (V/Hz¹²)", + 5: "No unit", + 6: "Unit volts", + 7: "Unit volts²", + } + +EXAXIS= {0: "No units", + 1: "Hertz", + 2: "RPM", + 3: "Orders", + 4: "Seconds", + 5: "Revs", + 6: "Degrees", + 7: "dB", + 8: "dBV", + 9: "Volts", + 10: "V Hz¹²", + 11: "Hz/s", + 12: "V/EU", + 13: "Vrms", + 14: "V²/Hz", + 15: "%", + 16: "Points", + 17: "Records", + 18: "Ohms", + 19: "Hertz/octave", + 20: "Pulse/Rev", + 21: "Decades", + 22: "Minutes", + 23: "V²s/Hz", + 24: "Octave", + 25: "Seconds/Decade", + 26: "Seconds/Octave", + #... + } + +EMEAS = {0: "Linear resolution", + 1: "Log resolution", + 2: "Swept sine", + 3: "Time capture", + 4: "Linear resolution throughput", + } + +EDEMOD1 = {45: "AM", + 46: "FM", + 47: "PM", + } + +EDEMOD2 = EDEMOD1 + +EAVG = {0: "No data", + 1: "Not averaged", + 2: "Averaged",} + + + +EWIN = {0: "N/A", + 1: "Hann", + 2: "Flat top", + #... + } + +HEADER = [ ("Display function", EDSP, 'h', 2), + ('Number of elements', int, 'h', 2), + ('Displayed elements', int, 'h', 2), + ('Number of averages', int, 'h', 2), + ('Channel selection', ECH, 'h', 2), + ('Overflow status', EOVR, 'h', 2), + ('Overlap percentage', int, 'h', 2), + ('Domain', EDOM, 'h', 2), + ('Volts peak/rms', EVLT, 'h', 2), + ('Amplitude units', EAMP, 'h', 2), + ('X axis units', EXAXIS, 'h', 2), + ('Auto math label', str, 's', 14), + ('Trace label', str, 's', 22), + ('EU label 1', str, 's', 6), + ('EU label 2', str, 's', 6), + ('Float/Interger', bool, 'h', 2), + ('Complex/Real', bool, 'h', 2), + ('Live/Recalled', bool, 'h', 2), + ('Math result', bool, 'h', 2), + ('Real/Complex input', bool, 'h', 2), + ('Log/Linear data', bool, 'h', 2), + ('Auto math', bool, 'h', 2), + ('Real time status', bool, 'h', 2), + ('Measurement mode', EMEAS, 'h', 2), + ('Window', EWIN, 'h', 2), + ('Demod type channel 1', EDEMOD1, 'h', 2), + ('Demod type channel 2', EDEMOD2, 'h', 2), + ('Demod active channel 1', bool, 'h', 2), + ('Demod active channel 2', bool, 'h', 2), + ('Average status', EAVG, 'h', 2), + ('Not used', int, 'hh', 4), + ('Samp freq/2 (real)', decode_float, None, 4), + ('Samp freq/2 (imag)', decode_float, None, 4), + ('Not used', decode_float, None, 4), + ('Delta X-axis', decode_float, None, 4), + ('Max range', decode_float, None, 4), + ('Start time value', decode_float, None, 4), + ('Expon wind const 1', decode_float, None, 4), + ('Expon wind const 2', decode_float, None, 4), + ('EU value chan 1', decode_float, None, 4), + ('EU value chan 2', decode_float, None, 4), + ('Trig delay chan 1', decode_float, None, 4), + ('Trig delay chan 2', decode_float, None, 4), + ('Start freq value', decode_float, None, 8), + ('Start data value', decode_float, None, 8), + ] + +def decode_file(filename): + d = open(filename).read() + + typ = d[:2] + assert typ == "#A" + + totlen = struct.unpack('>h', d[2:4])[0] + idx = 4 + tt=0 + header = {} + for i, (nam, dtype, fmt, nbytes) in enumerate(HEADER): + if dtype == str: + val = decode_string(d[idx:]) + else: + if fmt: + v = struct.unpack('>'+fmt, d[idx: idx+nbytes])[0] + if isinstance(dtype, dict): + val = dtype.get(int(v), "N/A") + else: + val = dtype(v) + else: + val = dtype(d[idx: idx+nbytes]) + + print idx, hex(idx), nam, ":", val + header[nam] = val + idx += nbytes + + resu = [] + + for i in range(header["Number of elements"]): + resu.append(decode_float(d[idx: idx+4])) + idx += 4 + + #print "resu = ", resu + #return + import pylab + import numpy + resu = numpy.array(resu, dtype=float) + print "max = ", max(resu) + #xr = numpy.linspace(0, header['Delta X-axis'], len(resu)) + sf = header['Start freq value'] + xr = numpy.linspace(sf, sf+20000, len(resu)) + mn = min(resu[resu>0]) + resu[resu==0] = mn + pylab.plot(xr, 10*numpy.log10(resu)) + pylab.show() + + # tt=0 + # for i, (nam, dtype, nbytes) in enumerate(HEADER): + # if dtype == str: + # nb = ord(struct.unpack('c', d[idx])[0]) + # val = d[idx+1:idx+1+nb] + # else: + # v = struct.unpack('>d', d[idx: idx+(nbytes*4)])[0] + # if isinstance(dtype, dict): + # val = dtype.get(int(v), "N/A") + # else: + # val = dtype(v) + # print idx, nam, ":", val + # idx += nbytes*4 + + + + +if __name__ == "__main__": + import sys + decode_file(sys.argv[1]) + + + +