33import select
44import socket
55import struct
6+ import warnings
67from typing import List , Optional , Tuple , Union
78
89import can
@@ -103,12 +104,22 @@ def __init__(
103104 )
104105
105106 super ().__init__ (
106- channel , ** kwargs , protocol = CanProtocol .CAN_FD if fd else CanProtocol .CAN_20
107+ channel ,
108+ ** kwargs ,
109+ protocol = CanProtocol .CAN_FD if fd else CanProtocol .CAN_20 ,
107110 )
108111
109- self .is_fd = fd
110112 self ._multicast = GeneralPurposeUdpMulticastBus (channel , port , hop_limit )
111113
114+ @property
115+ def is_fd (self ) -> bool :
116+ warnings .warn (
117+ "The UdpMulticastBus.is_fd property is deprecated and superseded by "
118+ "BusABC.protocol. It is scheduled for removal in version 5.0." ,
119+ DeprecationWarning ,
120+ )
121+ return self .protocol == CanProtocol .CAN_FD
122+
112123 def _recv_internal (self , timeout : Optional [float ]):
113124 result = self ._multicast .recv (timeout )
114125 if not result :
@@ -124,13 +135,13 @@ def _recv_internal(self, timeout: Optional[float]):
124135 "could not unpack received message"
125136 ) from exception
126137
127- if not self .is_fd and can_message .is_fd :
138+ if self .protocol != CanProtocol . CAN_FD and can_message .is_fd :
128139 return None , False
129140
130141 return can_message , False
131142
132143 def send (self , msg : can .Message , timeout : Optional [float ] = None ) -> None :
133- if not self .is_fd and msg .is_fd :
144+ if self .protocol != CanProtocol . CAN_FD and msg .is_fd :
134145 raise can .CanOperationError (
135146 "cannot send FD message over bus with CAN FD disabled"
136147 )
0 commit comments