File tree 1 file changed +10
-2
lines changed
ports/stm/common-hal/canio
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -241,13 +241,21 @@ void common_hal_canio_can_send(canio_can_obj_t *self, mp_obj_t message_in)
241
241
//
242
242
// We don't strictly guarantee that we abort the oldest Tx request,
243
243
// rather we just abort a different index each time. This permits us
244
- // to avoid tracking this information altogether.
244
+ // to just track a single cancel index
245
245
HAL_CAN_AbortTxRequest (& self -> handle , 1 << (self -> cancel_mailbox ));
246
246
self -> cancel_mailbox = (self -> cancel_mailbox + 1 ) % 3 ;
247
+ // The abort request may not have completed immediately, so wait for
248
+ // the Tx mailbox to become free
249
+ do {
250
+ free_level = HAL_CAN_GetTxMailboxesFreeLevel (& self -> handle );
251
+ } while (!free_level );
247
252
}
248
253
HAL_StatusTypeDef status = HAL_CAN_AddTxMessage (& self -> handle , & header , message -> data , & mailbox );
249
254
if (status != HAL_OK ) {
250
- mp_raise_OSError (MP_ENOMEM );
255
+ // this is a "shouldn't happen" condition. we don't throw because the
256
+ // contract of send() is that it queues the packet to be sent if
257
+ // possible and does not signal success or failure to actually send.
258
+ return ;
251
259
}
252
260
253
261
// wait 8ms (hard coded for now) for TX to occur
You can’t perform that action at this time.
0 commit comments