Permalink
Browse files

driver/usbtmc: add basic support for Tektronix TDS2000

This was tested on a TDS2014B.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
  • Loading branch information...
jluebbe committed Sep 5, 2018
1 parent 8222fa9 commit 10c485c8c1d107089a4f674ad2159ddce4f4ea53
Showing with 47 additions and 4 deletions.
  1. +30 −0 labgrid/driver/usbtmc/tektronix_tds2000.py
  2. +15 −2 labgrid/driver/usbtmcdriver.py
  3. +2 −2 labgrid/remote/client.py
@@ -0,0 +1,30 @@
def get_channel_info(driver, channel):
info = {}
info['SELECTED'] = driver.get_str("SELect:CH%i?" % channel).strip()
info['BWLIMIT'] = driver.get_str(":CH%i:BANdwidth?" % channel).strip()
info['COUPLING'] = driver.get_str(":CH%i:COUPling?" % channel).strip()
info['INVERT'] = driver.get_str(":CH%i:INVert?" % channel).strip()
info['POSITION'] = driver.get_decimal(":CH%i:POSition?" % channel)
info['PROBE'] = driver.get_decimal(":CH%i:PRObe?" % channel)
info['SCALE'] = driver.get_decimal(":CH%i:SCAle?" % channel)
return info
def get_channel_values(driver, channel):
driver.command(":MEASUrement:IMMed:SOUrce1 CH%i" % channel)
info = {}
driver.command(":MEASUrement:IMMed:TYPe MEAN")
info['MEAN'] = driver.get_decimal(":MEASUrement:IMMed:VALue?")
driver.command(":MEASUrement:IMMed:TYPe FREQuency")
info['FREQUENCY'] = driver.get_decimal(":MEASUrement:IMMed:VALue?")
driver.command(":MEASUrement:IMMed:TYPe PK2pk")
info['PK2PK'] = driver.get_decimal(":MEASUrement:IMMed:VALue?")
driver.command(":MEASUrement:IMMed:TYPe MINImum")
info['MINIMUM'] = driver.get_decimal(":MEASUrement:IMMed:VALue?")
driver.command(":MEASUrement:IMMed:TYPe MAXImum")
info['MAXIMUM'] = driver.get_decimal(":MEASUrement:IMMed:VALue?")
return info
def get_screenshot_tiff(driver):
driver.command(":hardcopy:format tiff")
tiff = driver.query(':hardcopy start', raw=True)
return tiff
@@ -33,6 +33,8 @@ def on_activate(self):
match = (self.tmc.vendor_id, self.tmc.model_id)
if match == (0x0957, 0x1798):
model = 'keysight_dsox2000'
elif match == (0x0699, 0x0368):
model = 'tektronix_tds2000'
else:
raise InvalidConfigError("Unkown USB TMC device {:04x}:{:04x}".format(*match))
@@ -55,10 +57,14 @@ def command(self, cmd):
self.wrapper.usbtmc(self.index, cmd, read=False)
@Driver.check_active
def query(self, cmd, binary=False):
def query(self, cmd, binary=False, raw=False):
assert isinstance(cmd, str)
cmd = b2s(cmd.encode('ASCII')+b'\n')
res = s2b(self.wrapper.usbtmc(self.index, cmd, read=True))
if raw:
return res
if binary:
assert res[0:1] == b'#'
digits = int(res[1:2], 10)
@@ -82,7 +88,14 @@ def get_channel_values(self, channel):
@Driver.check_active
def get_screenshot(self):
return self.backend.get_screenshot_png(self)
png = getattr(self.backend, 'get_screenshot_png', None)
tiff = getattr(self.backend, 'get_screenshot_tiff', None)
if png:
return 'png', png(self)
elif tiff:
return 'tiff', tiff(self)
else:
raise InvalidConfigError("get_screenshot_png/_tiff not implemented")
@Driver.check_active
def get_bool(self, cmd):
View
@@ -873,8 +873,8 @@ def tmc_screen(self):
drv = self._get_tmc()
action = self.args.action
if action in ['show', 'save']:
data = drv.get_screenshot()
filename = 'tmc-screen_{0:%Y-%m-%d}_{0:%H:%M:%S}.png'.format(datetime.now())
format, data = drv.get_screenshot()
filename = 'tmc-screen_{0:%Y-%m-%d}_{0:%H:%M:%S}.{1}'.format(datetime.now(), format)
open(filename, 'wb').write(data)
print("Saved as {}".format(filename))
if action == 'show':

0 comments on commit 10c485c

Please sign in to comment.