File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 30
30
31
31
32
32
import can
33
- from can import BusABC , Message
33
+ from can import BusABC , Message , CanProtocol
34
34
from can .broadcastmanager import (
35
35
LimitedDurationCyclicSendTaskABC ,
36
36
ModifiableCyclicTaskABC ,
@@ -710,7 +710,12 @@ def __init__(
710
710
"local_loopback" : local_loopback ,
711
711
}
712
712
)
713
- super ().__init__ (channel = channel , can_filters = can_filters , ** kwargs )
713
+ super ().__init__ (
714
+ channel = channel ,
715
+ can_filters = can_filters ,
716
+ protocol = CanProtocol .CAN_FD if fd else CanProtocol .CAN_20 ,
717
+ ** kwargs ,
718
+ )
714
719
715
720
def shutdown (self ) -> None :
716
721
"""Stops all active periodic tasks and closes the socket."""
Original file line number Diff line number Diff line change 9
9
import warnings
10
10
from unittest .mock import patch
11
11
12
+ from .config import TEST_INTERFACE_SOCKETCAN
13
+
12
14
import can
13
15
from can .interfaces .socketcan .constants import (
14
16
CAN_BCM_TX_DELETE ,
@@ -357,6 +359,16 @@ def test_build_bcm_update_header(self):
357
359
self .assertEqual (can_id , result .can_id )
358
360
self .assertEqual (1 , result .nframes )
359
361
362
+ @unittest .skipUnless (TEST_INTERFACE_SOCKETCAN , "Only run when vcan0 is available" )
363
+ def test_bus_creation_can (self ):
364
+ bus = can .Bus (interface = "socketcan" , channel = "vcan0" , fd = False )
365
+ self .assertEqual (bus .protocol , can .CanProtocol .CAN_20 )
366
+
367
+ @unittest .skipUnless (TEST_INTERFACE_SOCKETCAN , "Only run when vcan0 is available" )
368
+ def test_bus_creation_can_fd (self ):
369
+ bus = can .Bus (interface = "socketcan" , channel = "vcan0" , fd = True )
370
+ self .assertEqual (bus .protocol , can .CanProtocol .CAN_FD )
371
+
360
372
@unittest .skipUnless (IS_LINUX and IS_PYPY , "Only test when run on Linux with PyPy" )
361
373
def test_pypy_socketcan_support (self ):
362
374
"""Wait for PyPy raw CAN socket support
You can’t perform that action at this time.
0 commit comments