MATLAB: How to directly connect the FIFO Read block with the CAN Message Unpacking block in xPC Target 4.1 (R2009a)

candbcandbcconnectfiforeadSimulink Real-Time

I am using xPC Target 4.1 (R2009a) with CANdb blocks. In my models, I can connect the CANdb Message Packing block directly to the FIFO Write block which allows me take advantage of *.dbc files.
This does not work with the FIFO Read block. I am not able to directly connect the FIFO Read block to the CANdb Message unpacking block.

Best Answer

This functionality has been implemented in xPC Target 4.2 (R2009b).
For earlier releases please read below.
The ability to directly connect the FIFO Read block to the CANdb Message unpacking block is not available in xPC Target.
To work around this issue you can do the following:
In versions prior to R2009b, the output of the FIFO read filter block is an array of doubles that needs to be transformed before being fed to the CANdb unpack block. You need the 'FIFO Mode CAN Message' block from xpclib that takes a 'FIFO MODE RECEIVE' input and outputs 'CAN_MESSAGE'. Therefore you need to disable and then break the link from that block so you can modify the CAN Message Packing block inside it. You need to insert the ID that you filtered on. The attached model 'CANdb_unpack_Example.mdl' illustrates this method.
If you need to process every incoming message, then you may need to set the FIFO read depth to 1 in the FIFO read block. Then make sure you run the model often enough to keep the FIFO from overflowing. That may require the read portion to run more often than the write portion as a multi-rate model. If you don't limit the read depth, then the filter may only return the latest copy of the matching message.