@@ -178,14 +178,14 @@ def __init__(
178
178
app_name , channel , xldefine .XL_BusTypes .XL_BUS_TYPE_CAN
179
179
)
180
180
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 )
182
182
if idx < 0 :
183
183
# Undocumented behavior! See issue #353.
184
184
# If hardware is unavailable, this function returns -1.
185
185
# Raise an exception as if the driver
186
186
# would have signalled XL_ERR_HW_NOT_PRESENT.
187
187
raise VectorError (
188
- xldefine .XL_Status .XL_ERR_HW_NOT_PRESENT . value ,
188
+ xldefine .XL_Status .XL_ERR_HW_NOT_PRESENT ,
189
189
xldefine .XL_Status .XL_ERR_HW_NOT_PRESENT .name ,
190
190
"xlGetChannelIndex" ,
191
191
)
@@ -208,8 +208,8 @@ def __init__(
208
208
self .mask ,
209
209
permission_mask ,
210
210
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 ,
213
213
)
214
214
else :
215
215
xldriver .xlOpenPort (
@@ -218,8 +218,8 @@ def __init__(
218
218
self .mask ,
219
219
permission_mask ,
220
220
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 ,
223
223
)
224
224
LOG .debug (
225
225
"Open Port: PortHandle: %d, PermissionMask: 0x%X" ,
@@ -286,10 +286,7 @@ def __init__(
286
286
287
287
try :
288
288
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
293
290
)
294
291
except VectorError :
295
292
self .shutdown ()
@@ -323,9 +320,9 @@ def _apply_filters(self, filters):
323
320
self .mask ,
324
321
can_filter ["can_id" ],
325
322
can_filter ["can_mask" ],
326
- xldefine .XL_AcceptanceFilter .XL_CAN_EXT . value
323
+ xldefine .XL_AcceptanceFilter .XL_CAN_EXT
327
324
if can_filter .get ("extended" )
328
- else xldefine .XL_AcceptanceFilter .XL_CAN_STD . value ,
325
+ else xldefine .XL_AcceptanceFilter .XL_CAN_STD ,
329
326
)
330
327
except VectorError as exc :
331
328
LOG .warning ("Could not set filters: %s" , exc )
@@ -345,14 +342,14 @@ def _apply_filters(self, filters):
345
342
self .mask ,
346
343
0x0 ,
347
344
0x0 ,
348
- xldefine .XL_AcceptanceFilter .XL_CAN_EXT . value ,
345
+ xldefine .XL_AcceptanceFilter .XL_CAN_EXT ,
349
346
)
350
347
xldriver .xlCanSetChannelAcceptance (
351
348
self .port_handle ,
352
349
self .mask ,
353
350
0x0 ,
354
351
0x0 ,
355
- xldefine .XL_AcceptanceFilter .XL_CAN_STD . value ,
352
+ xldefine .XL_AcceptanceFilter .XL_CAN_STD ,
356
353
)
357
354
except VectorError as exc :
358
355
LOG .warning ("Could not reset filters: %s" , exc )
@@ -370,7 +367,7 @@ def _recv_internal(
370
367
msg = self ._recv_can ()
371
368
372
369
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 :
374
371
raise
375
372
else :
376
373
if msg :
@@ -396,16 +393,10 @@ def _recv_canfd(self) -> Optional[Message]:
396
393
xl_can_rx_event = xlclass .XLcanRxEvent ()
397
394
xldriver .xlCanReceive (self .port_handle , xl_can_rx_event )
398
395
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 :
403
397
is_rx = True
404
398
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 :
409
400
is_rx = False
410
401
data_struct = xl_can_rx_event .tagData .canTxOkMsg
411
402
else :
@@ -422,22 +413,20 @@ def _recv_canfd(self) -> Optional[Message]:
422
413
timestamp = timestamp + self ._time_offset ,
423
414
arbitration_id = msg_id & 0x1FFFFFFF ,
424
415
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
426
417
),
427
418
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
429
420
),
430
421
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
435
423
),
424
+ is_fd = bool (flags & xldefine .XL_CANFD_RX_MessageFlags .XL_CAN_RXMSG_FLAG_EDL ),
436
425
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
438
427
),
439
428
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
441
430
),
442
431
is_rx = is_rx ,
443
432
channel = channel ,
@@ -451,7 +440,7 @@ def _recv_can(self) -> Optional[Message]:
451
440
event_count = ctypes .c_uint (1 )
452
441
xldriver .xlReceive (self .port_handle , event_count , xl_event )
453
442
454
- if xl_event .tag != xldefine .XL_EventTags .XL_RECEIVE_MSG . value :
443
+ if xl_event .tag != xldefine .XL_EventTags .XL_RECEIVE_MSG :
455
444
self .handle_can_event (xl_event )
456
445
return
457
446
@@ -465,16 +454,16 @@ def _recv_can(self) -> Optional[Message]:
465
454
timestamp = timestamp + self ._time_offset ,
466
455
arbitration_id = msg_id & 0x1FFFFFFF ,
467
456
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
469
458
),
470
459
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
472
461
),
473
462
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
475
464
),
476
465
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
478
467
),
479
468
is_fd = False ,
480
469
dlc = dlc ,
@@ -539,14 +528,14 @@ def _send_can_msg_sequence(self, msgs: typing.Sequence[Message]) -> int:
539
528
def _build_xl_event (msg : Message ) -> xlclass .XLevent :
540
529
msg_id = msg .arbitration_id
541
530
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
543
532
544
533
flags = 0
545
534
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
547
536
548
537
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
550
539
xl_event .tagData .msg .id = msg_id
551
540
xl_event .tagData .msg .dlc = msg .dlc
552
541
xl_event .tagData .msg .flags = flags
@@ -573,18 +562,18 @@ def _send_can_fd_msg_sequence(self, msgs: typing.Sequence[Message]) -> int:
573
562
def _build_xl_can_tx_event (msg : Message ) -> xlclass .XLcanTxEvent :
574
563
msg_id = msg .arbitration_id
575
564
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
577
566
578
567
flags = 0
579
568
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
581
570
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
583
572
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
585
574
586
575
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
588
577
xl_can_tx_event .transId = 0xFFFF
589
578
590
579
xl_can_tx_event .tagData .canMsg .canId = msg_id
@@ -605,7 +594,7 @@ def shutdown(self):
605
594
def reset (self ):
606
595
xldriver .xlDeactivateChannel (self .port_handle , self .mask )
607
596
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
609
598
)
610
599
611
600
@staticmethod
@@ -616,7 +605,7 @@ def _detect_available_configs():
616
605
for channel_config in channel_configs :
617
606
if (
618
607
not channel_config .channelBusCapabilities
619
- & xldefine .XL_BusCapabilities .XL_BUS_ACTIVE_CAP_CAN . value
608
+ & xldefine .XL_BusCapabilities .XL_BUS_ACTIVE_CAP_CAN
620
609
):
621
610
continue
622
611
LOG .info (
@@ -631,7 +620,7 @@ def _detect_available_configs():
631
620
"channel" : channel_config .channelIndex ,
632
621
"supports_fd" : bool (
633
622
channel_config .channelBusCapabilities
634
- & xldefine .XL_ChannelCapabilities .XL_CHANNEL_FLAG_CANFD_ISO_SUPPORT . value
623
+ & xldefine .XL_ChannelCapabilities .XL_CHANNEL_FLAG_CANFD_ISO_SUPPORT
635
624
),
636
625
}
637
626
)
@@ -670,12 +659,7 @@ def get_application_config(
670
659
hw_channel = ctypes .c_uint ()
671
660
672
661
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
679
663
)
680
664
return xldefine .XL_HardwareType (hw_type .value ), hw_index .value , hw_channel .value
681
665
@@ -708,12 +692,7 @@ def set_application_config(
708
692
XL_BusTypes.XL_BUS_TYPE_CAN for most cases.
709
693
"""
710
694
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
717
696
)
718
697
719
698
def set_timer_rate (self , timer_rate_ms : int ) -> None :
0 commit comments