I cannot find a comprehensive guide on how to build a Synthetic LIN Slave in a CANoe configuration, so I would like to create one here.
Scenario: an ECU acts as LIN master and communicates with n LIN slaves. The goal is to be able to add a synthetic slave to the CANoe simulation acting as a replacer for one of the physical slaves. Since there is no way to dynamically activate or de-activate a LIN node, our setup would be of n-1 physical slaves and 1 synthetic slave, plus the Master. Here, Master is under test, and, in particular, we want to assess its ability to react to certain slave responses, by mocking the slave and triggering whatever frame is needed. Let's assume there will be a GUI or something for that, it is not in scope for the question.
I am able to add a new Node to the simulation setup, assign it to the LIN network and, if active, it connects to the red line indicating the simulated bus. An LDF was created and added to the configuration and I know the linFrame ID the node should communicate.
The node is to be simulated via CAPL script. I am stuck on the transmission part:
on ???
{
// This is my call: as LIN slave I should output something.
output(myLinFrame);
}
Where should I add my logic to update and transmit the message?
The basic I tried was to key-bind it, but the output would be on the next associated slot of the LDF, plus it's key-bound.
on key 'A'
{
// prepare new content...
output(myLinFrame);
}
This question relates to an older question of mine regarding LIN censorship.
Final note: I have very limited slots for CANoe licenses to test whatever code I come up with, so I need to prepare and research in advance.
In this scenario, should I use linUpdateResponse()
?
You should create on linFrame ...
event handlers.
These event handlers will be called, once a frame has been put to the bus.
Inside the event handler, you can use linUpdateResponse
(or also output
) to modify the frame which will be sent the next time, i.e. the call modifies does not send an immediate response but rather modifies the internal state of the slave so that a different frame is sent next time.