Skip to content

Commit ae85538

Browse files
committed
fixed self test parameter mismatch and included basic test
1 parent 353a90b commit ae85538

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

generated/nirfsg/nirfsg/_library_interpreter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,13 +625,13 @@ def self_calibrate_range(self, steps_to_omit, min_frequency, max_frequency, min_
625625
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
626626
return
627627

628-
def self_test(self, self_test_message): # noqa: N802
628+
def self_test(self): # noqa: N802
629629
vi_ctype = _visatype.ViSession(self._vi) # case S110
630630
self_test_result_ctype = _visatype.ViInt16() # case S220
631-
self_test_message_ctype = ctypes.create_string_buffer(self_test_message.encode(self._encoding)) # case C020
631+
self_test_message_ctype = (_visatype.ViChar * 256)() # case C070
632632
error_code = self._library.niRFSG_SelfTest(vi_ctype, None if self_test_result_ctype is None else (ctypes.pointer(self_test_result_ctype)), self_test_message_ctype)
633633
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
634-
return int(self_test_result_ctype.value)
634+
return int(self_test_result_ctype.value), self_test_message_ctype.value.decode(self._encoding)
635635

636636
def send_software_edge_trigger(self, trigger, trigger_identifier): # noqa: N802
637637
vi_ctype = _visatype.ViSession(self._vi) # case S110

generated/nirfsg/nirfsg/session.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7088,7 +7088,7 @@ def self_calibrate_range(self, steps_to_omit, min_frequency, max_frequency, min_
70887088
self._interpreter.self_calibrate_range(steps_to_omit, min_frequency, max_frequency, min_power_level, max_power_level)
70897089

70907090
@ivi_synchronized
7091-
def _self_test(self, self_test_message):
7091+
def _self_test(self):
70927092
r'''_self_test
70937093

70947094
Performs a self-test on the NI-RFSG device and returns the test results.
@@ -7103,12 +7103,6 @@ def _self_test(self, self_test_message):
71037103

71047104
`Device Warm-Up <https://www.ni.com/docs/en-US/bundle/rfsg/page/rfsg/warmup.html>`_
71057105

7106-
Args:
7107-
self_test_message (str): Returns the self-test response string from the NI-RFSG device. For an explanation of the string contents, refer to the **status** parameter of this method.
7108-
7109-
You must pass a ViChar array with at least 256 bytes.
7110-
7111-
71127106
Returns:
71137107
self_test_result (int): This parameter contains the value returned from the NI-RFSG device self test.
71147108

@@ -7120,9 +7114,13 @@ def _self_test(self, self_test_message):
71207114
| 1 | Self test failed |
71217115
+----------------+------------------+
71227116

7117+
self_test_message (str): Returns the self-test response string from the NI-RFSG device. For an explanation of the string contents, refer to the **status** parameter of this method.
7118+
7119+
You must pass a ViChar array with at least 256 bytes.
7120+
71237121
'''
7124-
self_test_result = self._interpreter.self_test(self_test_message)
7125-
return self_test_result
7122+
self_test_result, self_test_message = self._interpreter.self_test()
7123+
return self_test_result, self_test_message
71267124

71277125
@ivi_synchronized
71287126
def set_arb_waveform_next_write_position(self, waveform_name, relative_to, offset):

generated/nirfsg/nirfsg/unit_tests/_mock_helper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def __init__(self):
187187
self._defaults['SelfTest'] = {}
188188
self._defaults['SelfTest']['return'] = 0
189189
self._defaults['SelfTest']['selfTestResult'] = None
190+
self._defaults['SelfTest']['selfTestMessage'] = None
190191
self._defaults['SendSoftwareEdgeTrigger'] = {}
191192
self._defaults['SendSoftwareEdgeTrigger']['return'] = 0
192193
self._defaults['SetArbWaveformNextWritePosition'] = {}
@@ -805,6 +806,15 @@ def niRFSG_SelfTest(self, vi, self_test_result, self_test_message): # noqa: N80
805806
raise MockFunctionCallError("niRFSG_SelfTest", param='selfTestResult')
806807
if self_test_result is not None:
807808
self_test_result.contents.value = self._defaults['SelfTest']['selfTestResult']
809+
# self_test_message
810+
if self._defaults['SelfTest']['selfTestMessage'] is None:
811+
raise MockFunctionCallError("niRFSG_SelfTest", param='selfTestMessage')
812+
test_value = self._defaults['SelfTest']['selfTestMessage']
813+
if type(test_value) is str:
814+
test_value = test_value.encode('ascii')
815+
assert len(self_test_message) >= len(test_value)
816+
for i in range(len(test_value)):
817+
self_test_message[i] = test_value[i]
808818
return self._defaults['SelfTest']['return']
809819

810820
def niRFSG_SendSoftwareEdgeTrigger(self, vi, trigger, trigger_identifier): # noqa: N802

src/nirfsg/metadata/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3740,7 +3740,7 @@
37403740
'type': 'ViInt16'
37413741
},
37423742
{
3743-
'direction': 'in',
3743+
'direction': 'out',
37443744
'documentation': {
37453745
'description': 'Returns the self-test response string from the NI-RFSG device. For an explanation of the string contents, refer to the **status** parameter of this function.\n\nYou must pass a ViChar array with at least 256 bytes.'
37463746
},

src/nirfsg/system_tests/test_system_nirfsg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ def test_reset_with_options(self, rfsg_device_session):
118118
waveform_exists = rfsg_device_session.check_if_waveform_exists('mywaveform')
119119
assert waveform_exists is False
120120

121+
def test_self_test(self, rfsg_device_session):
122+
# We should not get an assert if self_test passes
123+
rfsg_device_session.self_test()
124+
121125
@pytest.mark.skipif(use_simulated_session is False, reason="Takes long time in real device")
122126
def test_self_cal(self, rfsg_device_session):
123127
rfsg_device_session.self_cal()

0 commit comments

Comments
 (0)