From aee44d801faff73833310e505be0ca55ec16437d Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Sat, 3 Sep 2022 20:25:48 +0200 Subject: [PATCH] extend XL api wrapper --- can/interfaces/vector/xlclass.py | 13 ++++++++++++- can/interfaces/vector/xldefine.py | 8 +++++++- can/interfaces/vector/xldriver.py | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/can/interfaces/vector/xlclass.py b/can/interfaces/vector/xlclass.py index c0ef9fa48..6441ad4e5 100644 --- a/can/interfaces/vector/xlclass.py +++ b/can/interfaces/vector/xlclass.py @@ -45,6 +45,13 @@ class s_xl_chip_state(ctypes.Structure): ] +class s_xl_sync_pulse(ctypes.Structure): + _fields_ = [ + ("pulseCode", ctypes.c_ubyte), + ("time", XLuint64), + ] + + class s_xl_can_ev_chip_state(ctypes.Structure): _fields_ = [ ("busStatus", ctypes.c_ubyte), @@ -65,7 +72,11 @@ class s_xl_can_ev_sync_pulse(ctypes.Structure): # BASIC bus message structure class s_xl_tag_data(ctypes.Union): - _fields_ = [("msg", s_xl_can_msg), ("chipState", s_xl_chip_state)] + _fields_ = [ + ("msg", s_xl_can_msg), + ("chipState", s_xl_chip_state), + ("syncPulse", s_xl_sync_pulse), + ] # CAN FD messages diff --git a/can/interfaces/vector/xldefine.py b/can/interfaces/vector/xldefine.py index 032f08318..5a1084f48 100644 --- a/can/interfaces/vector/xldefine.py +++ b/can/interfaces/vector/xldefine.py @@ -64,7 +64,7 @@ class XL_BusTypes(IntFlag): XL_BUS_TYPE_A429 = 8192 # =0x00002000 -class XL_CANFD_BusParams_CanOpMode(IntEnum): +class XL_CANFD_BusParams_CanOpMode(IntFlag): XL_BUS_PARAMS_CANOPMODE_CAN20 = 1 XL_BUS_PARAMS_CANOPMODE_CANFD = 2 XL_BUS_PARAMS_CANOPMODE_CANFD_NO_ISO = 8 @@ -318,3 +318,9 @@ class XL_HardwareType(IntEnum): XL_HWTYPE_VX1161A = 114 XL_HWTYPE_VX1161B = 115 XL_MAX_HWTYPE = 120 + + +class XL_SyncPulseSource(IntEnum): + XL_SYNC_PULSE_EXTERNAL = 0 + XL_SYNC_PULSE_OUR = 1 + XL_SYNC_PULSE_OUR_SHARED = 2 diff --git a/can/interfaces/vector/xldriver.py b/can/interfaces/vector/xldriver.py index 3243fa4a0..8df39e9dc 100644 --- a/can/interfaces/vector/xldriver.py +++ b/can/interfaces/vector/xldriver.py @@ -272,3 +272,18 @@ def check_status_initialization(result, function, arguments): xlCanGetEventString = _xlapi_dll.xlCanGetEventString xlCanGetEventString.argtypes = [ctypes.POINTER(xlclass.XLcanRxEvent)] xlCanGetEventString.restype = xlclass.XLstringType + +xlGetReceiveQueueLevel = _xlapi_dll.xlGetReceiveQueueLevel +xlGetReceiveQueueLevel.argtypes = [xlclass.XLportHandle, ctypes.POINTER(ctypes.c_int)] +xlGetReceiveQueueLevel.restype = xlclass.XLstatus +xlGetReceiveQueueLevel.errcheck = check_status_operation + +xlGenerateSyncPulse = _xlapi_dll.xlGenerateSyncPulse +xlGenerateSyncPulse.argtypes = [xlclass.XLportHandle, xlclass.XLaccess] +xlGenerateSyncPulse.restype = xlclass.XLstatus +xlGenerateSyncPulse.errcheck = check_status_operation + +xlFlushReceiveQueue = _xlapi_dll.xlFlushReceiveQueue +xlFlushReceiveQueue.argtypes = [xlclass.XLportHandle] +xlFlushReceiveQueue.restype = xlclass.XLstatus +xlFlushReceiveQueue.errcheck = check_status_operation