From 5312847b46b43e4a6bfb3e151d1b7b8314df00d2 Mon Sep 17 00:00:00 2001 From: Stefan Droege Date: Thu, 1 Jun 2017 09:48:18 +0200 Subject: [PATCH 1/2] fix #9 missing path to nidaqmx module in sphinx Fixes issue #9, where building of the Sphinx doc fails. By adding `../` to the path during the Sphinx doc build, sphinx can find the module source even if the package was not previously installed. --- docs/conf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3cbfaf85..3b64952e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,9 +16,9 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) +import os +import sys +sys.path.insert(0, os.path.abspath('../')) # -- General configuration ------------------------------------------------ From 38f9f09c8fc80d9d729ad27deeddeba9c81a08a4 Mon Sep 17 00:00:00 2001 From: CarlAndersson Date: Thu, 6 Jul 2017 15:41:10 +0200 Subject: [PATCH 2/2] Fix for unregistering callbacks A possible fix to enable unregistering of callback functions. Only tested with 'register_every_n_samples_acquired_into_buffer_event', but should work with all versions. --- nidaqmx/task.py | 65 +++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/nidaqmx/task.py b/nidaqmx/task.py index afebe12f..d553fe4b 100644 --- a/nidaqmx/task.py +++ b/nidaqmx/task.py @@ -716,17 +716,21 @@ def register_done_event(self, callback_method): DAQmxDoneEventCallbackPtr = ctypes.CFUNCTYPE( ctypes.c_int32, lib_importer.task_handle, ctypes.c_int32, ctypes.c_void_p) - + + cfunc = lib_importer.windll.DAQmxRegisterDoneEvent + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_uint, DAQmxDoneEventCallbackPtr, + ctypes.c_void_p] + if callback_method is not None: callback_method_ptr = DAQmxDoneEventCallbackPtr(callback_method) self._done_event_callbacks.append(callback_method_ptr) else: del self._done_event_callbacks[:] - - cfunc = lib_importer.windll.DAQmxRegisterDoneEvent - cfunc.argtypes = [ - lib_importer.task_handle, ctypes.c_uint, DAQmxDoneEventCallbackPtr, - ctypes.c_void_p] + callback_method_ptr = None + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_uint, ctypes.c_void_ptr, + ctypes.c_void_p] error_code = cfunc( self._handle, 0, callback_method_ptr, None) @@ -769,7 +773,12 @@ def register_every_n_samples_acquired_into_buffer_event( DAQmxEveryNSamplesEventCallbackPtr = ctypes.CFUNCTYPE( ctypes.c_int32, lib_importer.task_handle, ctypes.c_int32, ctypes.c_uint32, ctypes.c_void_p) - + + cfunc = lib_importer.windll.DAQmxRegisterEveryNSamplesEvent + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, + ctypes.c_uint, DAQmxEveryNSamplesEventCallbackPtr, ctypes.c_void_p] + if callback_method is not None: callback_method_ptr = DAQmxEveryNSamplesEventCallbackPtr( callback_method) @@ -777,11 +786,10 @@ def register_every_n_samples_acquired_into_buffer_event( callback_method_ptr) else: del self._every_n_acquired_event_callbacks[:] - - cfunc = lib_importer.windll.DAQmxRegisterEveryNSamplesEvent - cfunc.argtypes = [ - lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, - ctypes.c_uint, DAQmxEveryNSamplesEventCallbackPtr, ctypes.c_void_p] + callback_method_ptr = None + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, + ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p] error_code = cfunc( self._handle, EveryNSamplesEventType.ACQUIRED_INTO_BUFFER.value, @@ -826,6 +834,12 @@ def register_every_n_samples_transferred_from_buffer_event( ctypes.c_int32, lib_importer.task_handle, ctypes.c_int32, ctypes.c_uint32, ctypes.c_void_p) + cfunc = lib_importer.windll.DAQmxRegisterEveryNSamplesEvent + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, + ctypes.c_uint, DAQmxEveryNSamplesEventCallbackPtr, + ctypes.c_void_p] + if callback_method is not None: callback_method_ptr = DAQmxEveryNSamplesEventCallbackPtr( callback_method) @@ -833,13 +847,12 @@ def register_every_n_samples_transferred_from_buffer_event( callback_method_ptr) else: del self._every_n_transferred_event_callbacks[:] - - cfunc = lib_importer.windll.DAQmxRegisterEveryNSamplesEvent - cfunc.argtypes = [ - lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, - ctypes.c_uint, DAQmxEveryNSamplesEventCallbackPtr, - ctypes.c_void_p] - + callback_method_ptr = None + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, + ctypes.c_uint, ctypes.c_void_p, + ctypes.c_void_p] + error_code = cfunc( self._handle, EveryNSamplesEventType.TRANSFERRED_FROM_BUFFER.value, sample_interval, 0, callback_method_ptr, None) @@ -877,17 +890,21 @@ def register_signal_event(self, signal_type, callback_method): DAQmxSignalEventCallbackPtr = ctypes.CFUNCTYPE( ctypes.c_int32, lib_importer.task_handle, ctypes.c_int32, ctypes.c_void_p) + + cfunc = lib_importer.daqlib.DAQmxRegisterSignalEvent + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, + DAQmxSignalEventCallbackPtr, ctypes.c_void_p] if callback_method is not None: callback_method_ptr = DAQmxSignalEventCallbackPtr(callback_method) self._signal_event_callbacks.append(callback_method_ptr) else: del self._signal_event_callbacks[:] - - cfunc = lib_importer.daqlib.DAQmxRegisterSignalEvent - cfunc.argtypes = [ - lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, - DAQmxSignalEventCallbackPtr, ctypes.c_void_p] + callback_method_ptr = None + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_int, ctypes.c_uint, + ctypes.c_void_ptr, ctypes.c_void_p] error_code = cfunc( self._handle, signal_type.value, 0, callback_method_ptr, None)