6 Module for decoding the internal state of the HP3562A DSA, using the |
6 Module for decoding the internal state of the HP3562A DSA, using the |
7 GPIB command "DSBN" (Dump State BiNary). |
7 GPIB command "DSBN" (Dump State BiNary). |
8 |
8 |
9 This file can be exectued as a python script. Use '-h' for more informations. |
9 This file can be exectued as a python script. Use '-h' for more informations. |
10 """ |
10 """ |
11 from pygpibtoolkit.HP3562A import format_header, decode_float, decode_string, decode_header |
11 from pygpibtoolkit.gpi_utils import format_datablock_header, decode_datablock_header |
|
12 from pygpibtoolkit.gpi_utils import decode_float, decode_string |
12 |
13 |
13 from pygpibtoolkit.HP3562A.enum_types import * |
14 from pygpibtoolkit.HP3562A.enum_types import * |
14 |
15 |
15 HEADER = [("Measurement mode", EMEAS, 'h', 2), |
16 HEADER = [("Measurement mode", EMEAS, 'h', 2), |
16 ("Measurement 1", EMTYP, 'h', 2), |
17 ("Measurement 1", EMTYP, 'h', 2), |
111 Decode the data (as generated by the HP3562A DSA in response to a |
112 Decode the data (as generated by the HP3562A DSA in response to a |
112 "DSBN" command), and returns a dict (header) |
113 "DSBN" command), and returns a dict (header) |
113 |
114 |
114 header is the dictionnary of the header of the dumped data block, |
115 header is the dictionnary of the header of the dumped data block, |
115 """ |
116 """ |
116 header, idx = decode_header(data, HEADER) |
117 header, idx = decode_datablock_header(data, HEADER) |
117 return header |
118 return header |
118 |
119 |
119 |
120 |
120 def main(): |
121 def main(): |
121 import sys |
122 import sys |
135 if options.filename is None: |
136 if options.filename is None: |
136 print "Can't deal stdin for now..." |
137 print "Can't deal stdin for now..." |
137 sys.exit(1) |
138 sys.exit(1) |
138 #try: |
139 #try: |
139 if 1: |
140 if 1: |
140 header = decode_state(open(options.filename, 'rb').read()) |
141 header = decode_datablock_state(open(options.filename, 'rb').read()) |
141 else: |
142 else: |
142 #except Exception, e: |
143 #except Exception, e: |
143 print "ERROR: can't read %s an interpret it as a HP3562 trace"%options.filename |
144 print "ERROR: can't read %s an interpret it as a HP3562 trace"%options.filename |
144 print e |
145 print e |
145 sys.exit(1) |
146 sys.exit(1) |
146 |
147 |
147 print format_header(header, HEADER, 100) |
148 print format_datablock_header(header, HEADER, 100) |
148 |
149 |
149 if __name__ == "__main__": |
150 if __name__ == "__main__": |
150 main() |
151 main() |
151 |
152 |