I am working on the safety-critical system, I have, ON and OFF function, the entire system using UART communication. In which I am using the nrf_queue() and push the data to scooter_uart_flush line when it's in idle mode.
Very dangerous, I see after sending command OFF, it has one buffer in the queue somehow pops in the end, do not know what is causing the issue?
can someone help in figuring out the problem? its dangerous behavior for my application, I am not so experienced with NRF API 15.02, please someone guide me on how to completely clear the qeue()
I am worried if I don't manage to get deterministic behavior can cause the entire project to halt.
Appreciate the help.
//My queue definition. NRF_QUEUE_DEF(typeof(uart_cmd), iq_queue, 10, NRF_QUEUE_MODE_NO_OVERFLOW); if (lock == ON) { nrf_queue_push(module->iq_queue, &cmd); uart_send_command(cmd, event_handler); } else if (lock == OFF) { nrf_queue_reset(module->iq_queue); nrf_queue_reset(module->iq_queue); //paranoia reset this doesn't help also nrf_serial_flush(&serial_uarte, 0); //This doesn't even flush the serial line. NRF_LOG_INFO("SC queue :%d", nrf_queue_is_empty(module->iq_queue)); if (nrf_queue_is_empty(module->iq_queue) == true) { NRF_LOG_INFO("In loop SC queue :%d", nrf_queue_is_empty(module->iq_queue)); uart_cmd_t cmd = uart_cmd1; nrf_queue_push(module->iq_queue, &cmd); uart_send_command(cmd, scooter_event_handler); } }
This is the stdout of my application
11 14 02 15 15 13 |.....n 11 14 02 15 15 13 |.....n 11 14 02 15 15 13 |.....n IQ queue :1 <-- Here queue is 1 In loop IQ queue :1 <--- Inside the queue empty list, scratching my head why its not 0? 11 14 02 10 15 21 11 14 02 10 15 21 |...... //for safety reason I send the commands three times that doesn't solve either. 11 14 02 10 15 21 |...... 11 14 02 10 15 21 |...... 11 14 02 15 15 13 |.....n // Issue is here somehow the previous tx queue is not fully cleared and it still has one command.