Skip to content

Commit 931f0bb

Browse files
authored
Fix: Arduino_CAN::write return value incompatible with interface specification at ArduinoCore-API/HardwareCAN. (#956)
This fixes #924.
1 parent 6b697fe commit 931f0bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libraries/Arduino_CAN/src/Arduino_CAN.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ int Arduino_CAN::write(CanMsg const & msg)
5757
CANData,
5858
is_standard_id ? CANStandard : CANExtended);
5959

60-
return _can.write(can_msg);
60+
int const rc = _can.write(can_msg);
61+
if (rc == 0) /* mbed returns 0 in case of failed CAN::write(). */
62+
return -1; /* Note: provide named constant in ArduinoCore-API/HardwareCAN.h, i.e. CAN_WRITE_GENERIC_ERROR */
63+
return 1;
6164
}
6265

6366
size_t Arduino_CAN::available()

0 commit comments

Comments
 (0)