From 534d1d30560d55942c8eecca5ae52190c5e0bfaf Mon Sep 17 00:00:00 2001 From: Rahul R Date: Thu, 2 Apr 2026 11:31:26 +0000 Subject: [PATCH 1/4] Initial version of Fix --- docs/nirfsg/class.rst | 13 +++++++------ generated/nirfsg/nirfsg/_grpc_stub_interpreter.py | 7 ++++--- generated/nirfsg/nirfsg/_library_interpreter.py | 6 +++--- generated/nirfsg/nirfsg/session.py | 7 +++++-- generated/nirfsg/nirfsg/unit_tests/_mock_helper.py | 10 ++++++++++ src/nirfsg/metadata/functions.py | 2 +- 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/docs/nirfsg/class.rst b/docs/nirfsg/class.rst index 6d0cfd285..10d00c7d3 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,18 @@ 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. - + You must pass a ViChar array with at least 256 bytes to this parameter. + + - :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..b518c3bd7 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,15 @@ def error_message(self, error_code, error_message): **Default Value** : 0 (VI_SUCCESS) + + Returns: 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. ''' - 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..122f01391 100644 --- a/src/nirfsg/metadata/functions.py +++ b/src/nirfsg/metadata/functions.py @@ -1423,7 +1423,7 @@ '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.' }, From 03dda97dc07ca6255e7b3fcdf6a8bf4b43d771d9 Mon Sep 17 00:00:00 2001 From: Rahul R Date: Thu, 2 Apr 2026 12:29:34 +0000 Subject: [PATCH 2/4] ChangeLog Update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From f31c9f5428b63391cedaad2d6e33e17da1a14907 Mon Sep 17 00:00:00 2001 From: Rahul R Date: Tue, 7 Apr 2026 05:59:23 +0000 Subject: [PATCH 3/4] Updated with code review comments on description --- docs/nirfsg/class.rst | 2 -- generated/nifake/nifake/unit_tests/test_grpc.py | 2 +- generated/nirfsg/nirfsg/session.py | 2 -- src/nirfsg/metadata/functions.py | 2 +- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/nirfsg/class.rst b/docs/nirfsg/class.rst index 10d00c7d3..d41c0cf8a 100644 --- a/docs/nirfsg/class.rst +++ b/docs/nirfsg/class.rst @@ -1191,8 +1191,6 @@ error_message 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. - diff --git a/generated/nifake/nifake/unit_tests/test_grpc.py b/generated/nifake/nifake/unit_tests/test_grpc.py index e3463b93d..48b8cd6bf 100644 --- a/generated/nifake/nifake/unit_tests/test_grpc.py +++ b/generated/nifake/nifake/unit_tests/test_grpc.py @@ -13,7 +13,7 @@ import _mock_helper -GRPC_SESSION_OBJECT_FOR_TEST = nifake.session_pb2.Session(name="TestSession", id=42) +GRPC_SESSION_OBJECT_FOR_TEST = session_pb2.Session(name="TestSession", id=42) Metadatum = collections.namedtuple('Metadatum', ('key', 'value')) diff --git a/generated/nirfsg/nirfsg/session.py b/generated/nirfsg/nirfsg/session.py index b518c3bd7..0e131adc6 100644 --- a/generated/nirfsg/nirfsg/session.py +++ b/generated/nirfsg/nirfsg/session.py @@ -4849,8 +4849,6 @@ def error_message(self, error_code): Returns: 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. - ''' error_message = self._interpreter.error_message(error_code) return error_message diff --git a/src/nirfsg/metadata/functions.py b/src/nirfsg/metadata/functions.py index 122f01391..b4903aa6e 100644 --- a/src/nirfsg/metadata/functions.py +++ b/src/nirfsg/metadata/functions.py @@ -1425,7 +1425,7 @@ { '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': { From 6e4959aa5e5ec3be72d1d2d5ef9dea41cf775f96 Mon Sep 17 00:00:00 2001 From: Rahul R Date: Tue, 7 Apr 2026 10:15:49 +0000 Subject: [PATCH 4/4] Resolving travis issues --- generated/nifake/nifake/unit_tests/test_grpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated/nifake/nifake/unit_tests/test_grpc.py b/generated/nifake/nifake/unit_tests/test_grpc.py index 48b8cd6bf..e3463b93d 100644 --- a/generated/nifake/nifake/unit_tests/test_grpc.py +++ b/generated/nifake/nifake/unit_tests/test_grpc.py @@ -13,7 +13,7 @@ import _mock_helper -GRPC_SESSION_OBJECT_FOR_TEST = session_pb2.Session(name="TestSession", id=42) +GRPC_SESSION_OBJECT_FOR_TEST = nifake.session_pb2.Session(name="TestSession", id=42) Metadatum = collections.namedtuple('Metadatum', ('key', 'value'))