Proper use of take_next_sample() and SampleInfo

2 posts / 0 new
Last post
Offline
Last seen: 1 year 2 months ago
Joined: 10/23/2013
Posts: 43
Proper use of take_next_sample() and SampleInfo

I have an application that uses read_next_sample()/take_next_sample().   What is the proper way for the application to determine if a valid sample has been read/taken.  Does return value of DDS_RETURN_OK indicate a valid sample?  Or must SampleInfo.valid_data also be checked before using the sample data?

This link suggests that checking return value is sufficient.

This this link indicates that sampleInfo also needs to be checked.. but not sure if it applies to take_next_sample()/read_next_sample()

 

Thanks

Mark.

 

Organization:
Offline
Last seen: 3 months 3 days ago
Joined: 02/11/2016
Posts: 144

Hey Mark,

reading the links you've put up (as well as the api: http://community.rti.com/rti-doc/510/ndds/doc/html/api_java/classcom_1_1rti_1_1ndds_1_1example_1_1FooDataReader.html#ab889dab99d429b9a4ecfe94053745847) it would seem that the answer is this:

The sample you receive may still be "invalid" in the sense that it may be a sample that signifies other instance states (for example: NOT_ALIVE_DISPOSED or NOT_ALIVE_NO_WRITERS).

That being said, I am glad you taught me about this api, I may use it :)

As I am not 100% certain I would recommend giving it a try:

setup a reader, then setup a writer.

use the writer to write a sample and make sure that you can read(or take) next sample.

then have the writer dispose (or unregister) the instance and see if the reader can read a new sample.

 

Thank you and good luck,

Roy.