diff options
author | Anthony LaTorre <devnull@localhost> | 2013-02-28 17:29:06 -0600 |
---|---|---|
committer | Anthony LaTorre <devnull@localhost> | 2013-02-28 17:29:06 -0600 |
commit | 19bb5dc974e009b2591c2015910a66035dfaf383 (patch) | |
tree | fcd07ada82bbbd6faeac0ad7d5ebcbb6a9d0b749 /tektronix.py | |
parent | 42de6f6613a2088c8f5bb5af7a8ccb519a7ed7c8 (diff) | |
download | lecrunch-19bb5dc974e009b2591c2015910a66035dfaf383.tar.gz lecrunch-19bb5dc974e009b2591c2015910a66035dfaf383.tar.bz2 lecrunch-19bb5dc974e009b2591c2015910a66035dfaf383.zip |
start of module for communicating with tektronix scopes.
Diffstat (limited to 'tektronix.py')
-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 |