Skip to content
This repository was archived by the owner on Feb 2, 2026. It is now read-only.

Commit 14bbec0

Browse files
committed
Add create_setup and send_setup
1 parent 105dd46 commit 14bbec0

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

vxi11/vxi11.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@
104104
CMD_BUS_STATUS_LISTENER = 7
105105
CMD_BUS_STATUS_BUS_ADDRESS = 8
106106

107+
GPIB_CMD_GTL = 0x01 # go to local
108+
GPIB_CMD_SDC = 0x04 # selected device clear
109+
GPIB_CMD_PPC = 0x05 # parallel poll config
110+
GPIB_CMD_GET = 0x08 # group execute trigger
111+
GPIB_CMD_TCT = 0x09 # take control
112+
GPIB_CMD_LLO = 0x11 # local lockout
113+
GPIB_CMD_DCL = 0x14 # device clear
114+
GPIB_CMD_PPU = 0x15 # parallel poll unconfigure
115+
GPIB_CMD_SPE = 0x18 # serial poll enable
116+
GPIB_CMD_SPD = 0x19 # serial poll disable
117+
GPIB_CMD_LAD = 0x20 # listen address (base)
118+
GPIB_CMD_UNL = 0x3F # unlisten
119+
GPIB_CMD_TAD = 0x40 # talk address (base)
120+
GPIB_CMD_UNT = 0x5F # untalk
121+
GPIB_CMD_SAD = 0x60 # my secondary address (base)
122+
GPIB_CMD_PPE = 0x60 # parallel poll enable (base)
123+
GPIB_CMD_PPD = 0x70 # parallel poll disable
124+
107125
def parse_visa_resource_string(resource_string):
108126
# valid resource strings:
109127
# TCPIP::10.0.0.1::INSTR
@@ -805,6 +823,29 @@ def send_command(self, data):
805823

806824
return data_out
807825

826+
def create_setup(self, address_list):
827+
data = bytearray([self._bus_address | GPIB_CMD_TAD, GPIB_CMD_UNL])
828+
829+
for addr in address_list:
830+
if type(addr) == tuple:
831+
if addr[0] < 0 or addr[0] > 30:
832+
raise Vxi11Exception("Invalid address", 'create_setup')
833+
data.append(addr[0] | GPIB_CMD_LAD)
834+
if len(addr) > 1:
835+
if addr[1] < 0 or addr[1] > 30:
836+
raise Vxi11Exception("Invalid address", 'create_setup')
837+
data.append(addr[1] | GPIB_CMD_SAD)
838+
else:
839+
if addr < 0 or addr > 30:
840+
raise Vxi11Exception("Invalid address", 'create_setup')
841+
data.append(addr | GPIB_CMD_LAD)
842+
843+
return bytes(data)
844+
845+
def send_setup(self, address_list):
846+
"Send setup"
847+
return self.send_command(self.create_setup(address_list))
848+
808849
def _bus_status(self, val):
809850
"Bus status"
810851
if self.link is None:

0 commit comments

Comments
 (0)