diff --git a/can/interfaces/socketcan/socketcan.py b/can/interfaces/socketcan/socketcan.py index cdf4afac6..c4c92dce8 100644 --- a/can/interfaces/socketcan/socketcan.py +++ b/can/interfaces/socketcan/socketcan.py @@ -705,14 +705,18 @@ def __init__( # so this is always supported by the kernel self.socket.setsockopt(socket.SOL_SOCKET, constants.SO_TIMESTAMPNS, 1) - bind_socket(self.socket, channel) - kwargs.update( - { - "receive_own_messages": receive_own_messages, - "fd": fd, - "local_loopback": local_loopback, - } - ) + try: + bind_socket(self.socket, channel) + kwargs.update( + { + "receive_own_messages": receive_own_messages, + "fd": fd, + "local_loopback": local_loopback, + } + ) + except OSError as error: + log.error("Could not access SocketCAN device %s (%s)", channel, error) + raise super().__init__( channel=channel, can_filters=can_filters,