Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Python command with USB-6009

Solved!
Go to solution

Hi,

 

I try to use USB-6009 in Python 2.6 environment at Win7 64bit system and I'm facing  issues with following command.

 

 

 

The following issues I see following error command

 

  1. dll = windll.LoadLibrary("C:\\Windows\\System32\\nicaiu.dll")
    ...
    ....#command with return value!=0
    error_str=c_char_p('')
    b_size=c_uint(2048)
    ret_a=dll.DAQmxGetExtendedErrorInfo(error_str,b_size)

    Following the last command the python  I get the attached error message
    Am I doing something wrong? 

Thank you for help,

 

 

 

0 Kudos
Message 1 of 3
(4,295 Views)
Solution
Accepted by topic author Katerina

Hi Katerina

 

You could try replacing 'c_char_p' with 'create_string_buffer.' According to the Python reference library , "you should be careful, however, not to pass them (edit: c_char_p) to functions expecting pointers to mutable memory. If you need mutable memory blocks, ctypes has a create_string_buffer() function which creates these in various ways."

 

from ctypes import *

dll = windll.LoadLibrary("c:\\windows\\system32\\nicaiu.dll")
error_str = create_string_buffer(2048) # try this instead of c_char_p("")
b_size=c_uint(2048) 
task_handle = c_uint(0)
error = dll.DAQmxStartTask(task_handle) #this will result in an error
try:
    dll.DAQmxGetExtendedErrorInfo(error_str, b_size)
    print error_str.value
except:
    print "oops"

 

Let me know if this helps.

 

Regards,

Sunil

Message 2 of 3
(4,279 Views)

It works, Thanks a lot.

0 Kudos
Message 3 of 3
(4,250 Views)