DDS Python API Enum

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

As the documents are shown in, 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 {






// 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;





Last seen: 2 weeks 2 days 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): 

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


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     ..



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