take vs take_next_sample

2 posts / 0 new
Last post
Offline
Last seen: 11 years 1 month ago
Joined: 10/25/2013
Posts: 1
take vs take_next_sample

I was wondering if anybody else has seen an error I am having and if so they have any idea how to solve it.


In our system we use take when reading.  It works 100% of the time giving the data writen with no issues.

 

When intergrating with another department their reader is using take_next_sample.  When I write their reader triggers but gets garbage data.

So I went ahead and made my own reader matched to the writer when I use take it comes across perfectly.  When I use take_next_sample it gives mostly zeros and a sprinkling of numbers.

 

Any ideas?

 

below is code snipets with comments

 

            // This Reader Works
            ABC_DataArraySeq  data_seq;
            DDS_SampleInfoSeq info_seq;

            retcode = abcDataArrayReader_->getReader()->take(
                    data_seq, info_seq,
                    DDS_LENGTH_UNLIMITED,
                    DDS_ANY_SAMPLE_STATE,
                    DDS_ANY_VIEW_STATE,
                    DDS_ANY_INSTANCE_STATE);
            ABC_DataArray data;
            
            if (retcode == DDS_RETCODE_OK)
      {
          for (int i = 0; i < data_seq.length(); ++i)
          {
              if (info_seq[i].valid_data)
              {
                  data = data_seq[i];
                  info = info_seq[i];
              }
          }
      }

      retcode = abcDataArrayReader_->getReader()->return_loan(data_seq, info_seq);
            

          // This Reader never works
            ABC_DataArray data;
            DDS_SampleInfo info;

            retcode = abcDataArrayReader_->getReader()->take_next_sample(data,info);
            
            
            
            
        // The Writer
            
        ABC_DataArrayDataWriter *pWriter = ABC_DataArrayDataWriter::narrow(abcDataArrayWriter_->getWriter());

        ABC_DataArray dsfArray;
        abcArray = messageQueue_.front().getMessageAsabcDataArray();
        pWriter->write( abcArray, DDS_HANDLE_NIL );

Organization:
Gerardo Pardo's picture
Offline
Last seen: 3 weeks 4 days ago
Joined: 06/02/2010
Posts: 602

Hi,

Perhaps this is related to the fact that the ABC_DataArray constructor generated by rtiddsgen does not initialize the members of the class which can lead to bad behavior.

Take a look a this posting  where someone was also having a problem with the take_next_sample operation which was caused by this same fact: http://community.rti.com/forum-topic/simple-take-next-sample-fails

Gerardo