Skip to content

add vector hardware config popup #774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 28, 2020
Merged
9 changes: 9 additions & 0 deletions can/interfaces/vector/canlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 in milliseconds.
"""
xldriver.xlPopupHwConfig(ctypes.c_char_p(), ctypes.c_uint(wait_for_finish))


def get_channel_configs():
if xldriver is None:
Expand Down
5 changes: 5 additions & 0 deletions can/interfaces/vector/xldriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions test/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down