diff --git a/SilKit/include/silkit/capi/Flexray.h b/SilKit/include/silkit/capi/Flexray.h index 038cf5c27..528f5b37f 100644 --- a/SilKit/include/silkit/capi/Flexray.h +++ b/SilKit/include/silkit/capi/Flexray.h @@ -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; @@ -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; diff --git a/SilKit/include/silkit/capi/InterfaceIdentifiers.h b/SilKit/include/silkit/capi/InterfaceIdentifiers.h index 609b2870a..7490bd666 100644 --- a/SilKit/include/silkit/capi/InterfaceIdentifiers.h +++ b/SilKit/include/silkit/capi/InterfaceIdentifiers.h @@ -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 diff --git a/SilKit/include/silkit/detail/impl/HourglassConversions.hpp b/SilKit/include/silkit/detail/impl/HourglassConversions.hpp index b242e4225..a323d02e7 100644 --- a/SilKit/include/silkit/detail/impl/HourglassConversions.hpp +++ b/SilKit/include/silkit/detail/impl/HourglassConversions.hpp @@ -221,6 +221,8 @@ inline void assignCxxToC(const SilKit::Services::Flexray::FlexrayNodeParameters& cOut.pWakeupPattern = cxxIn.pWakeupPattern; cOut.pdMicrotick = static_cast(cxxIn.pdMicrotick); cOut.pSamplesPerMicrotick = cxxIn.pSamplesPerMicrotick; + cOut.pTwoKeySlotMode = cxxIn.pTwoKeySlotMode; + cOut.pSecondKeySlotId = cxxIn.pSecondKeySlotId; } inline void assignCxxToC(const SilKit::Services::Flexray::FlexrayTxBufferConfig& cxxIn, @@ -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; } // ----------------------------------- diff --git a/SilKit/include/silkit/detail/impl/services/flexray/FlexrayController.hpp b/SilKit/include/silkit/detail/impl/services/flexray/FlexrayController.hpp index 06150cd29..6234b21fa 100644 --- a/SilKit/include/silkit/detail/impl/services/flexray/FlexrayController.hpp +++ b/SilKit/include/silkit/detail/impl/services/flexray/FlexrayController.hpp @@ -567,6 +567,8 @@ void CxxToC(const SilKit::Services::Flexray::FlexrayNodeParameters& cxxFlexrayNo cFlexrayNodeParameters.pWakeupPattern = cxxFlexrayNodeParameters.pWakeupPattern; cFlexrayNodeParameters.pdMicrotick = static_cast(cxxFlexrayNodeParameters.pdMicrotick); cFlexrayNodeParameters.pSamplesPerMicrotick = cxxFlexrayNodeParameters.pSamplesPerMicrotick; + cFlexrayNodeParameters.pTwoKeySlotMode = cxxFlexrayNodeParameters.pTwoKeySlotMode; + cFlexrayNodeParameters.pSecondKeySlotId = cxxFlexrayNodeParameters.pSecondKeySlotId; } void CxxToC(const SilKit::Services::Flexray::FlexrayTxBufferConfig& cxxFlexrayTxBufferConfig, diff --git a/SilKit/include/silkit/services/flexray/FlexrayDatatypes.hpp b/SilKit/include/silkit/services/flexray/FlexrayDatatypes.hpp index 62846f3ca..e7d1c04c6 100644 --- a/SilKit/include/silkit/services/flexray/FlexrayDatatypes.hpp +++ b/SilKit/include/silkit/services/flexray/FlexrayDatatypes.hpp @@ -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; @@ -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 @@ -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) diff --git a/SilKit/source/capi/CapiFlexray.cpp b/SilKit/source/capi/CapiFlexray.cpp index 568f34df8..644706fce 100644 --- a/SilKit/source/capi/CapiFlexray.cpp +++ b/SilKit/source/capi/CapiFlexray.cpp @@ -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) diff --git a/SilKit/source/services/flexray/FlexraySerdes.cpp b/SilKit/source/services/flexray/FlexraySerdes.cpp index 5456eabdb..f7a4ea15f 100644 --- a/SilKit/source/services/flexray/FlexraySerdes.cpp +++ b/SilKit/source/services/flexray/FlexraySerdes.cpp @@ -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; } @@ -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; } diff --git a/SilKit/source/services/flexray/Test_FlexrayController.cpp b/SilKit/source/services/flexray/Test_FlexrayController.cpp index 625345c55..5c08474b9 100644 --- a/SilKit/source/services/flexray/Test_FlexrayController.cpp +++ b/SilKit/source/services/flexray/Test_FlexrayController.cpp @@ -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; @@ -73,7 +73,7 @@ auto MakeValidClusterParams() -> FlexrayClusterParameters auto MakeValidNodeParams() -> FlexrayNodeParameters { - FlexrayNodeParameters nodeParams; + FlexrayNodeParameters nodeParams{}; nodeParams.pAllowHaltDueToClock = 0; nodeParams.pAllowPassiveToActive = 0; nodeParams.pChannels = FlexrayChannel::A; @@ -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();