The simplest way (IMHO) to access a VISA resource is still by using the VISA device detection which would be through:
visa.ResourceManager().list_resources(), if you're using pyVisa
- or
viFindRsrc() and viFindNext() if you use the visa32.dll library.
Now by default, LAN connections are not detected using either method. This leaves you with two choices:
- If you have installed NI-MAX (the Measurement & Automation Explorer from National Instruments is a free download), go under 'Devices & Interfaces', right-click on 'Network Devices', select 'Create New VISA TCP/IP Resource...' and follow the instructions. NI-MAX will auto detect your instrument and provide its VISA resource name. Note that now this resource will be listed by both
list_resources() and viFindRsrc()/viFindNext()
- If not, you will have to provide VISA with the right resource name. If you use a VISA passport (e.g. VICP for LeCroy oscilloscopes) then you should change the VISA header appropriately (replace TCPIP with VICP). Then, the syntax is the following: [visa-header]::[instrument-ip]::INSTR or [visa-header]::[instrument-ip]::[instrument-port]::INSTR
Actually, it's not always INSTR, depending on the resource class (see http://zone.ni.com/reference/en-XX/help/371361J-01/lvinstio/visa_resource_name_generic/).
Be sure to send byte strings to the instrument (especially if using Python 3+), otherwise you will get the following error:
VI_ERROR_RSRC_NFOUND: Insufficient location information or the requested device or resource is not present in the system
which can also be identified by 0xBFFF0011 or a return value of -1073807343.