HP3562A/dump_datablock.py

changeset 17
fb8aa055f6e4
parent 14
07e2cbf140df
equal deleted inserted replaced
16:de9122b5680a 17:fb8aa055f6e4
3 import gpib 3 import gpib
4 import prologix 4 import prologix
5 5
6 6
7 class HP3562dumper(prologix.GPIB): 7 class HP3562dumper(prologix.GPIB):
8 8 """
9 Class dedicated to dump data blocks from HP3562A DSA (trace,
10 internal state or coordinate).
11 """
9 MODES = {'trace': 'DD', 12 MODES = {'trace': 'DD',
10 'state': 'DS', 13 'state': 'DS',
11 'coord': 'DC', 14 'coord': 'DC',
12 } 15 }
13 16
18 def __init__(self, device="/dev/ttyUSB0", baudrate=115200, timeout=0.1, 21 def __init__(self, device="/dev/ttyUSB0", baudrate=115200, timeout=0.1,
19 address=0): 22 address=0):
20 super(HP3562dumper, self).__init__(device, baudrate, timeout, address, mode=1) 23 super(HP3562dumper, self).__init__(device, baudrate, timeout, address, mode=1)
21 24
22 def dump(self, mode='trace', format="binary"): 25 def dump(self, mode='trace', format="binary"):
26 """
27 Dump the required data block and return it as a raw string buffer.
28
29 'mode' can be 'trace' [default], 'state' or 'coord'.
30 'format' can be 'binary' [default], 'ascii' or 'ansi'.
31 """
23 format = format.lower() 32 format = format.lower()
24 mode = mode.lower() 33 mode = mode.lower()
25 assert mode in self.MODES 34 assert mode in self.MODES
26 assert format in self.FORMATS 35 assert format in self.FORMATS
27 cmd = self.MODES[mode] + self.FORMATS[format] 36 cmd = self.MODES[mode] + self.FORMATS[format]

mercurial