01-27-2011 09:28 AM
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)
01-28-2011 03:05 AM
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