Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions SilKit/include/silkit/capi/Flexray.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,6 @@ struct SilKit_FlexrayNodeParameters
//! Maximum permissible rate correction value (range 3-3846 MicroTicks).
SilKit_FlexrayMicroTick pRateCorrectionOut;

////! Not used by network simulator
// pSecondKeySlotID

////! Not used by network simulator
// pTwoKeySlotMode

//! Channel used by the node to send a wakeup pattern (values FlexrayChannel::A, FlexrayChannel::B).
SilKit_FlexrayChannel pWakeupChannel;

Expand All @@ -242,6 +236,15 @@ struct SilKit_FlexrayNodeParameters

//! Number of samples per MicroTick (values 1 or 2).
uint8_t pSamplesPerMicrotick;

// ----------------------------------------------------------------------
// Parameters according to B.3.2.1 (added in SIL Kit 5.0.3)

//! Second Key Slot ID of the key slot (range 0-1023, value 0 means that there is no key slot).
uint16_t pSecondKeySlotId;

//! Second Key slot is used for startup with a single cold start node (range 0, 1).
uint8_t pTwoKeySlotMode;
};
typedef struct SilKit_FlexrayNodeParameters SilKit_FlexrayNodeParameters;

Expand Down
2 changes: 1 addition & 1 deletion SilKit/include/silkit/capi/InterfaceIdentifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ typedef struct
#define SilKit_FlexrayWakeupEvent_VERSION 1
#define SilKit_FlexrayControllerConfig_VERSION 1
#define SilKit_FlexrayClusterParameters_VERSION 1
#define SilKit_FlexrayNodeParameters_VERSION 1
#define SilKit_FlexrayNodeParameters_VERSION 2
#define SilKit_FlexrayHostCommand_VERSION 1
#define SilKit_FlexrayHeader_VERSION 1
#define SilKit_FlexrayFrame_VERSION 1
Expand Down
4 changes: 4 additions & 0 deletions SilKit/include/silkit/detail/impl/HourglassConversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ inline void assignCxxToC(const SilKit::Services::Flexray::FlexrayNodeParameters&
cOut.pWakeupPattern = cxxIn.pWakeupPattern;
cOut.pdMicrotick = static_cast<SilKit_FlexrayClockPeriod>(cxxIn.pdMicrotick);
cOut.pSamplesPerMicrotick = cxxIn.pSamplesPerMicrotick;
cOut.pTwoKeySlotMode = cxxIn.pTwoKeySlotMode;
cOut.pSecondKeySlotId = cxxIn.pSecondKeySlotId;
}

inline void assignCxxToC(const SilKit::Services::Flexray::FlexrayTxBufferConfig& cxxIn,
Expand Down Expand Up @@ -651,6 +653,8 @@ inline void assignCToCxx(const SilKit_FlexrayNodeParameters* cIn,
cxxOut.pWakeupPattern = cIn->pWakeupPattern;
cxxOut.pdMicrotick = (SilKit::Services::Flexray::FlexrayClockPeriod)cIn->pdMicrotick;
cxxOut.pSamplesPerMicrotick = cIn->pSamplesPerMicrotick;
cxxOut.pTwoKeySlotMode = cIn->pTwoKeySlotMode;
cxxOut.pSecondKeySlotId = cIn->pSecondKeySlotId;
}

// -----------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,8 @@ void CxxToC(const SilKit::Services::Flexray::FlexrayNodeParameters& cxxFlexrayNo
cFlexrayNodeParameters.pWakeupPattern = cxxFlexrayNodeParameters.pWakeupPattern;
cFlexrayNodeParameters.pdMicrotick = static_cast<SilKit_FlexrayClockPeriod>(cxxFlexrayNodeParameters.pdMicrotick);
cFlexrayNodeParameters.pSamplesPerMicrotick = cxxFlexrayNodeParameters.pSamplesPerMicrotick;
cFlexrayNodeParameters.pTwoKeySlotMode = cxxFlexrayNodeParameters.pTwoKeySlotMode;
cFlexrayNodeParameters.pSecondKeySlotId = cxxFlexrayNodeParameters.pSecondKeySlotId;
}

void CxxToC(const SilKit::Services::Flexray::FlexrayTxBufferConfig& cxxFlexrayTxBufferConfig,
Expand Down
20 changes: 12 additions & 8 deletions SilKit/include/silkit/services/flexray/FlexrayDatatypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,6 @@ struct FlexrayNodeParameters

//! Maximum permissible rate correction value (range 3-3846 MicroTicks).
FlexrayMicroTick pRateCorrectionOut;

////! Not used by network simulator
//pSecondKeySlotID

////! Not used by network simulator
//pTwoKeySlotMode

//! Channel used by the node to send a wakeup pattern (values FlexrayChannel::A, FlexrayChannel::B).
FlexrayChannel pWakeupChannel;

Expand All @@ -238,6 +231,15 @@ struct FlexrayNodeParameters

//! Number of samples per MicroTick (values 1 or 2).
uint8_t pSamplesPerMicrotick;

// ----------------------------------------------------------------------
// Parameters according to B.3.2.1 (added in SIL Kit 5.0.3)

//! Second Key Slot ID of the key slot (range 0-1023, value 0 means that there is no key slot).
uint16_t pSecondKeySlotId;

//! Second Key slot is used for startup with a single cold start node (range 0, 1).
uint8_t pTwoKeySlotMode;
};

//! Transmission mode for FlexRay Tx-Buffer
Expand Down Expand Up @@ -537,7 +539,9 @@ inline bool operator==(const FlexrayNodeParameters& lhs, const FlexrayNodeParame
&& lhs.pOffsetCorrectionStart == rhs.pOffsetCorrectionStart
&& lhs.pRateCorrectionOut == rhs.pRateCorrectionOut && lhs.pWakeupChannel == rhs.pWakeupChannel
&& lhs.pWakeupPattern == rhs.pWakeupPattern && lhs.pdMicrotick == rhs.pdMicrotick
&& lhs.pSamplesPerMicrotick == rhs.pSamplesPerMicrotick;
&& lhs.pSamplesPerMicrotick == rhs.pSamplesPerMicrotick && lhs.pSecondKeySlotId == rhs.pSecondKeySlotId
&& lhs.pTwoKeySlotMode == rhs.pTwoKeySlotMode
;
}

inline bool operator==(const FlexrayTxBufferConfig& lhs, const FlexrayTxBufferConfig& rhs)
Expand Down
57 changes: 34 additions & 23 deletions SilKit/source/capi/CapiFlexray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,40 @@ void assign(SilKit::Services::Flexray::FlexrayClusterParameters& cppClusterParam
void assign(SilKit::Services::Flexray::FlexrayNodeParameters& cppNodeParameters,
const SilKit_FlexrayNodeParameters* nodeParameters)
{
cppNodeParameters.pAllowHaltDueToClock = nodeParameters->pAllowHaltDueToClock;
cppNodeParameters.pAllowPassiveToActive = nodeParameters->pAllowPassiveToActive;
cppNodeParameters.pChannels = (SilKit::Services::Flexray::FlexrayChannel)nodeParameters->pChannels;
cppNodeParameters.pClusterDriftDamping = nodeParameters->pClusterDriftDamping;
cppNodeParameters.pdAcceptedStartupRange = nodeParameters->pdAcceptedStartupRange;
cppNodeParameters.pdListenTimeout = nodeParameters->pdListenTimeout;
cppNodeParameters.pKeySlotId = nodeParameters->pKeySlotId;
cppNodeParameters.pKeySlotOnlyEnabled = nodeParameters->pKeySlotOnlyEnabled;
cppNodeParameters.pKeySlotUsedForStartup = nodeParameters->pKeySlotUsedForStartup;
cppNodeParameters.pKeySlotUsedForSync = nodeParameters->pKeySlotUsedForSync;
cppNodeParameters.pLatestTx = nodeParameters->pLatestTx;
cppNodeParameters.pMacroInitialOffsetA = nodeParameters->pMacroInitialOffsetA;
cppNodeParameters.pMacroInitialOffsetB = nodeParameters->pMacroInitialOffsetB;
cppNodeParameters.pMicroInitialOffsetA = nodeParameters->pMicroInitialOffsetA;
cppNodeParameters.pMicroInitialOffsetB = nodeParameters->pMicroInitialOffsetB;
cppNodeParameters.pMicroPerCycle = nodeParameters->pMicroPerCycle;
cppNodeParameters.pOffsetCorrectionOut = nodeParameters->pOffsetCorrectionOut;
cppNodeParameters.pOffsetCorrectionStart = nodeParameters->pOffsetCorrectionStart;
cppNodeParameters.pRateCorrectionOut = nodeParameters->pRateCorrectionOut;
cppNodeParameters.pWakeupChannel = (SilKit::Services::Flexray::FlexrayChannel)nodeParameters->pWakeupChannel;
cppNodeParameters.pWakeupPattern = nodeParameters->pWakeupPattern;
cppNodeParameters.pdMicrotick = (SilKit::Services::Flexray::FlexrayClockPeriod)nodeParameters->pdMicrotick;
cppNodeParameters.pSamplesPerMicrotick = nodeParameters->pSamplesPerMicrotick;
const auto inputVersion = SK_ID_GET_VERSION(SilKit_Struct_GetId(*nodeParameters));

if (inputVersion == 1 || inputVersion == 2)
{
cppNodeParameters.pAllowHaltDueToClock = nodeParameters->pAllowHaltDueToClock;
cppNodeParameters.pAllowPassiveToActive = nodeParameters->pAllowPassiveToActive;
cppNodeParameters.pChannels = (SilKit::Services::Flexray::FlexrayChannel)nodeParameters->pChannels;
cppNodeParameters.pClusterDriftDamping = nodeParameters->pClusterDriftDamping;
cppNodeParameters.pdAcceptedStartupRange = nodeParameters->pdAcceptedStartupRange;
cppNodeParameters.pdListenTimeout = nodeParameters->pdListenTimeout;
cppNodeParameters.pKeySlotId = nodeParameters->pKeySlotId;
cppNodeParameters.pKeySlotOnlyEnabled = nodeParameters->pKeySlotOnlyEnabled;
cppNodeParameters.pKeySlotUsedForStartup = nodeParameters->pKeySlotUsedForStartup;
cppNodeParameters.pKeySlotUsedForSync = nodeParameters->pKeySlotUsedForSync;
cppNodeParameters.pLatestTx = nodeParameters->pLatestTx;
cppNodeParameters.pMacroInitialOffsetA = nodeParameters->pMacroInitialOffsetA;
cppNodeParameters.pMacroInitialOffsetB = nodeParameters->pMacroInitialOffsetB;
cppNodeParameters.pMicroInitialOffsetA = nodeParameters->pMicroInitialOffsetA;
cppNodeParameters.pMicroInitialOffsetB = nodeParameters->pMicroInitialOffsetB;
cppNodeParameters.pMicroPerCycle = nodeParameters->pMicroPerCycle;
cppNodeParameters.pOffsetCorrectionOut = nodeParameters->pOffsetCorrectionOut;
cppNodeParameters.pOffsetCorrectionStart = nodeParameters->pOffsetCorrectionStart;
cppNodeParameters.pRateCorrectionOut = nodeParameters->pRateCorrectionOut;
cppNodeParameters.pWakeupChannel = (SilKit::Services::Flexray::FlexrayChannel)nodeParameters->pWakeupChannel;
cppNodeParameters.pWakeupPattern = nodeParameters->pWakeupPattern;
cppNodeParameters.pdMicrotick = (SilKit::Services::Flexray::FlexrayClockPeriod)nodeParameters->pdMicrotick;
cppNodeParameters.pSamplesPerMicrotick = nodeParameters->pSamplesPerMicrotick;
}

if (inputVersion == 2)
{
cppNodeParameters.pTwoKeySlotMode = nodeParameters->pTwoKeySlotMode;
cppNodeParameters.pSecondKeySlotId = nodeParameters->pSecondKeySlotId;
}
}

void assign(SilKit::Services::Flexray::FlexrayControllerConfig& cppConfig, const SilKit_FlexrayControllerConfig* config)
Expand Down
7 changes: 6 additions & 1 deletion SilKit/source/services/flexray/FlexraySerdes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ inline SilKit::Core::MessageBuffer& operator<<(SilKit::Core::MessageBuffer& buff
<< nodeParams.pMacroInitialOffsetB << nodeParams.pMicroInitialOffsetA << nodeParams.pMicroInitialOffsetB
<< nodeParams.pMicroPerCycle << nodeParams.pOffsetCorrectionOut << nodeParams.pOffsetCorrectionStart
<< nodeParams.pRateCorrectionOut << nodeParams.pWakeupChannel << nodeParams.pWakeupPattern
<< nodeParams.pdMicrotick << nodeParams.pSamplesPerMicrotick;
<< nodeParams.pdMicrotick << nodeParams.pSamplesPerMicrotick << nodeParams.pSecondKeySlotId
<< nodeParams.pTwoKeySlotMode;
return buffer;
}

Expand All @@ -163,6 +164,10 @@ inline SilKit::Core::MessageBuffer& operator>>(SilKit::Core::MessageBuffer& buff
>> nodeParams.pMicroPerCycle >> nodeParams.pOffsetCorrectionOut >> nodeParams.pOffsetCorrectionStart
>> nodeParams.pRateCorrectionOut >> nodeParams.pWakeupChannel >> nodeParams.pWakeupPattern
>> nodeParams.pdMicrotick >> nodeParams.pSamplesPerMicrotick;
if (buffer.RemainingBytesLeft() > 0)
{
buffer >> nodeParams.pSecondKeySlotId >> nodeParams.pTwoKeySlotMode;
}
return buffer;
}

Expand Down
6 changes: 3 additions & 3 deletions SilKit/source/services/flexray/Test_FlexrayController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ auto GetDummyConfig() -> SilKit::Config::FlexrayController

auto MakeValidClusterParams() -> FlexrayClusterParameters
{
FlexrayClusterParameters clusterParams;
FlexrayClusterParameters clusterParams{};
clusterParams.gColdstartAttempts = 2;
clusterParams.gCycleCountMax = 7;
clusterParams.gdActionPointOffset = 1;
Expand All @@ -73,7 +73,7 @@ auto MakeValidClusterParams() -> FlexrayClusterParameters

auto MakeValidNodeParams() -> FlexrayNodeParameters
{
FlexrayNodeParameters nodeParams;
FlexrayNodeParameters nodeParams{};
nodeParams.pAllowHaltDueToClock = 0;
nodeParams.pAllowPassiveToActive = 0;
nodeParams.pChannels = FlexrayChannel::A;
Expand Down Expand Up @@ -116,7 +116,7 @@ auto MakeValidTxBufferConfig() -> FlexrayTxBufferConfig

auto GetDummyConfigWithValues() -> SilKit::Config::FlexrayController
{
SilKit::Config::FlexrayController dummyConfig;
SilKit::Config::FlexrayController dummyConfig{};
dummyConfig.network = "testNetwork";
dummyConfig.name = "testController";
dummyConfig.clusterParameters = MakeValidClusterParams();
Expand Down
Loading