How to read DDS Sequence data in C++.

2 posts / 0 new
Last post
Offline
Last seen: 10 years 4 months ago
Joined: 07/17/2014
Posts: 1
How to read DDS Sequence data in C++.

Below is the sample structure and C++ code i am using to read DDS Sequence Data.

Example IDL Structure Definition:

struct struct1{
enum1 enum_value;
float value;
};
enum enum1
{
ee1=1,
ee2=2,
ee3=3
};
struct num{
sequence<struct1,3> seq1;
};

 

Actual Values Received from DDS:(Example)
 num
 seq1
 enum_value xs:byte    bv: 1  // Value: 1
 value xs:float    bv: 30  // Value: 30

 seq1
 enum_value xs:byte    bv: 2  // Value: 2
 value  xs:float    bv: 35  // Value: 35

 seq1
 enum_value xs:byte    bv: 3  // Value: 3
 value  xs:float    bv: 40  // Value: 40

Code i used to read the DDS Sequence DATA:

struct1 * struct1Buffer = instance.num.struct1.get_contiguous_buffer();
printf("Enum: %d, Value:%f", struct1Buffer->enum_value,struct1Buffer->value);

After reading using get_contiguous_buffer, when i print the values, it always prints the 1st sequence data in the buffer.

OUTPUT:
struct1->enum_value  : 1
struct1->value       : 30

How do i read the next sequences for enum_value 2 and 3. With get_contiguous_buffer() always points to 1st sequence. Is there any other methods to read the further sequences?

Organization:
Offline
Last seen: 3 years 8 months ago
Joined: 01/15/2013
Posts: 94

Hi Balaramesh,

Have you checked out the Sequence support API?

You can access the different members with a loop. You can get the length of the sequence via the  FooSeq_get_length() method. Then you can access each of the objects via the  FooSeq_get() and  FooSeq_get_reference() methods.

I would use the buffer accessors (e.g. FooSeq_get_configuous_buffer) carefully, or avoid it if possible.

Thanks,

Juanlu