k_fifo_get does not remove the item

Hi,

I'm on NCS 1.9.2, and I'm having a unexpected behavior on the consumer thread of a k_fifo.
The documentation states that the k_fifo_get routine removes a data item from fifo in a “first in, first out” manner.
However, even if I inject one single element in the fifo, the cosumer thread continues to get the same element indefinitely many times.
This is the thread code

while (true) {
    struct lcuml_data_t *buf;
    buf = k_fifo_get(&tx_queue, K_FOREVER);

    usb_transfer(cfg->endpoint[IN_EP_IDX].ep_addr, buf->data, buf->len, USB_TRANS_WRITE, usb_on_sent, cfg);
    k_msleep(10);
}

I expected to see the k_fifo_get() blocking behavior, keeping from more than one usb transfer to happen. 

This is the k_fifo_put side

while (true) {
    struct lcuml_data_t *buf;
    buf = k_malloc(sizeof(*buf));
    if (buf) {
        buf->len = 1 + snprintf(buf->data, sizeof(*buf), "mymsg%08x", idx++);
        k_fifo_put(&tx_queue, buf);
    } else {
        printk("unable to allocate buffer\n");
    }
    k_msleep(50);
}

Parents Reply Children
Related