This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Feedback on nrf_serial API - process for detecting transmission complete

Hi, I've got an application where I need to send a message and then receive a response on a half duplex serial link.

I feel like this is a pretty common use case but the way I found of detecting transmission complete is kind of awkward. The serial library generates a NRF_SERIAL_EVENT_TX_DONE event for every single character, so I have to dig deep into the SDK internals to detect when all bytes have been transmitted.

It seems like there ought to be a better way, like a field in nrf_serial_event_t to indicate how many bytes remain in the transmit queue

modbus_uart_event_handler(struct nrf_serial_s const *p_serial, ... nrf_serial_event_t event) {
    ...
    case NRF_SERIAL_EVENT_TX_DONE:
        nrf_queue_t const * p_txq = p_serial->p_ctx->p_config->p_queues->p_txq;
        if (nrf_queue_is_empty(p_txq)) {
            /* switch the transceiver to receive and start the nrf_serial_read() */

Any ideas for a better way to do this, or can the nrf_serial API be extended in the future?

 

Parents Reply Children
No Data
Related