#include "demo_flexray_decoder.h"
#include <cstring>
#include <string>
#include <map>
ADTF_PLUGIN_VERSION("Demo FlexRay Decoder",
devicetb,
DEVICETB_VERSION_MAJOR,
DEVICETB_VERSION_MINOR,
DEVICETB_VERSION_PATCH,
cFlexRay2DDLFilter)
cFlexRay2DDLFilter::cFlexRay2DDLFilter()
{
SetDescription("input_flexray", "The FlexRay sample stream to decode.");
m_pWriter = CreateOutputPin("output_ddl", mediadescription::description<output_ddl>());
SetDescription("output_ddl", "The decoded content of the CAN sample stream.");
m_nChannelID.SetDescription("Channel-ID for the desired FlexRay database, made available by FlexRay service");
m_nChannelID.SetValidRange(FLEXRAY_DEVICECHANNEL_MIN, FLEXRAY_DEVICECHANNEL_MAX);
RegisterPropertyVariable("ChannelID", m_nChannelID);
SetDescription("Demo filter for decoding FlexRay samples into previous specified signals.");
SetHelpLink("$(ADTF_DEVICE_TOOLBOX_DIR)/doc/adtf_device_toolbox_html/page_example_source_flexray_config_decoder.html");
}
tResult cFlexRay2DDLFilter::Init(filter::cFilter::tInitStage eStage)
{
if (filter::cFilter::tInitStage::StageNormal == eStage)
{
RETURN_IF_FAILED(_runtime->GetObject(m_pFlexRaySupport));
RETURN_IF_FAILED(m_pFlexRaySupport->GetDatabase(
static_cast<tDeviceChannel>(m_nChannelID), m_pFlexRayDatabase));
RETURN_IF_FAILED(m_pFlexRaySupport->CreateCoder(m_pFlexRayDatabase, m_pFlexRayCoder));
}
RETURN_NOERROR;
}
tResult cFlexRay2DDLFilter::ProcessInput(streaming::ISampleReader* ,
const ucom::iobject_ptr<const streaming::ISample>& pSample)
{
ucom::object_ptr_shared_locked<const streaming::ISampleBuffer> pSampleBuffer;
RETURN_IF_FAILED(pSample->Lock(pSampleBuffer));
streaming::output_sample_data<output_ddl> oDDLOutput(pSample->GetTime());
RETURN_IF_FAILED(m_pFlexRayCoder->ReceiveData(pSampleBuffer->GetPtr(), static_cast<tInt>(pSampleBuffer->GetSize()), pSample->GetTime()));
tTimeStamp tmTimeStamp = 0;
while (IS_OK(m_pFlexRayCoder->EnumPDUs(&nPDUID, &nChannel, &nECUID, &tmTimeStamp, tTrue)))
{
RETURN_IF_FAILED(m_pFlexRayDatabase->GetPDUInfo(nPDUID, &pPduInfo));
for (tUInt32 nSigIdx = 0; nSigIdx < pPduInfo->nSignalCount; nSigIdx++)
{
tSignalID nSignalID = pPduInfo->aSignalID[nSigIdx];
const tChar* pstrSignalName = nullptr;
RETURN_IF_FAILED(m_pFlexRayDatabase->GetSignalName(nSignalID, &pstrSignalName));
RETURN_IF_FAILED(m_pFlexRayCoder->GetSignalValue(nSignalID, &oSignalValue));
switch (nSignalID)
{
case 2: oDDLOutput->Signal_3 = static_cast<tInt8>(oSignalValue.nf64Value); break;
case 3: oDDLOutput->Signal_4 = static_cast<tInt8>(oSignalValue.nf64Value); break;
case 4: oDDLOutput->Signal_5 = static_cast<tInt8>(oSignalValue.nf64Value); break;
default: break;
}
}
}
m_pFlexRayCoder->ResetModifiedFlag();
m_pWriter->Write(oDDLOutput.Release());
RETURN_NOERROR;
}
@ ENUM_PDU_START
Used in the EnumPDUs() method as start value.
Copyright 2024 CARIAD SE.
Namespace for FlexRay in ADTF-Devicetoolbox.
axle::tChannelID tChannelID
FlexRay Cluster and Channel ID (FLEXRAY_CHANNEL_A, FLEXRAY_CHANNEL_B, FLEXRAY_CHANNEL_AB).
axle::tDeviceChannel tDeviceChannel
axle::tPDUID tPDUID
FlexRay PDU (Protocol Data Unit) ID.
axle::tSignalValue tSignalValue
Signal value structure.
axle::tSignalID tSignalID
FlexRay signal ID.
axle::stream_meta_type_flexray stream_meta_type_flexray
Definition of Stream Meta Type FlexRay Messages.
axle::tECUID tECUID
FlexRay ECU (Electronic Communication Unit) ID.
axle::tPDUInfo tPDUInfo
Structure with information about one PDU (may be a complete frame or part of a frame)