Skip to content

Commit 366e239

Browse files
authored
Test on vector virtual bus if XL API is available (hardbyte#1390)
* refactoring for easier testing * use the vector virtual bus if XL driver is available * check xldriver to satisfy mypy * fix assertion
1 parent 1e11f21 commit 366e239

File tree

2 files changed

+802
-337
lines changed

2 files changed

+802
-337
lines changed

can/interfaces/vector/canlib.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -881,16 +881,25 @@ class VectorChannelConfig(NamedTuple):
881881
transceiverName: str
882882

883883

884-
def get_channel_configs() -> List[VectorChannelConfig]:
884+
def _get_xl_driver_config() -> xlclass.XLdriverConfig:
885885
if xldriver is None:
886-
return []
886+
raise VectorError(
887+
error_code=xldefine.XL_Status.XL_ERR_DLL_NOT_FOUND,
888+
error_string="xldriver is unavailable",
889+
function="_get_xl_driver_config",
890+
)
887891
driver_config = xlclass.XLdriverConfig()
892+
xldriver.xlOpenDriver()
893+
xldriver.xlGetDriverConfig(driver_config)
894+
xldriver.xlCloseDriver()
895+
return driver_config
896+
897+
898+
def get_channel_configs() -> List[VectorChannelConfig]:
888899
try:
889-
xldriver.xlOpenDriver()
890-
xldriver.xlGetDriverConfig(driver_config)
891-
xldriver.xlCloseDriver()
900+
driver_config = _get_xl_driver_config()
892901
except VectorError:
893-
pass
902+
return []
894903

895904
channel_list: List[VectorChannelConfig] = []
896905
for i in range(driver_config.channelCount):

0 commit comments

Comments
 (0)