diff --git a/CHANGELOG.md b/CHANGELOG.md index c6117b654..4ee1a29cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1708,6 +1708,7 @@ - `numpy` is now an install dependency - gRPC support, enabling remote session management via NI gRPC Device Server - Changed + - Fixed `error_message` method to return the error string as output - Removed #### [nirfsg] 1.0.1 - 2026-01-09 diff --git a/docs/nirfsg/class.rst b/docs/nirfsg/class.rst index 6d0cfd285..d41c0cf8a 100644 --- a/docs/nirfsg/class.rst +++ b/docs/nirfsg/class.rst @@ -1163,7 +1163,7 @@ error_message .. py:currentmodule:: nirfsg.Session - .. py:method:: error_message(error_code, error_message) + .. py:method:: error_message(error_code) Converts an error code returned by an NI-RFSG method into a user-readable string. @@ -1184,17 +1184,16 @@ error_message :type error_code: int - :param error_message: + :rtype: str + :return: - Returns the user-readable message string that corresponds to the status code you specify. - You must pass a ViChar array with at least 256 bytes to this parameter. + Returns the user-readable message string that corresponds to the status code you specify. - + - :type error_message: str get_all_named_waveform_names ---------------------------- diff --git a/generated/nirfsg/nirfsg/_grpc_stub_interpreter.py b/generated/nirfsg/nirfsg/_grpc_stub_interpreter.py index b1eae312e..da26eb175 100644 --- a/generated/nirfsg/nirfsg/_grpc_stub_interpreter.py +++ b/generated/nirfsg/nirfsg/_grpc_stub_interpreter.py @@ -241,11 +241,12 @@ def disable_start_trigger(self): # noqa: N802 grpc_types.DisableStartTriggerRequest(vi=self._vi), ) - def error_message(self, error_code, error_message): # noqa: N802 - self._invoke( + def error_message(self, error_code): # noqa: N802 + response = self._invoke( self._client.ErrorMessage, - grpc_types.ErrorMessageRequest(vi=self._vi, error_code=error_code, error_message=error_message), + grpc_types.ErrorMessageRequest(vi=self._vi, error_code=error_code), ) + return response.error_message def get_all_named_waveform_names(self): # noqa: N802 response = self._invoke( diff --git a/generated/nirfsg/nirfsg/_library_interpreter.py b/generated/nirfsg/nirfsg/_library_interpreter.py index 1b3f9e820..354881d32 100644 --- a/generated/nirfsg/nirfsg/_library_interpreter.py +++ b/generated/nirfsg/nirfsg/_library_interpreter.py @@ -298,13 +298,13 @@ def disable_start_trigger(self): # noqa: N802 errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return - def error_message(self, error_code, error_message): # noqa: N802 + def error_message(self, error_code): # noqa: N802 vi_ctype = _visatype.ViSession(self._vi) # case S110 error_code_ctype = _visatype.ViStatus(error_code) # case S150 - error_message_ctype = ctypes.create_string_buffer(error_message.encode(self._encoding)) # case C020 + error_message_ctype = (_visatype.ViChar * 256)() # case C070 error_code = self._library.niRFSG_ErrorMessage(vi_ctype, error_code_ctype, error_message_ctype) errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=True) - return + return error_message_ctype.value.decode(self._encoding) def get_all_named_waveform_names(self): # noqa: N802 vi_ctype = _visatype.ViSession(self._vi) # case S110 diff --git a/generated/nirfsg/nirfsg/session.py b/generated/nirfsg/nirfsg/session.py index 002e68253..0e131adc6 100644 --- a/generated/nirfsg/nirfsg/session.py +++ b/generated/nirfsg/nirfsg/session.py @@ -4833,7 +4833,7 @@ def disable_script_trigger(self): ''' self._interpreter.disable_script_trigger(self._repeated_capability) - def error_message(self, error_code, error_message): + def error_message(self, error_code): r'''error_message Converts an error code returned by an NI-RFSG method into a user-readable string. @@ -4845,12 +4845,13 @@ def error_message(self, error_code, error_message): **Default Value** : 0 (VI_SUCCESS) - error_message (str): Returns the user-readable message string that corresponds to the status code you specify. - You must pass a ViChar array with at least 256 bytes to this parameter. + Returns: + error_message (str): Returns the user-readable message string that corresponds to the status code you specify. ''' - self._interpreter.error_message(error_code, error_message) + error_message = self._interpreter.error_message(error_code) + return error_message @ivi_synchronized def _get_attribute_vi_boolean(self, attribute): diff --git a/generated/nirfsg/nirfsg/unit_tests/_mock_helper.py b/generated/nirfsg/nirfsg/unit_tests/_mock_helper.py index cb54bf2e3..33ff5a46b 100644 --- a/generated/nirfsg/nirfsg/unit_tests/_mock_helper.py +++ b/generated/nirfsg/nirfsg/unit_tests/_mock_helper.py @@ -75,6 +75,7 @@ def __init__(self): self._defaults['DisableStartTrigger']['return'] = 0 self._defaults['ErrorMessage'] = {} self._defaults['ErrorMessage']['return'] = 0 + self._defaults['ErrorMessage']['errorMessage'] = None self._defaults['GetAllNamedWaveformNames'] = {} self._defaults['GetAllNamedWaveformNames']['return'] = 0 self._defaults['GetAllNamedWaveformNames']['actualBufferSize'] = None @@ -393,6 +394,15 @@ def niRFSG_DisableStartTrigger(self, vi): # noqa: N802 def niRFSG_ErrorMessage(self, vi, error_code, error_message): # noqa: N802 if self._defaults['ErrorMessage']['return'] != 0: return self._defaults['ErrorMessage']['return'] + # error_message + if self._defaults['ErrorMessage']['errorMessage'] is None: + raise MockFunctionCallError("niRFSG_ErrorMessage", param='errorMessage') + test_value = self._defaults['ErrorMessage']['errorMessage'] + if type(test_value) is str: + test_value = test_value.encode('ascii') + assert len(error_message) >= len(test_value) + for i in range(len(test_value)): + error_message[i] = test_value[i] return self._defaults['ErrorMessage']['return'] def niRFSG_GetAllNamedWaveformNames(self, vi, waveform_names, buffer_size, actual_buffer_size): # noqa: N802 diff --git a/src/nirfsg/metadata/functions.py b/src/nirfsg/metadata/functions.py index ea0a800d8..b4903aa6e 100644 --- a/src/nirfsg/metadata/functions.py +++ b/src/nirfsg/metadata/functions.py @@ -1423,9 +1423,9 @@ 'use_in_python_api': True }, { - 'direction': 'in', + 'direction': 'out', 'documentation': { - 'description': 'Returns the user-readable message string that corresponds to the status code you specify.\n\nYou must pass a ViChar array with at least 256 bytes to this parameter.' + 'description': 'Returns the user-readable message string that corresponds to the status code you specify.' }, 'name': 'errorMessage', 'size': {