Mar-14-2017, 08:16 PM
Larz60+,
Thanks for your help, but neither of the options presented could open this file, and I don't know why. The second simply said it wasn't supported.
Thanks for all of your help, though.
sparkz_alot,
This is the code that I have presently. I don't think it will help you all that much because the error generated is not in python, its an error code coming from the function itself as it actually only returns errors (or 0 if no errors). However, I need to access the variable "testVal" after running the imported dll file. That's the part I don't know how to do.
Zach
Zach
Thanks for your help, but neither of the options presented could open this file, and I don't know why. The second simply said it wasn't supported.
Thanks for all of your help, though.
sparkz_alot,
This is the code that I have presently. I don't think it will help you all that much because the error generated is not in python, its an error code coming from the function itself as it actually only returns errors (or 0 if no errors). However, I need to access the variable "testVal" after running the imported dll file. That's the part I don't know how to do.
# import all necessary libraries import ctypes import time from ctypes import * import os import usb.core as usbc import usb.util as usbu # Step 1: Locate the cbw32.dll file #This loop looks through the dierectory starting in the Program Files (x86) #and finds the file path to the cbw32.dll file necessary for the Universal #Library and names it path path = '' #initialize path to be used later import os for root, dirs, files in os.walk('E:\Program Files (x86)'): for name in files: if 'cbw64.dll' in name: print(root + '\cbw64.dll') path = root + '\cbw64.dll' # Step 2: import the .dll file from the Omega Universal Library dll = cdll.LoadLibrary(path) # Test the function boardNum=ctypes.c_int(0) chan=ctypes.c_int(1) scale=ctypes.c_int(0) testVal=ctypes.c_float(0) option=ctypes.c_int(0) #boardNum=0 #chan=0 #scale=0 #testVal=0.0 #option=0 for num in range(0,100): test2 = dll.cbTIn(boardNum,chan,scale,testVal,option) print(test2) time.sleep(1)If I run the program using the ctypes definitions for the integers, I get an error code "35" which corresponds to:
Error:An invalid (NULL) pointer was passed as an argument/parameter to a function or method.
However, if I run the code without using the ctypes definitions I get an error code from python saying:Error:Traceback (most recent call last):
File "<ipython-input-1-590ecd1f49cf>", line 1, in <module>
runfile('E:/Users/Zachary/documents/Senior Design Python and Daq/DaqComV1p1.py', wdir='E:/Users/Zachary/documents/Senior Design Python and Daq')
File "E:\Users\Zachary\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "E:\Users\Zachary\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "E:/Users/Zachary/documents/Senior Design Python and Daq/DaqComV1p1.py", line 48, in <module>
test2 = dll.cbTIn(boardNum,chan,scale,testVal,option)
ArgumentError: argument 4: <class 'TypeError'>: Don't know how to convert parameter 4
Thank you,Zach
Zach