ADTF_DEVICE_TOOLBOX  3.9.0 (ADTF 3.14.3)
SOME/IP Support Service
Introduction

This documentation is about using the SOME/IP API of the DeviceToolbox for the purpose of programming ADTF modules. It is adressed to C++ programmers with knowledge about the ADTF programming interfaces.

Plugin Information
Plugin Filenamesomeip.adtfplugin
Plugin Descriptionsomeip.plugindescription
Plugin NameSOME IP Support Service
LicenseADTF
Support Mailsupport@digitalwerk.net
Homepage URLwww.digitalwerk.net
Plugin Versions
Plugin Version3.9.0
Plugin File Version1.0
adtf::devicetb3.9.0
adtf3.14.3
adtf::ucom3.1.0
Component Information
NameSOME IP Support Service
CIDsomeip.service.devicetb.cid
DescriptionThe SOME/IP service is responsible for loading a SOME/IP database parser library and providing access to the ISomeIpDatabse contained within. The service also handles the creaton of ISomeIpDecoder instances for convenient access of SOME/IP samples.
TypeService
Default Runlevelsession
Properties
NameValueTypeDescriptionSubproperties
someip_database_pathscFilenameListList of files containing the SOME/IP database.
Required Interfaces
IID
someip_arxml.parser.someip.sdk.devicetb.adtf.iid
macroresolver.ant.base.adtf.iid
Provided Interfaces
IID
bus_database_registry.axle.sdk.devicetb.adtf.iid
someip_service.hood.someip.sdk.devicetb.adtf.iid
someip_database.hood.someip.sdk.devicetb.adtf.iid
someip_decoder.hood.someip.sdk.devicetb.adtf.iid

Structure of SOME/IP Samples

SOME/IP samples consist of a sample header followed by one or more SOME/IP messages. The header contains metadata such as the network endpoints and protocol as well as the number of messages contained in the sample. The messages themselves are stored in the sample in the unchanged on-wire format. Samples containig more than one message indicate, that the messages were part of a single UDP packet received from the network.

Processing SOME/IP Samples in a Filter

Receiving SOME/IP Samples

For a Fitler or Streaming Sink to process SOME/IP samples it must merely provide an input pin with the apropriate Stream Meta Type.

// In the filters constructor
CreateInputPin("someip_in", stream_meta_type_someip());
brake::stream_meta_type_someip stream_meta_type_someip
Definition of Stream Meta Type for SOME/IP.

Decoding SOME/IP Samples

For convenient access to the sample header as well as the contained messages you may use the adtf::devicetb::sdk::someip::ISomeIpDecoder interface. An instance of adtf::devicetb::sdk::someip::ISomeIpDecoder for a given sample can be obtained from the adtf::devicetb::sdk::someip::ISomeIpSupport Service.

// Obtain an instance of the SOME/IP Support Service.
object_ptr<ISomeIpSupport> pSomeIpSupport;
RETURN_IF_FAILED(_runtime->GetObject(pSomeIpSupport));
// ...
// Then given a SOME/IP sample pSample, obtain a decoder.
object_ptr<ISomeIpDecoder> pDecoder;
RETURN_IF_FAILED(pSomeIpSupport->CreateDecoder(pDecoder, pSample));
for (tSize i = 0; i < pDecoder->GetMessageCount())
{
tUInt32 nMessagId = 0;
RETURN_IF_FAILED(pDecoder->GetMessageId(nMessageId, i));
// ...
}

adtf::devicetb::sdk::someip::ISomeIpDecoder provides direct access to the messages' header fields as well as their raw payload. The message payload itself is dynamic by nature and decoding requires information about its structure. This information is provided to ADTF by a database parser library (e.g. for ARXML or FIBEX) and may not always be present. adtf::devicetb::sdk::someip::ISomeIpDecoder can provide a Media Description (DDL) of the message payload, if a parser library and database file have been registered with the adtf::devicetb::sdk::someip::ISomeIpSupport Service.

// Obtain the DDL description for the message payload.
const tChar* strPayloadDesc = nullptr;
RETURN_IF_FAILED(pDecoder->GetPayloadDescription(strPayloadDesc, nMessageIndex));
// Obtain a pointer to the message payload and its size.
const tUInt8* pMessagePayload = nullptr;
tSize nPayloadSize = 0;
RETURN_IF_FAILED(pDecoder->GetPayload(pMessagePayload, nPayloadSize, nMessageIndex));
// Create a DDL decoder instance given the payload data and the DDL string.
ddl::cCodecFactory oFactory("tPayload", strPayloadDesc);
ddl::cStaticDecoder oDecoder = oFactory.MakeStaticDecoderFor(pMessagePayload, nPayloadSize, ddl::tDataRepresentation::Serialized);
tSize nElementCount = oDecoder.GetElementCount();
// Use the DDL decoder to access the names and values of the payload elements.
for (tSize i = 0; i < nElementCount; ++i)
{
const ddl::tStructElement* pElement = nullptr;
oDecoder.GetElement(i, pElement);
adtf::util::cVariant oVar;
oDecoder.GetElementValue(i, oVar);
LOG_INFO("Name: %s -- Value: %s", pElement->strName, oVar.AsString().GetPtr());
}

Crafting SOME/IP Samples

The Device Toolbox does not currently provide the same convenience functions for writing SOME/IP samples as it does for reading. However, it is possible to manually craft samples and containing pre-existing messages.

// Obtain the actual SOME/IP message from somewhere.
std::vector<uUInt8> vecMessageData = ObtainMessageFromSomewhere();
// Create and fill in the sample header.
tSomeIpSampleHeader oSampleHeader;
oSampleHeader.nVLANId = 1;
oSampleHeader.bIsIpv6 = true;
oSampleHeader.nMessageCount = 1;
oSampleHeader.nMessageDataSize = vecMessageData.size();
// ...
// Create a writable SOME/IP samples.
object_ptr<ISample> pSomeIpSample;
RETURN_IF_FAILED(alloc_sample(pSomeIpSample, tmTimestamp));
object_ptr_locked<adtf::streaming::ant::ISampleBuffer> pBuffer;
tSize nSampleSize = sizeof(tSomeIpSampleHeader) + vecMessageData.size();
RETURN_IF_FAILED(pEthernetSample->WriteLock(pBuffer, nSampleSize));
// Write the sample header and message to the sample buffer.
std::memcpy(pBuffer->GetPtr(), &oSampleHeader, sizeof(oSampleHeader));
std::memcpy(pBuffer->GetPtr() + sizeof(oSampleHeader), vecMessageData.data(), vecMessageData.size());
hood::tSomeIpSampleHeader tSomeIpSampleHeader
This struct describes the SOME/IP sample header which is placed in the beginning of every SOME/IP sam...
Definition: someip_types.h:663