CANopenNode/CANopenEditor

Subobjects without default value won't appear in OD.h/.c

HamedJafarzadeh opened this issue · 7 comments

Hi,

Thanks for all your efforts on this repo.

I just noticed that I couldn't get couple of subobjects of a record to show up in the OD.h and .c, after a debugging for a while I figured that if you have not provided a default value, those subobjects wouldn't appear in the OD files. I believe there should be sort of warning in that case to remind the user about that.

Here is the code line that checks for default value I believe.
image

Can not reproduce. Can you provide the xdd and the object index that is missing.

Here is a sample. Object x2000 does not add subobject 0x02 to the generated files.
MissingValuesXdd.zip

Do you expect more than this (from your file)?

.x2000_testrecord = {
        .highestSub_indexSupported = 0x02, <===========
        .testsubwithvalue = 0x00000000
    }

   OD_obj_record_t o_2000_testrecord[3]; <================== SUM(Subs 0,1,2) =3

  .o_2000_testrecord = {
        {
            .dataOrig = &OD_RAM.x2000_testrecord.highestSub_indexSupported,
            .subIndex = 0,
            .attribute = ODA_SDO_R,
            .dataLength = 1
        },
        {
            .dataOrig = &OD_RAM.x2000_testrecord.testsubwithvalue,
            .subIndex = 1,
            .attribute = ODA_SDO_RW | ODA_MB,
            .dataLength = 4
        },
        {
            .dataOrig = NULL,
            .subIndex = 2, <===================
            .attribute = ODA_SDO_RW | ODA_MB,
            .dataLength = 4
        }
    }

Thanks for your response.

According these sub objects, should we see .testsubwithoutvalue somewhere ? and be able to access it like OD_RAM.testrecord.testsubwithoutvalue ?
image

Try bugfix branch c121291

Thanks @trojanobelix . I can confirm that this commit fixes the problem. Although user should note that a variable without default value might have any random values if they use them before assigning a value first.

Sorry, I missed that issue.
CANopenNode V4 actually does not require data storage for a variable. Instead application may define own callbacks for reading or writing OD entry.
See also #73 (comment)