Skip to content

Commit

Permalink
Fix: Arduino_CAN::write return value incompatible with interface spec…
Browse files Browse the repository at this point in the history
…ification at ArduinoCore-API/HardwareCAN.

This fixes #924.
  • Loading branch information
aentinger committed Sep 20, 2024
1 parent 6b697fe commit 382f4f4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libraries/Arduino_CAN/src/Arduino_CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ int Arduino_CAN::write(CanMsg const & msg)
CANData,
is_standard_id ? CANStandard : CANExtended);

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

size_t Arduino_CAN::available()
Expand Down

0 comments on commit 382f4f4

Please sign in to comment.