@@ -178,14 +178,14 @@ def __init__(
178178 app_name , channel , xldefine .XL_BusTypes .XL_BUS_TYPE_CAN
179179 )
180180 LOG .debug ("Channel index %d found" , channel )
181- idx = xldriver .xlGetChannelIndex (hw_type . value , hw_index , hw_channel )
181+ idx = xldriver .xlGetChannelIndex (hw_type , hw_index , hw_channel )
182182 if idx < 0 :
183183 # Undocumented behavior! See issue #353.
184184 # If hardware is unavailable, this function returns -1.
185185 # Raise an exception as if the driver
186186 # would have signalled XL_ERR_HW_NOT_PRESENT.
187187 raise VectorError (
188- xldefine .XL_Status .XL_ERR_HW_NOT_PRESENT . value ,
188+ xldefine .XL_Status .XL_ERR_HW_NOT_PRESENT ,
189189 xldefine .XL_Status .XL_ERR_HW_NOT_PRESENT .name ,
190190 "xlGetChannelIndex" ,
191191 )
@@ -208,8 +208,8 @@ def __init__(
208208 self .mask ,
209209 permission_mask ,
210210 rx_queue_size ,
211- xldefine .XL_InterfaceVersion .XL_INTERFACE_VERSION_V4 . value ,
212- xldefine .XL_BusTypes .XL_BUS_TYPE_CAN . value ,
211+ xldefine .XL_InterfaceVersion .XL_INTERFACE_VERSION_V4 ,
212+ xldefine .XL_BusTypes .XL_BUS_TYPE_CAN ,
213213 )
214214 else :
215215 xldriver .xlOpenPort (
@@ -218,8 +218,8 @@ def __init__(
218218 self .mask ,
219219 permission_mask ,
220220 rx_queue_size ,
221- xldefine .XL_InterfaceVersion .XL_INTERFACE_VERSION . value ,
222- xldefine .XL_BusTypes .XL_BUS_TYPE_CAN . value ,
221+ xldefine .XL_InterfaceVersion .XL_INTERFACE_VERSION ,
222+ xldefine .XL_BusTypes .XL_BUS_TYPE_CAN ,
223223 )
224224 LOG .debug (
225225 "Open Port: PortHandle: %d, PermissionMask: 0x%X" ,
@@ -286,10 +286,7 @@ def __init__(
286286
287287 try :
288288 xldriver .xlActivateChannel (
289- self .port_handle ,
290- self .mask ,
291- xldefine .XL_BusTypes .XL_BUS_TYPE_CAN .value ,
292- 0 ,
289+ self .port_handle , self .mask , xldefine .XL_BusTypes .XL_BUS_TYPE_CAN , 0
293290 )
294291 except VectorError :
295292 self .shutdown ()
@@ -323,9 +320,9 @@ def _apply_filters(self, filters):
323320 self .mask ,
324321 can_filter ["can_id" ],
325322 can_filter ["can_mask" ],
326- xldefine .XL_AcceptanceFilter .XL_CAN_EXT . value
323+ xldefine .XL_AcceptanceFilter .XL_CAN_EXT
327324 if can_filter .get ("extended" )
328- else xldefine .XL_AcceptanceFilter .XL_CAN_STD . value ,
325+ else xldefine .XL_AcceptanceFilter .XL_CAN_STD ,
329326 )
330327 except VectorError as exc :
331328 LOG .warning ("Could not set filters: %s" , exc )
@@ -345,14 +342,14 @@ def _apply_filters(self, filters):
345342 self .mask ,
346343 0x0 ,
347344 0x0 ,
348- xldefine .XL_AcceptanceFilter .XL_CAN_EXT . value ,
345+ xldefine .XL_AcceptanceFilter .XL_CAN_EXT ,
349346 )
350347 xldriver .xlCanSetChannelAcceptance (
351348 self .port_handle ,
352349 self .mask ,
353350 0x0 ,
354351 0x0 ,
355- xldefine .XL_AcceptanceFilter .XL_CAN_STD . value ,
352+ xldefine .XL_AcceptanceFilter .XL_CAN_STD ,
356353 )
357354 except VectorError as exc :
358355 LOG .warning ("Could not reset filters: %s" , exc )
@@ -370,7 +367,7 @@ def _recv_internal(
370367 msg = self ._recv_can ()
371368
372369 except VectorError as exc :
373- if exc .error_code != xldefine .XL_Status .XL_ERR_QUEUE_IS_EMPTY . value :
370+ if exc .error_code != xldefine .XL_Status .XL_ERR_QUEUE_IS_EMPTY :
374371 raise
375372 else :
376373 if msg :
@@ -396,16 +393,10 @@ def _recv_canfd(self) -> Optional[Message]:
396393 xl_can_rx_event = xlclass .XLcanRxEvent ()
397394 xldriver .xlCanReceive (self .port_handle , xl_can_rx_event )
398395
399- if (
400- xl_can_rx_event .tag
401- == xldefine .XL_CANFD_RX_EventTags .XL_CAN_EV_TAG_RX_OK .value
402- ):
396+ if xl_can_rx_event .tag == xldefine .XL_CANFD_RX_EventTags .XL_CAN_EV_TAG_RX_OK :
403397 is_rx = True
404398 data_struct = xl_can_rx_event .tagData .canRxOkMsg
405- elif (
406- xl_can_rx_event .tag
407- == xldefine .XL_CANFD_RX_EventTags .XL_CAN_EV_TAG_TX_OK .value
408- ):
399+ elif xl_can_rx_event .tag == xldefine .XL_CANFD_RX_EventTags .XL_CAN_EV_TAG_TX_OK :
409400 is_rx = False
410401 data_struct = xl_can_rx_event .tagData .canTxOkMsg
411402 else :
@@ -422,22 +413,20 @@ def _recv_canfd(self) -> Optional[Message]:
422413 timestamp = timestamp + self ._time_offset ,
423414 arbitration_id = msg_id & 0x1FFFFFFF ,
424415 is_extended_id = bool (
425- msg_id & xldefine .XL_MessageFlagsExtended .XL_CAN_EXT_MSG_ID . value
416+ msg_id & xldefine .XL_MessageFlagsExtended .XL_CAN_EXT_MSG_ID
426417 ),
427418 is_remote_frame = bool (
428- flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_RTR . value
419+ flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_RTR
429420 ),
430421 is_error_frame = bool (
431- flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_EF .value
432- ),
433- is_fd = bool (
434- flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_EDL .value
422+ flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_EF
435423 ),
424+ is_fd = bool (flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_EDL ),
436425 bitrate_switch = bool (
437- flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_BRS . value
426+ flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_BRS
438427 ),
439428 error_state_indicator = bool (
440- flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_ESI . value
429+ flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_ESI
441430 ),
442431 is_rx = is_rx ,
443432 channel = channel ,
@@ -451,7 +440,7 @@ def _recv_can(self) -> Optional[Message]:
451440 event_count = ctypes .c_uint (1 )
452441 xldriver .xlReceive (self .port_handle , event_count , xl_event )
453442
454- if xl_event .tag != xldefine .XL_EventTags .XL_RECEIVE_MSG . value :
443+ if xl_event .tag != xldefine .XL_EventTags .XL_RECEIVE_MSG :
455444 self .handle_can_event (xl_event )
456445 return
457446
@@ -465,16 +454,16 @@ def _recv_can(self) -> Optional[Message]:
465454 timestamp = timestamp + self ._time_offset ,
466455 arbitration_id = msg_id & 0x1FFFFFFF ,
467456 is_extended_id = bool (
468- msg_id & xldefine .XL_MessageFlagsExtended .XL_CAN_EXT_MSG_ID . value
457+ msg_id & xldefine .XL_MessageFlagsExtended .XL_CAN_EXT_MSG_ID
469458 ),
470459 is_remote_frame = bool (
471- flags & xldefine .XL_MessageFlags .XL_CAN_MSG_FLAG_REMOTE_FRAME . value
460+ flags & xldefine .XL_MessageFlags .XL_CAN_MSG_FLAG_REMOTE_FRAME
472461 ),
473462 is_error_frame = bool (
474- flags & xldefine .XL_MessageFlags .XL_CAN_MSG_FLAG_ERROR_FRAME . value
463+ flags & xldefine .XL_MessageFlags .XL_CAN_MSG_FLAG_ERROR_FRAME
475464 ),
476465 is_rx = not bool (
477- flags & xldefine .XL_MessageFlags .XL_CAN_MSG_FLAG_TX_COMPLETED . value
466+ flags & xldefine .XL_MessageFlags .XL_CAN_MSG_FLAG_TX_COMPLETED
478467 ),
479468 is_fd = False ,
480469 dlc = dlc ,
@@ -539,14 +528,14 @@ def _send_can_msg_sequence(self, msgs: typing.Sequence[Message]) -> int:
539528 def _build_xl_event (msg : Message ) -> xlclass .XLevent :
540529 msg_id = msg .arbitration_id
541530 if msg .is_extended_id :
542- msg_id |= xldefine .XL_MessageFlagsExtended .XL_CAN_EXT_MSG_ID . value
531+ msg_id |= xldefine .XL_MessageFlagsExtended .XL_CAN_EXT_MSG_ID
543532
544533 flags = 0
545534 if msg .is_remote_frame :
546- flags |= xldefine .XL_MessageFlags .XL_CAN_MSG_FLAG_REMOTE_FRAME . value
535+ flags |= xldefine .XL_MessageFlags .XL_CAN_MSG_FLAG_REMOTE_FRAME
547536
548537 xl_event = xlclass .XLevent ()
549- xl_event .tag = xldefine .XL_EventTags .XL_TRANSMIT_MSG . value
538+ xl_event .tag = xldefine .XL_EventTags .XL_TRANSMIT_MSG
550539 xl_event .tagData .msg .id = msg_id
551540 xl_event .tagData .msg .dlc = msg .dlc
552541 xl_event .tagData .msg .flags = flags
@@ -573,18 +562,18 @@ def _send_can_fd_msg_sequence(self, msgs: typing.Sequence[Message]) -> int:
573562 def _build_xl_can_tx_event (msg : Message ) -> xlclass .XLcanTxEvent :
574563 msg_id = msg .arbitration_id
575564 if msg .is_extended_id :
576- msg_id |= xldefine .XL_MessageFlagsExtended .XL_CAN_EXT_MSG_ID . value
565+ msg_id |= xldefine .XL_MessageFlagsExtended .XL_CAN_EXT_MSG_ID
577566
578567 flags = 0
579568 if msg .is_fd :
580- flags |= xldefine .XL_CANFD_TX_MessageFlags .XL_CAN_TXMSG_FLAG_EDL . value
569+ flags |= xldefine .XL_CANFD_TX_MessageFlags .XL_CAN_TXMSG_FLAG_EDL
581570 if msg .bitrate_switch :
582- flags |= xldefine .XL_CANFD_TX_MessageFlags .XL_CAN_TXMSG_FLAG_BRS . value
571+ flags |= xldefine .XL_CANFD_TX_MessageFlags .XL_CAN_TXMSG_FLAG_BRS
583572 if msg .is_remote_frame :
584- flags |= xldefine .XL_CANFD_TX_MessageFlags .XL_CAN_TXMSG_FLAG_RTR . value
573+ flags |= xldefine .XL_CANFD_TX_MessageFlags .XL_CAN_TXMSG_FLAG_RTR
585574
586575 xl_can_tx_event = xlclass .XLcanTxEvent ()
587- xl_can_tx_event .tag = xldefine .XL_CANFD_TX_EventTags .XL_CAN_EV_TAG_TX_MSG . value
576+ xl_can_tx_event .tag = xldefine .XL_CANFD_TX_EventTags .XL_CAN_EV_TAG_TX_MSG
588577 xl_can_tx_event .transId = 0xFFFF
589578
590579 xl_can_tx_event .tagData .canMsg .canId = msg_id
@@ -605,7 +594,7 @@ def shutdown(self):
605594 def reset (self ):
606595 xldriver .xlDeactivateChannel (self .port_handle , self .mask )
607596 xldriver .xlActivateChannel (
608- self .port_handle , self .mask , xldefine .XL_BusTypes .XL_BUS_TYPE_CAN . value , 0
597+ self .port_handle , self .mask , xldefine .XL_BusTypes .XL_BUS_TYPE_CAN , 0
609598 )
610599
611600 @staticmethod
@@ -616,7 +605,7 @@ def _detect_available_configs():
616605 for channel_config in channel_configs :
617606 if (
618607 not channel_config .channelBusCapabilities
619- & xldefine .XL_BusCapabilities .XL_BUS_ACTIVE_CAP_CAN . value
608+ & xldefine .XL_BusCapabilities .XL_BUS_ACTIVE_CAP_CAN
620609 ):
621610 continue
622611 LOG .info (
@@ -631,7 +620,7 @@ def _detect_available_configs():
631620 "channel" : channel_config .channelIndex ,
632621 "supports_fd" : bool (
633622 channel_config .channelBusCapabilities
634- & xldefine .XL_ChannelCapabilities .XL_CHANNEL_FLAG_CANFD_ISO_SUPPORT . value
623+ & xldefine .XL_ChannelCapabilities .XL_CHANNEL_FLAG_CANFD_ISO_SUPPORT
635624 ),
636625 }
637626 )
@@ -670,12 +659,7 @@ def get_application_config(
670659 hw_channel = ctypes .c_uint ()
671660
672661 xldriver .xlGetApplConfig (
673- app_name .encode (),
674- app_channel ,
675- hw_type ,
676- hw_index ,
677- hw_channel ,
678- bus_type .value ,
662+ app_name .encode (), app_channel , hw_type , hw_index , hw_channel , bus_type
679663 )
680664 return xldefine .XL_HardwareType (hw_type .value ), hw_index .value , hw_channel .value
681665
@@ -708,12 +692,7 @@ def set_application_config(
708692 XL_BusTypes.XL_BUS_TYPE_CAN for most cases.
709693 """
710694 xldriver .xlSetApplConfig (
711- app_name .encode (),
712- app_channel ,
713- hw_type .value ,
714- hw_index ,
715- hw_channel ,
716- bus_type .value ,
695+ app_name .encode (), app_channel , hw_type , hw_index , hw_channel , bus_type
717696 )
718697
719698 def set_timer_rate (self , timer_rate_ms : int ) -> None :
0 commit comments