From eee112b3a472252d607f9dc9bdb3e4428bbdacf6 Mon Sep 17 00:00:00 2001 From: zariiii9003 Date: Thu, 20 Feb 2020 22:22:03 +0100 Subject: [PATCH 1/2] vector interface - add xlPopupHwConfig --- can/interfaces/vector/canlib.py | 9 +++++++++ can/interfaces/vector/xldriver.py | 5 +++++ test/test_vector.py | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/can/interfaces/vector/canlib.py b/can/interfaces/vector/canlib.py index cb1858062..6df86ced7 100644 --- a/can/interfaces/vector/canlib.py +++ b/can/interfaces/vector/canlib.py @@ -577,6 +577,15 @@ def _detect_available_configs(): ) return configs + @staticmethod + def popup_vector_hw_configuration(wait_for_finish: int = 0) -> None: + """Open vector hardware configuration window. + + :param int wait_for_finish: + Time to wait for user input. + """ + xldriver.xlPopupHwConfig(ctypes.c_char_p(), ctypes.c_uint(wait_for_finish)) + def get_channel_configs(): if xldriver is None: diff --git a/can/interfaces/vector/xldriver.py b/can/interfaces/vector/xldriver.py index 337135755..7a361a29d 100644 --- a/can/interfaces/vector/xldriver.py +++ b/can/interfaces/vector/xldriver.py @@ -229,3 +229,8 @@ def check_status(result, function, arguments): xlCanSetChannelOutput.argtypes = [xlclass.XLportHandle, xlclass.XLaccess, ctypes.c_char] xlCanSetChannelOutput.restype = xlclass.XLstatus xlCanSetChannelOutput.errcheck = check_status + +xlPopupHwConfig = _xlapi_dll.xlPopupHwConfig +xlPopupHwConfig.argtypes = [ctypes.c_char_p, ctypes.c_uint] +xlPopupHwConfig.restype = xlclass.XLstatus +xlPopupHwConfig.errcheck = check_status diff --git a/test/test_vector.py b/test/test_vector.py index d99509df8..a2d47c74e 100644 --- a/test/test_vector.py +++ b/test/test_vector.py @@ -240,6 +240,14 @@ def test_reset(self) -> None: can.interfaces.vector.canlib.xldriver.xlDeactivateChannel.assert_called() can.interfaces.vector.canlib.xldriver.xlActivateChannel.assert_called() + def test_popup_hw_cfg(self) -> None: + canlib.xldriver.xlPopupHwConfig = Mock() + canlib.VectorBus.popup_vector_hw_configuration(10) + assert canlib.xldriver.xlPopupHwConfig.called + args, kwargs = canlib.xldriver.xlPopupHwConfig.call_args + assert isinstance(args[0], ctypes.c_char_p) + assert isinstance(args[1], ctypes.c_uint) + def test_called_without_testing_argument(self) -> None: """This tests if an exception is thrown when we are not running on Windows.""" if os.name != "nt": From 66e4adaa39223a25332cf6da488656feb9e21272 Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Fri, 21 Feb 2020 20:43:07 +0100 Subject: [PATCH 2/2] update popup_vector_hw_configuration docstring --- can/interfaces/vector/canlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/vector/canlib.py b/can/interfaces/vector/canlib.py index 6df86ced7..14205327b 100644 --- a/can/interfaces/vector/canlib.py +++ b/can/interfaces/vector/canlib.py @@ -582,7 +582,7 @@ def popup_vector_hw_configuration(wait_for_finish: int = 0) -> None: """Open vector hardware configuration window. :param int wait_for_finish: - Time to wait for user input. + Time to wait for user input in milliseconds. """ xldriver.xlPopupHwConfig(ctypes.c_char_p(), ctypes.c_uint(wait_for_finish))