drivers: can: can_loopback: Abort pending messages when stopped
This commit aims at updating the drivers stop function to better follow the CAN header file which specifiec that stopping the CAN controller should "abort any pending CAN frame transmissions". Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
This commit is contained in:
parent
03fd995fd5
commit
500809f8fa
1 changed files with 8 additions and 1 deletions
|
@ -66,12 +66,17 @@ static void tx_thread(void *arg1, void *arg2, void *arg3)
|
|||
struct can_loopback_data *data = dev->data;
|
||||
struct can_loopback_frame frame;
|
||||
struct can_loopback_filter *filter;
|
||||
int ret;
|
||||
|
||||
ARG_UNUSED(arg2);
|
||||
ARG_UNUSED(arg3);
|
||||
|
||||
while (1) {
|
||||
k_msgq_get(&data->tx_msgq, &frame, K_FOREVER);
|
||||
ret = k_msgq_get(&data->tx_msgq, &frame, K_FOREVER);
|
||||
if (ret < 0) {
|
||||
LOG_DBG("Pend on TX queue returned without valid frame (err %d)", ret);
|
||||
continue;
|
||||
}
|
||||
frame.cb(dev, 0, frame.cb_arg);
|
||||
|
||||
if (!data->loopback) {
|
||||
|
@ -255,6 +260,8 @@ static int can_loopback_stop(const struct device *dev)
|
|||
|
||||
data->started = false;
|
||||
|
||||
k_msgq_purge(&data->tx_msgq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue