From 1f1c39cf45cb4025366712c43bc9aaba3e23fdf1 Mon Sep 17 00:00:00 2001 From: archerleong Date: Thu, 11 Aug 2022 02:45:00 -0500 Subject: [PATCH 1/2] add support for reverse voltage error attributes --- nidaqmx/_task_modules/in_stream.py | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/nidaqmx/_task_modules/in_stream.py b/nidaqmx/_task_modules/in_stream.py index b839c4f1..c4779556 100644 --- a/nidaqmx/_task_modules/in_stream.py +++ b/nidaqmx/_task_modules/in_stream.py @@ -1932,6 +1932,66 @@ def remote_sense_error_chans_exist(self): return val.value + @property + def reverse_voltage_error_chans(self): + """ + List[str]: Indicates a list of names of any virtual channels in the + task for which reverse voltage error condition has been detected. + You must read the Reverse Voltage Error Channels Exist property before + you read this property. Otherwise, you will receive an error. + """ + cfunc = lib_importer.windll.DAQmxGetReverseVoltageErrorChans + if cfunc.argtypes is None: + with cfunc.arglock: + if cfunc.argtypes is None: + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.c_char_p, + ctypes.c_uint] + + temp_size = 0 + while True: + val = ctypes.create_string_buffer(temp_size) + + size_or_code = cfunc( + self._handle, val, temp_size) + + if is_string_buffer_too_small(size_or_code): + # Buffer size must have changed between calls; check again. + temp_size = 0 + elif size_or_code > 0 and temp_size == 0: + # Buffer size obtained, use to retrieve data. + temp_size = size_or_code + else: + break + + check_for_error(size_or_code) + + return unflatten_channel_string(val.value.decode('ascii')) + + @property + def reverse_voltage_error_chans_exist(self): + """ + bool: Indicates if the device(s) detected reverse voltage error for any channel in + the task. Reverse voltage error will occured if the local voltage is equal to negative + saturated voltage. Reading this property clears the error condition status for all channels + in the task. You must read this property before you read the Reverse Voltage Error Channels + property. Otherwise, you will receive an error. + """ + val = c_bool32() + + cfunc = lib_importer.windll.DAQmxGetReverseVoltageErrorChansExist + if cfunc.argtypes is None: + with cfunc.arglock: + if cfunc.argtypes is None: + cfunc.argtypes = [ + lib_importer.task_handle, ctypes.POINTER(c_bool32)] + + error_code = cfunc( + self._handle, ctypes.byref(val)) + check_for_error(error_code) + + return val.value + @property def sleep_time(self): """ From 8ea4a693feaffb57c2c5c9497d397e3d16d75eb0 Mon Sep 17 00:00:00 2001 From: Archer Leong Date: Thu, 11 Aug 2022 21:02:53 -0500 Subject: [PATCH 2/2] Replace in_stream.py to in_stream.py generated by internal generator --- nidaqmx/_task_modules/in_stream.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nidaqmx/_task_modules/in_stream.py b/nidaqmx/_task_modules/in_stream.py index c4779556..c4d6f2c7 100644 --- a/nidaqmx/_task_modules/in_stream.py +++ b/nidaqmx/_task_modules/in_stream.py @@ -1935,10 +1935,11 @@ def remote_sense_error_chans_exist(self): @property def reverse_voltage_error_chans(self): """ - List[str]: Indicates a list of names of any virtual channels in the - task for which reverse voltage error condition has been detected. - You must read the Reverse Voltage Error Channels Exist property before - you read this property. Otherwise, you will receive an error. + List[str]: Indicates a list of names of any virtual channels in + the task for which reverse voltage error condition has been + detected. You must read the Reverse Voltage Error Channels + Exist property before you read this property. Otherwise, you + will receive an error. """ cfunc = lib_importer.windll.DAQmxGetReverseVoltageErrorChans if cfunc.argtypes is None: @@ -1971,10 +1972,12 @@ def reverse_voltage_error_chans(self): @property def reverse_voltage_error_chans_exist(self): """ - bool: Indicates if the device(s) detected reverse voltage error for any channel in - the task. Reverse voltage error will occured if the local voltage is equal to negative - saturated voltage. Reading this property clears the error condition status for all channels - in the task. You must read this property before you read the Reverse Voltage Error Channels + bool: Indicates if the device(s) detected reverse voltage error + for any channel in the task. Reverse voltage error will + occured if the local voltage is equal to negative saturated + voltage. Reading this property clears the error condition + status for all channels in the task. You must read this + property before you read the Reverse Voltage Error Channels property. Otherwise, you will receive an error. """ val = c_bool32()