In the function tlp_get(...) (file trdp_if.c) in order to get all the received messages the trdp_pdReceive(...) function is called in a loop (in the case of non blocking mode). The condition to exit the loop is that the function returns any value different to TRDP_NO_ERR. The point is that any error in trdp_pdReceive(TRDP_CRC_ERR, TRDP_NOSUB_ERR...) causes the loop to end, and at the same time to return from tlp_get(...). In our opinion this is wrong because any incorrect message makes to finish the reception process. For example, if the device receives non-subscribed comId messages, each time one of these messages is got, the tlp_get() function will return, so the rest of the messages won't be processed.
We think that in each call of tlp_get(...) all the messages got in the receiving socket must be processed, discarding those that are incorrect or we are not interested, and saving the good ones in the reception queue. The only condition to finish the reception loop must be that the configured time out has been reached or that there is not any message pending to process.
We have attached a patch that has this change applied. The version of the library in which the change has been implemented and tested is 1.4.2.0 but it could be applied to the last (currently) oficial version 2.0.3.0r1 since the code has not been changed (file tlp_if.c in version 1.4.2.0 and tlp_if.c in 2.0.3.0r1). At the same time, another change has been implemented in trdp_pdcom.c in order to update the statistics when a non-subscribed ComId message is received.
Both patches are attached.
Diff: