DDS Python API Enum

2 posts / 0 new
Last post
Offline
Last seen: 1 year 10 months ago
Joined: 04/20/2022
Posts: 3
DDS Python API Enum

As the documents are shown in https://community.rti.com/static/documentation/connext-dds/6.0.1/api/connext_dds/api_python/intro.html, we have some initial tests (prototype) on DDS Python APIs, based on Connext DDS v6.0.1. It is very nice we might use Python much easier. But it seems we can NOT access 'enum' variables in a 'Base' IDL, which is shown as follows.

FYI, from the 'fields', it is correctly showing all 'enum' variables, including 'eb' in struct 'Base' and 'ec' in struct 'C'

>>> print([v for v in sample.fields()])

Could you help to confirm whether it is an issue? And any quick solutions? (As you might know, we can not change the IDL for Python usually.)

 

// IDL files: EE.idl, Base.idl, C.idl

// EE.idl

module bbb {

enum EE {

  A,

  B

};

};

 

// Base.idl

module bbb {

struct Base {

  EE eb;   // reporting: member 'eb' doesn't exist.

  long i;   // works as expected

};

};

 

// C.idl

module ccc {

struct C : bbb::Base {

  bbb::EE ec;   // works as expected

  long c;

};

};

 

 

Keywords:
Offline
Last seen: 4 months 2 weeks ago
Joined: 09/23/2018
Posts: 63

It looks like we have a bug in accessing enumerated members in a Base class.   This is currently under investigation.   

Reproducer that mimics IDL code above  (with slight changes): 

  <types>
    <module name="bbb">
      <enum name="EE">
        <enumerator name="A"/>
        <enumerator name="B"/>
      </enum>
      <struct name= "Base">
        <member name="b" type="int32"/>
        <member name="ea" type="nonBasic"  nonBasicTypeName= "bbb::EE"/>
        <member name="eb" type="nonBasic"  nonBasicTypeName= "bbb::EE"/>
      </struct>
    </module>
    <module name="ccc">
      <struct name= "Sample" baseType="bbb::Base">
        <member name="c" type="int32"/>
        <member name="ec" type="nonBasic"  nonBasicTypeName= "bbb::EE"/>
      </struct>
    </module>
   </types>

 

def publish_env(id, writer, my_type):
    sample = dds.DynamicData(my_type)
    sample["c"] = id
    sample["ec"] = enum_type["A"]

    sample["b"] = id + 1                     # Ints in base work
    sample["ea"] = enum_type["A"]   # ERROR: ea is an unknown member
    sample["eb"] = enum_type["B"]   #   ..   eb     ..

    writer.write(sample)

 

The above reproducer code is based on the xml_application example provided with the RTI Python API.