Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

viOpenDefaultRM returns -1073807300 using Python 2.6

Hi

I have tried one of the NI Python examples for VISA programming (see below).

But the viOpenDefaultRM returns an error -1073807300.

I'm very new at Python,- but it seems that Python converts my ctype int to a long and maybe viOpenDefaultRM can't support that. But I'm just guessing.

Anyone knows whats wrong?

 

My GPIB/VISA installation works fine using C++.

 

best regards

Carsten 

 

#!/usr/bin/env python
import sys

from ctypes import *

dll = windll.LoadLibrary("visa32.dll")

#Steps:
#    1. Open Resource Manager                                      
#    2. Open VISA Session to an Instrument
#    3. Set Timeout Attribute
#    4. Write the Identification Query Using viWrite               
#    5. Try to Read a Response With viRead                         
#    6. Close the VISA Session & Resource Manager
#    7. Display an error if any.

#Note: All VISA function return 0 on success.
#This example checks for 0 at each step and reports an error for non-zero return values

##############################
#Open Resource Manager
##############################
resourceManagerHandle = c_int(0)        ##Resource Manager Handle

print "Opening Resource Manager"

#First get the resource manager handle. This will be used next to get a handle to the instrument
#Function Prototype: ViStatus viOpenDefaultRM(ViPSession sesn)
returnValue = dll.viOpenDefaultRM(byref(resourceManagerHandle))

if returnValue != 0:
    print >> sys.stderr, "Could not open Resource Manager. Error: ", returnValue
    sys.exit(returnValue)

 

0 Kudos
Message 1 of 2
(2,091 Views)

Problem solved......

 

I used

dll = windll.LoadLibrary("c:\Python26\visa32.dll")

instead of the one posted. I copied the dll to the Python dir. Not a good idea.

 

Best regards

Carsten

0 Kudos
Message 2 of 2
(2,073 Views)