alsterane / pylibnidaqmx

Automatically exported from code.google.com/p/pylibnidaqmx
Other
0 stars 0 forks source link

register_every_n_samples_event function doesn't work #7

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.connect NI USB-6008 
2.run AI_callback.py

What is the expected output? What do you see instead?
The callback function, processData, should be called around 10 times. It
was called only one time and then report an error.

>>> etner processData
[1.7970646050673522, 1.7984920817111949, 1.7988999321808641,
1.798899932180865, 1.7986960069460296, 1.7978803060066901,
1.7980842312415248, 1.797472455537021, 1.7968606798325175, 1.7976763807718563]
Traceback (most recent call last):
  File
"C:\Python26\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 322, in RunScript
    debugger.run(codeObject, __main__.__dict__, start_stepping=0)
  File
"C:\Python26\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line
60, in run
    _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
  File
"C:\Python26\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line
655, in run
    exec cmd in globals, locals
  File "C:\Python26\AI_callback.py", line 21, in <module>
    task.stop()
  File "C:\Python26\lib\site-packages\nidaqmx\libnidaqmx.py", line 787, in stop
    return CALL('StopTask', self) == 0
  File "C:\Python26\lib\site-packages\nidaqmx\libnidaqmx.py", line 187, in CALL
    r = CHK(r, funcname, *new_args)
  File "C:\Python26\lib\site-packages\nidaqmx\libnidaqmx.py", line 168, in CHK
    raise RuntimeError('%s%s:%s' % (funcname,args, text))
RuntimeError: DAQmxStopTask(AnalogInputTask('_unnamedTask<5>'),):
  Measurements: Task specified is invalid or does not exist.
  ----------

What version of the product are you using? On what operating system?
I am using NI USB-6008 on windows PC.

Please provide any additional information below.
I tried register_done_event with finite AI mode, it has the same the problems. 

Original issue reported on code.google.com by liujiny...@gmail.com on 28 Apr 2010 at 8:37

Attachments:

GoogleCodeExporter commented 9 years ago
Hello,

attached you will find a patch that fixes the problem. The drawback is that the 
task parameter now contains the task_handle (an integer) not the task object 
itself so you need to fix that in your AI_callback.py.

Maybe it would be a good idea to register a local callback that calls the 
callback given by the user, using the task object as parameter and maybe also a 
data array.
I also suggest to update the documentation as it was very confusing for me when 
I first tried to use this event. I can come up with a patch for that but I 
would like to know other opinions about the local callback part.

I guess that the done_event and signal_event have the same problem which can be 
fixed the same way, but I haven't tested this.

Best wishes,

Tobias

Original comment by m...@tobiasgehring.de on 29 Aug 2010 at 1:33

Attachments:

GoogleCodeExporter commented 9 years ago
I 'fixed' this - although it is probably not fully thread-safe. The callback 
function now gets:
 * a Task object from the Task cache, so no new Tasks are created in the callback
 * the data retrieved from the DAQ card (instead of the number of samples).

It's a breaking API change, though, I guess. A more simple patch would not add 
the data as a parameter, which won't break the API.

Original comment by valhall...@gmail.com on 24 Feb 2011 at 1:43

Attachments: