Skip to content

Commit 748e450

Browse files
committed
ensure that we are backward compatible on a network protocol level
Signed-off-by: Marius Börschig <Marius.Boerschig@vector.com>
1 parent 56623b0 commit 748e450

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

SilKit/source/services/flexray/FlexraySerdes.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ inline SilKit::Core::MessageBuffer& operator<<(SilKit::Core::MessageBuffer& buff
149149
<< nodeParams.pMacroInitialOffsetB << nodeParams.pMicroInitialOffsetA << nodeParams.pMicroInitialOffsetB
150150
<< nodeParams.pMicroPerCycle << nodeParams.pOffsetCorrectionOut << nodeParams.pOffsetCorrectionStart
151151
<< nodeParams.pRateCorrectionOut << nodeParams.pWakeupChannel << nodeParams.pWakeupPattern
152-
<< nodeParams.pdMicrotick << nodeParams.pSamplesPerMicrotick << nodeParams.pSecondKeySlotId
153-
<< nodeParams.pTwoKeySlotMode;
152+
<< nodeParams.pdMicrotick << nodeParams.pSamplesPerMicrotick;
154153
return buffer;
155154
}
156155

@@ -164,10 +163,6 @@ inline SilKit::Core::MessageBuffer& operator>>(SilKit::Core::MessageBuffer& buff
164163
>> nodeParams.pMicroPerCycle >> nodeParams.pOffsetCorrectionOut >> nodeParams.pOffsetCorrectionStart
165164
>> nodeParams.pRateCorrectionOut >> nodeParams.pWakeupChannel >> nodeParams.pWakeupPattern
166165
>> nodeParams.pdMicrotick >> nodeParams.pSamplesPerMicrotick;
167-
if (buffer.RemainingBytesLeft() > 0)
168-
{
169-
buffer >> nodeParams.pSecondKeySlotId >> nodeParams.pTwoKeySlotMode;
170-
}
171166
return buffer;
172167
}
173168

@@ -189,12 +184,22 @@ inline SilKit::Core::MessageBuffer& operator<<(SilKit::Core::MessageBuffer& buff
189184
const FlexrayControllerConfig& config)
190185
{
191186
buffer << config.clusterParams << config.nodeParams << config.bufferConfigs;
187+
// Support for struct FlexrayControllerConfig version 2:
188+
// ensure that the pSecondKeySlotId and pTwoKeySlotMode are also serialized after the bufferConfigs
189+
// otherwise we will confuse the buffer deserialization of the bufferConfigs
190+
buffer << config.nodeParams.pSecondKeySlotId << config.nodeParams.pTwoKeySlotMode;
192191
return buffer;
193192
}
194193

195194
inline SilKit::Core::MessageBuffer& operator>>(SilKit::Core::MessageBuffer& buffer, FlexrayControllerConfig& config)
196195
{
197196
buffer >> config.clusterParams >> config.nodeParams >> config.bufferConfigs;
197+
// Support for struct FlexrayControllerConfig version 2:
198+
// the pSecondKeySlotId and pTwoKeySlotMode were added after the bufferConfigs
199+
if (buffer.RemainingBytesLeft() > 0)
200+
{
201+
buffer >> config.nodeParams.pSecondKeySlotId >> config.nodeParams.pTwoKeySlotMode;
202+
}
198203
return buffer;
199204
}
200205

0 commit comments

Comments
 (0)