Skip to content

C++ (cyclonedds-cxx release 11.0.0) and C (cyclonedds release 11.0.0) work differently with XType @appended Enumeration Value #2354

@rbtboat

Description

@rbtboat

Test Report: C++ and C work differently with XType @appended Enumeration Value

Objective

Test OMG DDS X-Types 1.3 behavior when an XType @appended Enumeration value
maps to default value (ordinal 0) using @try_construct(USE_DEFAULT).

Test Setup

HelloWorld1 idl:
module HelloWorldData
{
@appendable
enum ColorAppendable {
CA_UNKNOWN,
CA_BLACK,
CA_WHITE
};
@topic
@appendable
struct Msg
{
@key
long userID;
string message;
ColorAppendable colorAppendable;
};
};

HelloWorld2 idl:
module HelloWorldData
{
@appendable
enum ColorAppendable {
CA_UNKNOWN,
CA_BLACK,
CA_WHITE,
CA_RED // Added/Appended New Value
};
@topic
@appendable
struct Msg
{
@key
long userID;
string message;
ColorAppendable colorAppendable;
};
};

C++ Test Procedure (cyclonedds-cxx release 11.0.0)

  1. C++ HelloWorld2 Publisher writes Msg with colorAppendable = CA_RED
  2. C++ HelloWorld1 Subscriber (unaware of CA_RED) reads Msg successfully
  3. colorAppendable mapped to CA_UNKNOWN (ordinal 0)
  4. This works because idlc generates “enum_conversion” API to unknown value to default case, which is “0”.
  5. Equivalent to @try_construct(USE_DEFAULT), see the idlc generated C++ code with enum_conversion API.

c Test Procedure (cyclonedds release 11.0.0)

  1. c HelloWorld2 Publisher writes Msg with colorAppendable = CA_RED
  2. c HelloWorld1 Subscriber (unaware of CA_RED) fails to read Msg
  3. c HelloWorld1 gets "deserialization HelloWorldData_Msg/HelloWorldData::Msg failed (for reasons unknown)"
  4. This fails because read_normalize_enum in dds_cdrstream.c return “false” if the value is greater the maximum value of enumeration type.
  5. Equivalent to @try_construct(DISCARD) which is the XTpes default behavior when @try_construct is not specified

Requested Change

Add idlc options to allow idlc generated c code to act equivalent to @try_construct(USE_DEFAULT).
Note: idl compiler options are standard solutions from other OMG DDS vendor implementations that do not support @try_contruct annotation in the IDL.
RTI Community: https://community.rti.com/static/documentation/connext-dds/current/doc/api/connext_dds/api_cpp2/classrti_1_1config_1_1compliance_1_1XTypesMask.html.

Example Programs

cyclonedds-cxx:
HelloWorld1 source: helloWorld_cxx.zip
HelloWorld2 source: helloWorld_cxx.zip

Cyclonedds (C version):
HelloWorld1 source: helloWorld_c.zip
HelloWorld2 source: helloWorld_c.zip

helloWorld_c.zip
helloWorld_cxx.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions