Home/Support/Support Forum/How can the receive buffer be cleared/flushed before using readDataFrom(...)?

How can the receive buffer be cleared/flushed before using readDataFrom(...)?

0 votes
Is there a way to flush the receive message buffer before calling the readDataFrom function? If it is not flushed it may contain older messages from before the command.
asked Aug 22, 2017 in Miscellaneous Hardware and Software by keplerian New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
I just ran into the need to flush the receive buffer during a reboot. There may be an easier way to do it.

# flush old messages prior to your main loop
received_msg = xbee.receive()
while received_msg:
received_msg = xbee.receive()

while True:
# Your main loop
answered Jan 29, 2021 by LLamabobAL New to the Community (2 points)
...