This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using DSS to Set Data in a Union

Other Parts Discussed in Thread: CCSTUDIO

I am attempting to access a union using the DSS API. In my code I have this data type:

typedef union{
struct{
Uint64 Temp1:13;
Uint64 Temp2:13;
Uint64 Temp3:13;
Uint64 Temp4:13;
Uint64 Temp5:12;
};
struct{
Uint32 DataL;
Uint32 DataH;
};
Uint64 ull_value;
} Temps_t;

And a data item

Temps_t tempData

that is part of a larger structure:

Data

I have a jython script using the DSS API that is trying to set that value. I can connect and set/read other values fine but when I try to write to a to a union like this:  

DSS.session.expression.evaluate("tempData.Temp5 = 5")

I get the following error:

ScriptingException: com.ti.ccstudio.scripting.environment.ScriptingException: Error evaluating "Data.tempData.Temp5= 5": member 'Temp5' not found
E ((Data).tempData).Temp5

How do I use the DSS "evaluate" with unions in structures? 

  • I believe that you have to name the structs within the union and access them via that name. Example:

    typedef union {
      struct TempX {
        Uint64 Temp1:13;
        Uint64 Temp2:13;
        Uint64 Temp3:13;
        Uint64 Temp4:13;
        Uint64 Temp5:12;
      };
      struct DataX {
        Uint32 DataL;
        Uint32 DataH;
      };
      Uint64 ull_value;
    } Temps_t;
    
    (Temps_t included in struct Data instanced as variable tempData as OP indicated)

    Then access it like:

    DSS.session.expression.evaluate("tempData.TempX.Temp5 = 5")

**Attention** This is a public forum