This project demonstrates the use of CAN Transmit and Receive Driver Transforms. The CAN bus is defined entirely in MxTransIt; MxVDev Network Configuration is not used.
Click here to download the project: https://github.com/DanlawMxTeam/Samples/raw/master/CANTxRxSample.rar
Applies to: •MxSuite 3.36 or later Other Requirements: •A supported version of Visual Studio is required. •The user should have an understanding of MxSuite Scenarios, TestCases, and Transforms. |
This sample includes examples of the following features: •A CAN Transmit Driver Transform •A CAN Receive Driver Transform •A DBC file, CANnode.dbc, in the project folder •A Virtual Bus Transform •A SIL Easy Transform
![]() CAN Tx Rx Sample Harness Two message-based Signals, MsgHazard·Value1 and MsgHazard·Value2, are transmitted from the TestCase to the CAN Transmit Driver. The Transmit Driver puts the message onto the CAN_A bus. The SIL Easy Transform adds the two values and puts the sum into VehSpeedRPM·EngineRPM. The CAN Receive Driver reads the message from the bus and separates the fields into Signals so the VehSpeedRPM·EngineRPM can be viewed in the TestCase. The Harness also includes a Virtual Bus Transform, which enables you to view the traffic on the CAN bus with the Virtual Bus Monitor. |
You may need to use the MSVS conversion wizard and convert the solution to run the sample. See Retargeting a Visual Studio solution. The SilTick method is called periodically as specified in the SIL Easy Transform's Tick Period property. (Every 0.001 seconds in this example.) It formats the output buffer as shown below. This buffer becomes the VehSpeedRPM message. Byte 9 of the message is calculated by adding bytes 7 and 9 of the input buffer. void SilTick(void) {
bufferOut[0] = 0x12; // vehSpeedRPM Arb id bufferOut[1] = 0x04; // vehSpeedRPM Arb id
bufferOut[5] = 8; // DLC
bufferOut[8] = 0; bufferOut[9] = bufferIn[7] + bufferIn[9]; // vehSpeedRPM.EngineRPM
}
|
To run Test Scenario1, click the run button ( MsgHazard·Value1 and MsgHazard·Value2 are numeric stimulus Signals transmitted to the CAN Transmit Driver. The SIL Easy Transform reads these values from the CAN bus and adds them together. The VehSpeedRPM·EngineRPM numeric Signal is the sum of the input Signals. It is extracted from the bus by the CAN Receive Driver and read from its ports. The CAN_A message Signal shows messages received by the CAN Receive Driver. Because VehSpeedRPM·EngineRPM is a spontaneous message, it is only transmitted when there is a transition. Because the CAN Receive Driver reads messages from the OtherECUs node only, the CAN_A·ArbId Signal always has a value of 0x412. To view bus traffic in the Virtual Bus Monitor, select View->Virtual Bus Monitor->Virtual Bus from the MxVDev main menu.
|