Open siddux opened 1 year ago
The contents of debug_info
is pure garbage, I would say, every single field as very impossible (e.g., instance_handle
= 0), or at least an implausible (e.g., source_timestamp
= 37ns 1-1-1970 00:00 GMT) value.
dds_take
returns the number of samples it read, so if 0 < return_code
< MaxSamplesNum
then the loop is simply reading garbage for return_code
≤ i
< MaxSamplesNum
. That would be my guess.
Thanks for the explanation @eboasson! In the case of return_code
≤ i
< MaxSamplesNum
, we should just be checking that samples[i] != NULL
for a valid message? Similar to https://github.com/eclipse-cyclonedds/cyclonedds/blob/bc91e11b5c74a592a41cb673a8af16d5a25cb4f5/src/core/ddsc/tests/loan.c#L195-L197
@aaronchongth, you should always only check the valid_data
flag to know what it is you got, and then only for 0
≤ i
< return_code
. The entries return_code
≤ i
< MaxSamplesNum
are best considered garbage that is not to be looked at 🙂
(In reality they aren't garbage, the pointers'll will point to somewhat valid samples, butbut I'd rather keep as much freedom there as I possibly can 😁)
Hi,
I'm using dds implementation from ROS2 Galactic. I observed strange behavior on the code and after debugging it I've found what it seems a problem. I'm using the dds_sample_info to retrieve info about the received messages and decide where to process them or just ignore. At some point of my code I've the following function lines:
when receiving valid messages all work as expected. The problem comes when I receive empty messages (which has not been initialized). When checking if the message is valid, accessing the
'valid_data
member from the struct it returns an integer (non-zero). Below you can find a screenshot of the debugger, sincerely I couldn't understand why the boolean returns "random" integer values.At this moment I can bypass this just changing from:
if (infos[i].valid_data)
to:
if (infos[i].valid_data == true)
Is this behavior correct? Is there any more elegant solution for this problem?
Thanks.