Hi everyone,
I use the function nrf_queue_write for queueing data. Also I use the NRF_QUEUE_MODE_OVERFLOW mode to overwrite old data in case the queue is full.
My problem is that nrf_queue_write asserts when the buffer size is greater thant the queue size (see nrf_queue.c)
ret_code_t nrf_queue_write(nrf_queue_t const * p_queue,
void const * p_data,
size_t element_count)
{
ret_code_t status = NRF_SUCCESS;
ASSERT(p_queue != NULL);
ASSERT(p_data != NULL);
ASSERT(element_count <= p_queue->size);
.......
.......
.......
So when I declare a queue size of 4 and try to queue a buffer of 5 elements, nrf_queue_write asserts.
#define QUEUE_SIZE 4 // 4 element queue
NRF_QUEUE_DEF(int16_t, m_sensor_data_queue, QUEUE_SIZE, NRF_QUEUE_MODE_OVERFLOW);
int16_t data_in[] = {6000, 8000, -10000, -12000, -14000};
uint8_t data_in_size = sizeof(data_in) / sizeof(data_in[0]);
void my_sensors_buffer() {
ret_code_t err_code;
nrf_queue_write(&m_sensor_data_queue, data_in, data_in_size); // It asserts when data_in_size > QUEUE_SIZE
APP_ERROR_CHECK(err_code);
}
It seems that something I don't understand. How can I work this arround?