Add timeout to CAN write to prevent crashing

This commit is contained in:
Daniel 2023-08-16 23:55:28 +03:00
parent 56f7f205e4
commit 7025811c6e
4 changed files with 31 additions and 10 deletions

View file

@ -271,10 +271,7 @@ int CAN_write_frame(const CAN_frame_t *p_frame) {
// Write the frame to the controller
CAN_write_frame_phy(p_frame);
// wait for the frame tx to complete
xSemaphoreTake(sem_tx_complete, portMAX_DELAY);
return 0;
return xSemaphoreTake(sem_tx_complete, 20) == pdTRUE ? 0 : -1;
}
int CAN_stop() {