I want to modify settings of a National Instruments PXI system via pyvisa. In particular, I want to programmatically route a trigger from bus 1 to bus 2 on the backplane.
There is a documentation by National Instruments which explains the process via a Labview VI:
This basically tells me to
Step 1) works fine via pyvisa, I can open a communication with the backplane via backplane = rm.open_resource('PXI0::2::BACKPLANE')
, as described in the resource names.
But after having opened a visa session to the backplane, I cannot find any of the described src trig bus and dest trig bus attributes here. There is only a bunch of attribute classes such as AttrVI_ATTR_RM_SESSION, which do not seem to contain any of the values I am interested in. But I guess I am misunderstanding something here.
Step 3) would be straightforward, as this functionality is directly implemented in pyvisa.
So the remaining question is: How can I modify the source trigger bus and destination trigger bus in a PXI backplane via pyvisa?
I found the location of all required attributes: pyvisa.constants lists all addresses of all possible attributes (for any interface).
To access a specific attribute, this can be implemented via the set_visa_attributes function:
import pyvisa
import pyvisa.constants
address = 'PXI0::2::BACKPLANE'
rm = pyvisa.ResourceManager()
backplane = rm.open_resource(address)
src_bus = 2
dest_bus = 1
trigger = pyvisa.constants.VI_TRIG_TTL0 # i.e. PXI_Trig0
backplane.set_visa_attribute(pyvisa.constants.VI_ATTR_PXI_SRC_TRIG_BUS, src_bus)
backplane.set_visa_attribute(pyvisa.constants.VI_ATTR_PXI_DEST_TRIG_BUS, dest_bus)
# route trigger 0 from source bus to destination bus
backplane.visalib.map_trigger(backplane.session, trigger, trigger, pyvisa.constants.VI_NULL)