-
Notifications
You must be signed in to change notification settings - Fork 11
/
instrument.py
46 lines (31 loc) · 1.08 KB
/
instrument.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
import os
class usbtmc:
"""Simple implementation of a USBTMC device driver, in the style of visa.h"""
def __init__(self, device):
self.device = device
self.FILE = os.open(device, os.O_RDWR)
# TODO: Test that the file opened
def write(self, command):
os.write(self.FILE, command);
def read(self, length = 4000):
return os.read(self.FILE, length)
def getName(self):
self.write("*IDN?")
return self.read(300)
def sendReset(self):
self.write("*RST")
class RigolScope:
"""Class to control a Rigol DS1000 series oscilloscope"""
def __init__(self, device):
self.meas = usbtmc(device)
self.name = self.meas.getName()
print self.name
def write(self, command):
"""Send an arbitrary command directly to the scope"""
self.meas.write(command)
def read(self, command):
"""Read an arbitrary amount of data directly from the scope"""
return self.meas.read(command)
def reset(self):
"""Reset the instrument"""
self.meas.sendReset()