Why does my FIFO queue get stuck on the 1st message?

I have a FIFO queue in a chart in Stateflow where I am trying to read multiple messages in a while loop:

while receive(FIFO)
temp = length(FIFO);
end
However, it gets stuck to the first message received from the FIFO queue. How can I resolve this?

 Accepted Answer

Stateflow charts need to discard the message in order to receive the next one. By default, they do this at the end of each time step. However, since the chart processes many messages in the same time step in a while loop, the messages need to be explicitly discarded. 
The code should instead be:
while receive(FIFO)
temp = length(FIFO);
discard(FIFO);
end
For more background on this function and controlling message activity in general please refer to the following documentation:

More Answers (0)

Categories

Find more on Decision Logic in Help Center and File Exchange

Products

Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!