Zephyr ASYNC Uart and Data Processing

Hi, 

Context: 

    I am looking at feeding the ASYNC UART data into a ring buffer. Then, processing that ring buffer at regular intervals. I'm concerned that the ASYNC UART callback function could get triggered while the ring buffer is being processed. I could forsee some problems with that. I suppose it wouldn't be totally detrimental, provided the ring buffer does not overflow. However, I could see the ring buffer filling up concurrently when a processing operation. To prevent this problem, I would like to temporarily suspend the ASYNC UART callback.

Goal:

To prevent this problem, I would like to temporarily suspend the ASYNC UART callback. Is that possible, without otherwise causing impact on the data transfer? 

Parents
  • Hi Chad

    One of the reasons for using a ring buffer is to allow it to be filled and emptied concurrently. The critical point is to ensure that there is enough free space in the buffer at all time to handle the maximum amount of data that you might have to process in a single UART callback (set by the UART RX buffer size). 

    If you don't respond to buffer requests then RX will eventually get disabled, and no more data will be received, but this will limit the data transfer speed, and lead to data loss if you don't use hardware flow control. 

    Some time back I made my own UART async wrapper in an attempt to provide a simple interface to the application, while at the same time allowing for high throughput and minimal memory consumption. 

    I decided to use memslabs for the RX buffers rather than ringbuffers, because the ringbuffers have some limitations in the way the UART RX buffers are allocated and freed that made them less optimal. 

    The library is available here if you want to have a look at it. It if is sufficient for your application it might save you some time not having to make your own Wink

    As you can see from the simple sample you can initialize and use it with very little application code needed. 

    Best regards
    Torbjørn

Reply
  • Hi Chad

    One of the reasons for using a ring buffer is to allow it to be filled and emptied concurrently. The critical point is to ensure that there is enough free space in the buffer at all time to handle the maximum amount of data that you might have to process in a single UART callback (set by the UART RX buffer size). 

    If you don't respond to buffer requests then RX will eventually get disabled, and no more data will be received, but this will limit the data transfer speed, and lead to data loss if you don't use hardware flow control. 

    Some time back I made my own UART async wrapper in an attempt to provide a simple interface to the application, while at the same time allowing for high throughput and minimal memory consumption. 

    I decided to use memslabs for the RX buffers rather than ringbuffers, because the ringbuffers have some limitations in the way the UART RX buffers are allocated and freed that made them less optimal. 

    The library is available here if you want to have a look at it. It if is sufficient for your application it might save you some time not having to make your own Wink

    As you can see from the simple sample you can initialize and use it with very little application code needed. 

    Best regards
    Torbjørn

Children
No Data
Related