diff options
-rw-r--r-- | tektronix.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tektronix.py b/tektronix.py new file mode 100644 index 0000000..d18885f --- /dev/null +++ b/tektronix.py @@ -0,0 +1,37 @@ +import socket + +preamble_fields = {'BYT_NR': int, # data width for waveform + 'BIT_NR': int, # number of bits per waveform point + 'ENCDG' : str, # encoding of waveform (binary/ascii) + 'BN_FMT': str, # binary format of waveform + 'BYT_OR': str, # ordering of waveform data bytes (LSB/MSB) + 'NR_PT' : int, # record length of record waveform + 'WFID' : str, # description string of waveform + 'PT_FMT': str, # format of reverence waveform (Y/ENV) + 'PT_OFF': int, + 'XZERO' : float, + 'XUNIT' : str, + 'YMULT' : float, + 'YZERO' : float, + 'YOFF' : float, + 'YUNIT' : str, + 'NR_FR' : int } + +class TekScope(object): + def __init__(self, host, port): + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.sock.connect((host,port)) + + def send(self, msg): + self.sock.sendall(msg) + + def recv(self): + buffer = '' + + while True: + buffer += self.sock.recv(1024) + + if buffer.endswith('\n'): + break + + return buffer |