forked from bsdphk/pylt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tds540a.py
66 lines (56 loc) · 1.4 KB
/
tds540a.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/local/bin/python
import sys
import time
import prologix_usb
import pcl_util
class tds540a(prologix_usb.gpib_dev):
def __init__(self, name = "gpib0", adr = 1):
prologix_usb.gpib_dev.__init__(self, name, adr)
self.attr("read_tmo_ms", 2000)
self.attr("rd_mode", 10)
self.attr("autocr", 1)
self.errors()
x = self.ask("*IDN?").split(",")
if x[0] != "TEKTRONIX" or x[1] != "TDS 540A":
self.fail("TDS540A ID Failure (%s)" % x)
self.id = "TDS540A"
self.AOK()
#######################
# PYLT Standard methods
#######################
def errors(self, f=sys.stderr):
r = False
while int(self.ask("*ESR?")) & 0x20:
x = self.ask("EVMsg?")
if x == '0,"No events to report - queue empty"':
break
f.write(self.id + ".ERROR: " + x + "\n")
r = True
return r
def reset(self):
self.wr("*RST");
self.AOK()
def screen_dump(self, fname = "_.tds540a.pbm"):
print(self.id + " Taking a screendump into " + fname)
self.AOK()
self.wr("HARDCOPY abort")
self.AOK()
self.wr("CLEARMenu")
self.AOK()
self.wr("HARDCOPY:FORMAT THINKJET")
self.wr("HARDCOPY:LAYOUT PORTRAIT")
self.wr("HARDCOPY:PORT GPIB")
self.AOK()
self.wr("HARDCOPY start")
x = ""
while True:
y = self.rd()
x = x + y
if y[-1:] == "\014":
break
pcl_util.pcl_to_pbm(x, fname)
if __name__ == "__main__":
d = tds540a()
print("Device responds: " + d.ask("*IDN?"))
d.AOK()
d.screen_dump()