-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPIB.py
42 lines (31 loc) · 1.18 KB
/
GPIB.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
import os,sys,ctypes
gpib=getattr(ctypes.windll,"gpib-32")
RQS = (1<<11)
SRQ = (1<<12)
TIMO = (1<<14)
class Gpib:
def __init__(self,name='gpib0'):
self.id = gpib.ibfindA(name)
def set_term_CR(self):
gpib.ibeos(self.id, 0x140D)
def close(self):
gpib.ibonl(self.id,0)
def write(self,str):
gpib.ibwrt(self.id, str,len(str))
def read(self,leng=512):
result = ctypes.c_char_p('\000' * leng)
retval = gpib.ibrd(self.id,result,leng)
return result.value
def readb(self,leng=512):
result = ctypes.c_buffer(leng)
retval = gpib.ibrd(self.id,result,leng)
return result.raw
def clear(self):
gpib.ibclr(self.id)
def rsp(self):
result = ctypes.c_char_p('\000')
self.spb = gpib.ibrsp(self.id,result)
if len(result.value)>0:
return ord(result.value)
else:
return -256