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
|
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
|