Here is an example of using the CAN Receive Driver and SIL Easy Transforms with a CAN bus.

Suppose you have a CAN signal that is a 4-bit rolling counter. You want to verify that the count is in sequence. The test passes if the count is in sequence.  The test fails if any count is missing or out-of-sequence. The counter can start from any number from 0 to 15.

You can do this in MxTransit with a couple of transforms:

SIL Easy - Use this to monitor the sequence signal and determine if a count is missed.

CAN Receive Driver – Use this to monitor the bus and feed the appropriate sequence signal to the SIL Easy Transform.

SIL Easy

In SIL Easy, define one Discrete Input Signal called SequenceCnt and one True/False Output signal called SequenceFail. See Using SIL Easy. Add code similar to the following to main.c:

int NextSeqCnt = -1;

int SequenceFail;

int SequenceCnt;

void SilInitialize(void)

{

SequenceFail = 0;

}

/* called periodically */

void SilTick(void)

{

if (NextSeqCnt == -1)

NextSeqCnt = SequenceCnt;

else

NextSeqCnt = (NextSeqCnt + 1)%4;

if (SequenceCnt != NextSeqCnt)

SequenceFail = 1;

}

In SilHarness.cpp you need:

gSil.AddDiscrete(&SequenceCnt, L" SequenceCnt ", DataFlowEnum::Input, 0, 15, -1);

gSil.AddDiscrete(&SequenceFail, L" SequenceFail ", DataFlowEnum::Output, 0, 1, 0);

Once you have successfully built the transform, SequenceCnt is an input port and SequenceFail is an output port.

Export the SequenceFail port. This signal is used to report the result to your TestCase in MxVDev.

CAN Receive Driver Transform

The CAN Receive Driver Transform enables you to extract a particular signal or message from the data stream on a particular CAN bus. Once you have added the Transform to your harness:

1.Select the CAN Receive Driver Transform, and in its properties select the CAN Database.

2.On the CAN Bus Configuration form, in the Receive From column, select the node from which the message/signal will be received. Click OK. The signal and messages become available as outports on the Transform.

Click to expand.

Click to expand.

3.Use the Transform's Name property to rename the input and output CAN Network ports to the exact name of the appropriate CAN bus.

TestingCAN_Name

4.Locate the port for sequence counter and connect it to the input of the SIL Easy transform described above.

TestingCAN_Connect

 

Related Topics:

Using SIL Easy

CAN Receive Driver

Bus Overview