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

Polling Mode in Serial library

Hello,

Can anyone point me to a good example for Polling mode using serial library?

I'm looking for an application in which I can poll the serial port for data. I went through API documentation and found that Serial library has a polling mode. Can anyone guide me in using that?

  • It does print the received data in the first iteration. It gets stuck only in the second iteration of the loop.

    Btw, I'm going with polling mode because the functionality I'm trying to achieve is very trivial and doesn't need any complex queues and interrupt handlers. I just have to read data from both UARTs at will and store them. An example or code snippet describing the nuances of this polling mode would be very helpful. 

  • When using the POLLING mode, the function calls nrf_serial_read and nrf_serial_write will not return until the operation is complete (the number of specified bytes have been transmitted or received), the timeouts will not be functional. If you do not write anything to the UART line, it will be stuck on the read if until the requested number of bytes are received. nrf_serial_flush will not have any effect in polling mode:

    if (p_serial->p_ctx->p_config->mode == NRF_SERIAL_MODE_POLLING)
    {
        return NRF_SUCCESS;
    }

Related