variables
{
[...]
DWORD gFunctionalRequestId = 0;
DWORD gFunctionalRequestIdMask = 0;
long gFunctionalRequestExt = -1;
long gCANchannel = -1;
}
_Diag_SetChannelParameters()
{
[...]
// Configure functional request ids
gCANchannel = DiagGetCommParameter( "CANoe.ChannelNumber");
gFunctionalRequestId = DiagGetFunctionalGroupId();
if( gFunctionalRequestId != -1)
{
gFunctionalRequestIdMask = DiagGetFunctionalGroupIdMask();
gFunctionalRequestExt = DiagGetFunctionalGroupExt();
}
}
on message *
{
int i, dataStart, requestLength;
BYTE requestData[7];
// Check if the message received has the functional request id,
// and if extended addresses are used, if the extension matches
if( gCANchannel != this.can
|| (this.id & gFunctionalRequestIdMask) != gFunctionalRequestId
|| gFunctionalRequestExt >= 0 && this.byte(0) != gFunctionalRequestExt)
return;
// This is a functional request, so indicate the data to the diagnostic layer.
// The length of the data is found in the first byte of data
dataStart = (gFunctionalRequestExt >= 0) ? 1 : 0;
requestLength = this.byte(dataStart);
++dataStart;
writeDbgLevel(1, "%s: Functional request received, %d byte: %02x...",
gECU, requestLength, this.byte( dataStart));
for( i = 0; i < requestLength; ++i)
{
requestData[ i] = this.byte( dataStart + i);
}
Diag_DataInd( requestData, requestLength, gFunctionalRequestExt);
}