Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Help me understand the operation of the NRF_RINGBUF module

Hi!

I'm trying to figure out the nrf_ringbuf module, and would really appreciate some advice about its intended use case. The api exposes the following functions:




This is my current flow of execution:

Ask for space with nrf_ringbuffer_alloc( p_ringbuf, pp_data, p_length, false). This gives me a pointer to where I can write the amount of bytes that I've requested.

Write bytes to the allocated pointer location using memcpy( pp_data, inputBuffer, length )

Commit the bytes to the ring buffer using nrf_ringbuf_put( p_ringbuf, length)

...

Later pop things from the ring buffer using:

However, I am getting an error, NRF_ERROR_INVALID_STATE, from line 94 of nrf_ringbuf.c:

I believe I am not using the api correctly, as I haven't understood the use case of nrf_ringbuf_cpy_put() and cpy_get() . Are these supposed to be called in-between alloc & put, and get & free? It is not very clear in the documentation. Please advise.


Cheers and all the best,
Rares Gosman

Parents Reply Children
No Data