Skip to content

Commit c474296

Browse files
committed
use the same error messages in socketcan_ctypes' send() as in socketcan_native's send()
1 parent 16c6191 commit c474296

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

can/interfaces/socketcan/socketcan_ctypes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,16 @@ def recv(self, timeout=None):
125125

126126
def send(self, msg, timeout=None):
127127
frame = _build_can_frame(msg)
128+
128129
if timeout:
129130
# Wait for write availability. write will fail below on timeout
130-
select.select([], [self.socket], [], timeout)
131+
_, ready_send_sockets, _ = select.select([], [self.socket], [], timeout)
132+
if not ready_send_sockets:
133+
raise can.CanError("Timeout while sending")
134+
131135
bytes_sent = libc.write(self.socket, ctypes.byref(frame), ctypes.sizeof(frame))
136+
132137
if bytes_sent == -1:
133-
log.debug("Error sending frame :-/")
134138
raise can.CanError("can.socketcan.ctypes failed to transmit")
135139
elif bytes_sent == 0:
136140
raise can.CanError("Transmit buffer overflow")

0 commit comments

Comments
 (0)