EVerest / libiso15118

ISO 15118 library suite
Apache License 2.0
8 stars 5 forks source link

_isUsed inside of union iso20_PGPDataType #1

Closed SiebrenW closed 10 months ago

SiebrenW commented 10 months ago

Looking through the code I noticed that the _isUsed for the choices in the iso20_PGPDataType union are within the union. That is not going to work.

struct iso20_PGPDataType {
    union {
        // sequence of choice 1
        struct {
            // PGPKeyID, base64Binary
            struct {
                uint8_t bytes[iso20_base64Binary_BYTES_SIZE];
                uint16_t bytesLen;
            } PGPKeyID;
            // PGPKeyPacket, base64Binary
            struct {
                uint8_t bytes[iso20_base64Binary_BYTES_SIZE];
                uint16_t bytesLen;
            } PGPKeyPacket;
            unsigned int PGPKeyPacket_isUsed:1;
            // ANY, anyType (base: base64Binary)
            struct {
                uint8_t bytes[iso20_anyType_BYTES_SIZE];
                uint16_t bytesLen;
            } ANY;
            unsigned int ANY_isUsed:1;
        } choice_1;
        // =================
        // here's the issue:
        unsigned int choice_1_isUsed:1; // <- here, takes same memory as PGPKeyID, choice_2_isUsed, and PGPKeyPacket
        // sequence of choice 2
        struct {
            // PGPKeyPacket, base64Binary
            struct {
                uint8_t bytes[iso20_base64Binary_BYTES_SIZE];
                uint16_t bytesLen;
            } PGPKeyPacket;
            // ANY, anyType (base: base64Binary)
            struct {
                uint8_t bytes[iso20_anyType_BYTES_SIZE];
                uint16_t bytesLen;
            } ANY;
            unsigned int ANY_isUsed:1;
        } choice_2;
        unsigned int choice_2_isUsed:1; // same here
    };
    // should be here
    // unsigned int choice_1_isUsed:1;
    // unsigned int choice_2_isUsed:1;    
};
barsnick commented 10 months ago

Good point.

This is in the code imported from cbV2G, as generated by cbExiGen.

As mentioned in https://github.com/EVerest/cbexigen/issues/56, the code for choice sequences is not completely correct anyway, this is an additional artefact of that. As furthermore mentioned, this element is not to be used, according to ISO 15118-2 and ISO 15118-20, therefore we are not putting any manpower into fixing it.

If someone happens to want to use it anyway, feel free to propose a fix/PR to the code generator. Thank you.