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

Zephyr k_fifo_is_empty()

Documentation states that k_fifo_is_empty() returns 0 if data is available in the fifo (which is really implemented using a queue).

I'm receiving some spurious interrupts and while trying to track down where they are coming from am zeroing in on my use of a fifo (k_fifo).

I'm testing to see if data is available in the fifo before attempting to read from it, and seeing that k_fifo_is_empty() really returns the pointer to the "head" of the queue (_queue in the k_fifo structure).    It appears that this is set to NULL when initialized.    So if you initialize a fifo, then ask if data is available, it returns zero.     This appears to contradict the definition of the k_fifo_is_empty() return value.

So when I test to see if data is available (using the k_fifo_is_empty()) and receive 0, I attempt a k_fifo_get() and get an interrupt (due to addressing issues).

I'm not sure if this is the ultimate problem I'm facing, but need confirmation that k_fifo_is_empty() is working properly or documented properly...

Thanks!

Related