@@ -155,15 +155,15 @@ def start(
155155
156156 if error_handler is not None :
157157 err_mask = _CAN_ERR_TX_TIMEOUT | _CAN_ERR_CRTL | _CAN_ERR_BUSOFF
158- self ._sock .setsockopt (socket . SOL_CAN_RAW , _CAN_RAW_ERR_FILTER , err_mask )
158+ self ._sock .setsockopt (_SOL_CAN_RAW , _CAN_RAW_ERR_FILTER , err_mask )
159159
160160 def configure_acceptance_filters (self , configuration : typing .Sequence [FilterConfiguration ]) -> None :
161161 if self ._closed :
162162 raise pycyphal .transport .ResourceClosedError (repr (self ))
163163
164164 try :
165165 self ._sock .setsockopt (
166- socket . SOL_CAN_RAW , # type: ignore
166+ _SOL_CAN_RAW , # type: ignore
167167 socket .CAN_RAW_FILTER , # type: ignore
168168 _pack_filters (configuration ),
169169 )
@@ -380,7 +380,7 @@ def _parse_native_frame(self, source: bytes) -> None | DataFrame | typing.List[M
380380
381381 def _set_loopback_enabled (self , enable : bool ) -> None :
382382 if enable != self ._loopback_enabled :
383- self ._sock .setsockopt (socket . SOL_CAN_RAW , socket .CAN_RAW_RECV_OWN_MSGS , int (enable )) # type: ignore
383+ self ._sock .setsockopt (_SOL_CAN_RAW , socket .CAN_RAW_RECV_OWN_MSGS , int (enable )) # type: ignore
384384 self ._loopback_enabled = enable
385385
386386 @staticmethod
@@ -478,6 +478,7 @@ class _NativeFrameDataCapacity(enum.IntEnum):
478478""" recovered to error active state"""
479479
480480# From the Linux kernel (linux/include/uapi/linux/can/raw.h); not exposed via the Python's socket module
481+ _SOL_CAN_RAW = 100 + 1
481482_CAN_RAW_ERR_FILTER = 2
482483
483484_CAN_EFF_MASK = 0x1FFFFFFF
@@ -512,7 +513,7 @@ def _make_socket(iface_name: str, can_fd: bool, native_frame_size: int) -> socke
512513 # - "SocketCAN and queueing disciplines: Final Report", Sojka et al, 2012
513514 s .setsockopt (socket .SOL_SOCKET , _SO_SNDBUF , min (blocking_sndbuf_size , default_sndbuf_size ) // 2 )
514515 if can_fd :
515- s .setsockopt (socket . SOL_CAN_RAW , socket .CAN_RAW_FD_FRAMES , 1 ) # type: ignore
516+ s .setsockopt (_SOL_CAN_RAW , socket .CAN_RAW_FD_FRAMES , 1 ) # type: ignore
516517
517518 s .setblocking (False )
518519
0 commit comments