Skip to content

LIN Node Simulation Examples

Master Request Transmission:

To send the Master request ( or Header), the header ID should be configured in Node simulation Pre Connect Event.

Example code:

The following example shows how to send the master request with an identifier 0x4, for every 10ms.

void OnBus_Pre_Connect() { STLIN_MSG sMsg; sMsg.messagetype = 0; // Master Response sMsg.checksumtype = 0; // Classic sMsg.id = 0x4; // Message Identifier sMsg.cluster = 1; // channel 1 // Register the header frame. SendMsg(sMsg); } //Called For Every 10ms. void OnTimer_TimerFor10ms_10() { STLIN_MSG sMsg; sMsg.messagetype = 0; // Master Response sMsg.checksumtype = 0; // Classic sMsg.id = 0x4; // Message Identifier sMsg.cluster = 1; // Send the header frame SendMsg(sMsg); }

Responding to Master Request

To respond to the master request, slave response of the particular identifier needs to be configured in Node simulation Pre Connect Event. Once the configuration is done, The data can be changed in any other Node simulation handlers.

Example code:

For example to respond to the master request with an identifier 0x4, Pre-Connect event shall be configured as shown below:

void OnBus_Pre_Connect()
{
STLIN_MSG sMsg;
sMsg.messagetype = 1; // Slave Response
sMsg.checksumtype = 0; // Classic
sMsg.dlc = 8;
sMsg.id = 0x4; // Message Identifier
sMsg.data[0] = 10; // Lower 4 Bytes
sMsg.data[1] = 20; // Upper 4 Bytes
sMsg.cluster = 1;
// Register Slave response
SendMsg(sMsg);
}
//changing data in key handlers.
void OnKey_A()
{
STLIN_MSG sMsg;
sMsg.messagetype = 1; // Slave Response
sMsg.checksumtype = 0; // Classic
sMsg.dlc = 8;
sMsg.id = 0x4; // Message Identifier
sMsg.data[0] = 20; // Lower 4 Bytes
sMsg.data[1] = 30; // Upper 4 Bytes
sMsg.cluster = 1;
// Send the message
SendMsg(sMsg);
}

Authoritative source: BUSMASTER DITA help source LIN_Node_Simulation_Examples.dita, compiled into BUSMASTER.CHM with the application.