Keep receiving old message in channel


while using tx/rx channel for communication, even though I publish a message once, receiver keep receiving the old message. This happens in C++, python, and JS codelete.

This is the code that I publish:

if (pub_data) {
  auto proto = tx_test_proto().initProto();
else {
  LOG_INFO("Not sending data");

I used the following code to receive the message and print out the publishing time:

if (rx_test_proto().available()) {
    const double pubtime = rx_test_proto().pubtime();
    printf("Pub time: %f \n", pubtime);

The result turns out that even if the test channel is not sending any new message, I am still receiving messages from the test channel. By looking into the publishing time of the message, I can confirm that the message is old as the publishing time is the same.

rx_test_proto() will only read the last message receiver but not clear it. You should be able to get the behavior you want with rx_test_proto().processLatestNewMessageBuffered([](<PROTO type>{}) or the processAllNewMessagesBuffered() variant. These will invoke your callback with the received protos and clear the queue so available() starts returning false after processing.