COVESA / capicxx-someip-tools

Common API C++ SOMEIP tooling
Mozilla Public License 2.0
78 stars 54 forks source link

Compile error related to extended structs with array member #10

Open lucka-me opened 4 years ago

lucka-me commented 4 years ago

Hello, I'm studying the SOME/IP by following the Wiki but encontered a compile error and I have no idea about how to solve it.

The .fidl file:

typeCollection CommonType {
    version { major 1 minor 0 }
    enumeration ValueType {
        Node            = 0
        LaneModel       = 4
        FormOfWay       = 16
        VersionSoftware = 52
    }
    struct ValueBase polymorphic {
    }
    struct Data {
        ValueType type
        ValueBase value
    }
    struct ValueA extends ValueBase {
         UInt32 id
    }
    struct Item {
        UInt32 size
    }
    struct ValueB extends ValueBase {
         Item [ ] items
    }
}

interface MessageBus {
    version { major 1 minor 0 }
    attribute CommonType.Data data readonly
}

After generating code with commonapi-generator and commonapisomeip_generator, I compiled my test code but failed with:

error: no matching function for call to 'CommonAPI::SomeIP::OutputStream::writeValue(const std::vector<v1::com::CommonType::Item>&, const CommonAPI::EmptyDeployment*&)'

I haven't dive into CommonAPI yet but it seems that the server write ValueBase with an EmptyDeployment, which doesn't work with array. The compile error won't occur if I remove ValueB and keep ValueA. Should I add something to the .fdepl file or replace the value in Data with a byte buffer and serialize the ValueA and ValueB by myself?

lutzbichler commented 3 years ago

Please check whether this problem persists with CommonAPI v3.2. If yes, please also provide the content of the .fdepl.

lucka-me commented 3 years ago

This problem persists with v3.2 (v3.2.0.1 of both tools).

The Sample.fidl:

package sample

typeCollection CommonType {
    version { major 1 minor 0 }

    enumeration ValueType {
        None            = 0
        Size            = 1
        Items           = 2
    }

    struct ValueBase polymorphic {
    }

    struct Data {
        ValueType type
        ValueBase value
    }
    struct ValueA extends ValueBase {
         UInt32 id
    }
    struct Item {
        UInt32 size
    }
    struct ValueB extends ValueBase {
         Item [ ] items
    }
}

interface MessageBus {
    version { major 1 minor 0 }
    attribute CommonType.Data data readonly
}

And Sample.fdepl:

import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
import "Sample.fidl"

define org.genivi.commonapi.someip.deployment for interface sample.MessageBus {
    SomeIpServiceID = 4660

    attribute data {
        SomeIpNotifierID = 33333
        SomeIpNotifierReliable = true
        SomeIpEventGroups = { 33333 }
        //SomeIpNotifierEventGroups = { 222 }
    }
}

define org.genivi.commonapi.someip.deployment for provider as SampleService {
    instance sample.MessageBus as bus {
        InstanceId = "test"
        SomeIpInstanceID = 22136
    }
}

Error:

<.>/capicxx-core-runtime/include/CommonAPI/OutputStream.hpp:121:47: error: no matching function for call to ‘CommonAPI::SomeIP::OutputStream::writeValue(const std::vector<v1::sample::CommonType::Item>&, const CommonAPI::EmptyDeployment*&)’

And there are two more errors:

<.>/src-gen/v1/sample/MessageBusSomeIPStubAdapter.hpp:79:36: error: ‘DataDeployment’ is not a member of ‘v1::sample::CommonType_’

<.>/src-gen/v1/sample/MessageBusSomeIPStubAdapter.hpp:102:128: error: ‘DataDeployment’ is not a member of ‘v1::sample::CommonType_’

By the way, src-gen/v1/sample/MessageBusStubDefault.cpp is not generated and I removed it from CMakeLists.txt.

lucka-me commented 3 years ago

Here is a work around (NOT solution) from my colleague: replace the array with a map.

In the sample I provided before, replace:

struct ValueB extends ValueBase {
    Item [ ] items
}

With:

map ItemMap {
    Int16 to Item
}

struct ValueB extends ValueBase {
    ItemMap items
}