Examples
Non database message transmission:
STCAN_MSG sMsg;
// Initialise message structuresMsg.id = 0x100; // Message IDsMsg.isExtended = false; // Standard Message typesMsg.isRtr = false; // Not RTR typesMsg.dlc = 8; // Length is 8 BytessMsg.data[0] = 10; // Byte DatasMsg.data[1] = 20;sMsg.wordAt(1, 30); // Word datasMsg.cluster = 1; // First CAN channel
// Send the messageSendMsg(sMsg);```**Database message transmission:**
// Message Declaration CAN_Request sMsgStruct; // CAN_Request is a database message // Use signal member // Sig1 sMsgStruct.Sig_1 = 10; // for setting signal raw value // Sig2 sMsgStruct.Sig_2 = 20; // Sig3 sMsgStruct.Sig_3 = 30; // Send the message now SendMsg(sMsgStruct));
**Accessing signal values:**// Message Declaration CAN_Request sMsgStruct; // Use signal member // Sig1 int sig1Value = sMsgStruct..Sig_1; // Type 'int' to be changed as per signal type // Sig2 int sig2Value = sMsgStruct.Sig_2; // Sig3 int sig3Value = sMsgStruct.Sig_3; (OR) int sig1Rawvalue = sMsgStruct.sig1.rawvalue(); (OR) double sig1PhyValue = sMsgStruct.sig1.physicalvalue();
**Updating database message signal values:**
Database message structures can be meaningfully interpreted. Database message structures will have signal members as defined in the database. Signal raw value can be directly assigned by using member of database message structure with the signal name.
CAN_Request is a database message that has signals Sig1, Sig2 and Sig3. Each signal is 2 bytes of length. To assign raw value of a signal use message name structure and use signal name as member.
```text// Message DeclarationCAN_Request sMsgStruct;
// Use signal member// Sig1sMsgStruct.Sig_1 = 10;// Sig2sMsgStruct.Sig_2 = 20;// Sig3sMsgStruct.Sig_3 = 30;
(OR)
sMsgStruct.sig1.rawvalue(10);
(OR)
sMsgStruct.sig1.physicalvalue(12.4);```**Updating message data bytes:**
STCAN_MSG sMsg; // Initialise message structure here sMsg.id = 0x100; // Message ID sMsg.isExtended = false; // Standard Message type sMsg.isRtr = false; // Not RTR type sMsg.dlc = 8; // Length is 8 Bytes sMsg.cluster = 1; // First CAN channel sMsg.data[0] = 10; // Byte Data sMsg.data[1] = 20; (OR) sMsg.byteAt(0, 10); sMsg.byteAt(1, 20); // Send the message SendMsg(sMsg);
> **Note**: Right click on edit area of function editor. Select "Insert Message" or "Insert Signal" option to insert message structure or signal structure. Select the option "Yes, I want to declare selected message structure variable" option in the "Message and Signal List" to initialise message with its struct definition. Messages and Signals of a database can be used in Node Simulation if database is associated/imported in BusMaster
---
**Authoritative source**: BUSMASTER DITA help source `CAN_Node_Simulation_Examples.dita`, compiled into `BUSMASTER.CHM` with the application.