3
3
import select
4
4
import socket
5
5
import struct
6
+ import warnings
6
7
from typing import List , Optional , Tuple , Union
7
8
8
9
import can
@@ -103,12 +104,22 @@ def __init__(
103
104
)
104
105
105
106
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 ,
107
110
)
108
111
109
- self .is_fd = fd
110
112
self ._multicast = GeneralPurposeUdpMulticastBus (channel , port , hop_limit )
111
113
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
+
112
123
def _recv_internal (self , timeout : Optional [float ]):
113
124
result = self ._multicast .recv (timeout )
114
125
if not result :
@@ -124,13 +135,13 @@ def _recv_internal(self, timeout: Optional[float]):
124
135
"could not unpack received message"
125
136
) from exception
126
137
127
- if not self .is_fd and can_message .is_fd :
138
+ if self .protocol != CanProtocol . CAN_FD and can_message .is_fd :
128
139
return None , False
129
140
130
141
return can_message , False
131
142
132
143
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 :
134
145
raise can .CanOperationError (
135
146
"cannot send FD message over bus with CAN FD disabled"
136
147
)
0 commit comments