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 3030
3131
3232import can
33- from can import BusABC , Message
33+ from can import BusABC , Message , CanProtocol
3434from can .broadcastmanager import (
3535 LimitedDurationCyclicSendTaskABC ,
3636 ModifiableCyclicTaskABC ,
@@ -710,7 +710,12 @@ def __init__(
710710 "local_loopback" : local_loopback ,
711711 }
712712 )
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+ )
714719
715720 def shutdown (self ) -> None :
716721 """Stops all active periodic tasks and closes the socket."""
Original file line number Diff line number Diff line change 99import warnings
1010from unittest .mock import patch
1111
12+ from .config import TEST_INTERFACE_SOCKETCAN
13+
1214import can
1315from can .interfaces .socketcan .constants import (
1416 CAN_BCM_TX_DELETE ,
@@ -357,6 +359,16 @@ def test_build_bcm_update_header(self):
357359 self .assertEqual (can_id , result .can_id )
358360 self .assertEqual (1 , result .nframes )
359361
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+
360372 @unittest .skipUnless (IS_LINUX and IS_PYPY , "Only test when run on Linux with PyPy" )
361373 def test_pypy_socketcan_support (self ):
362374 """Wait for PyPy raw CAN socket support
You can’t perform that action at this time.
0 commit comments