diff --git a/drivers/can.c b/drivers/can.c index f79958bb46..dd47a2caf0 100644 --- a/drivers/can.c +++ b/drivers/can.c @@ -330,6 +330,7 @@ static ssize_t can_read(FAR struct file *filep, FAR char *buffer, do { ret = sem_wait(&dev->cd_recv.rx_sem); + DEBUGASSERT(ret >= 0 || errno == EINTR); } while (dev->cd_recv.rx_head == dev->cd_recv.rx_tail); dev->cd_nrxwaiters--; diff --git a/include/nuttx/can.h b/include/nuttx/can.h index dc6c2db27d..c1f59b9882 100644 --- a/include/nuttx/can.h +++ b/include/nuttx/can.h @@ -283,7 +283,7 @@ struct can_dev_s { uint8_t cd_ocount; /* The number of times the device has been opened */ uint8_t cd_npendrtr; /* Number of pending RTR messages */ - uint8_t cd_ntxwaiters; /* Number of threads waiting to enqueue a message */ + volatile uint8_t cd_ntxwaiters; /* Number of threads waiting to enqueue a message */ volatile uint8_t cd_nrxwaiters; /* Number of threads waiting to receive a message */ sem_t cd_closesem; /* Locks out new opens while close is in progress */ sem_t cd_recvsem; /* Used to wakeup user waiting for space in cd_recv.buffer */