xPC Target | ![]() ![]() |
The FIFO Read driver block is used to read CAN messages out of the receive FIFO. The firmware running in FIFO mode puts received events (CAN messages) into the receive FIFO from where the FIFO Read driver reads it out.
The FIFO Read driver block has at least one output port of type double. The signal of this port is a matrix of size m*6, where m is the FIFO Read depth defined in the block dialog box (see below). For example, if the FIFO read depth is 5, then the matrix signal of port 1 has size 5*6. Therefore, one row for each event is read out of the receive FIFO (no new message is considered as an event as well). For information on how to extract data from the matrix signal, see See "Examples.
Each row with its 6 elements containing all the information defining a CAN message. These are
Port -- The value will be either 1 (port 1) or 2 (port 2) and reports at which port the CAN message was received.
Identifier -- This is the identifier of the CAN message being received. If it is a Standard CAN message the range is 0 to 2047, if is an extended CAN message, the range is 0 to 229-1.
Event type -- This value defines the type of event read out of the receive FIFO. The following values are defined from the Softing user manual.
0 No new event
1 Standard data frame received
2 Standard remote frame received
3 Transmission of a standard data frame is confirmed
4 -
5 Change of bus state
6 -
7 -
8 Transmission of a standard remote frame is confirmed
9 Extended data frame received
10 Transmission of an extended data frame is confirmed
11 Transmission of an extended remote frame is confirmed
12 Extended remote frame received
13 -
14 -
15 Error frame detected
Data frame size -- If a data frame has been received, the length of the data in bytes is reported by this element. Possible values are 0 to 8.
Timestamp -- This element reports the time at which the event was received. The resolution of the timestamp counter is 1us.
Data -- This is the data of the data frame itself and is returned as a double value (8 bytes). The CAN unpacking block is used to extract the data out of the double value.
The dialog box of the block lets you define the following settings.
Board -- Defines which physically present board is used to send out the CAN messages defined by this block instance. For more information about the meaning of the board number see the Setup driver block described above. If one board is present in the target system, select board number 1.
FIFO read depth -- Defines the number of receive FIFO read attempts. Each time the block gets executed it reads this fixed amount of events (CAN messages) which lead to a deterministic time behavior independent of the number of events currently stored in the receive FIFO. The Read depth (m) defines at the same time the size of the matrix signal (m*6) leaving the first output port. If no event is currently stored in the receive FIFO, the FIFO will be read anyway, but the Event type will be reported as 0 (No new event).
Show status output port -- Check this box to enable the Status output port. If the box is unchecked (disabled) the block has one output port for the events. If enabled, a second port is shown. The signal leaving that port is a vector of type double with two elements.
The first element returns the current value of the lost messages counter. The receive FIFO can store up to 255 events. If the receive FIFO is not regularly accessed for reading events, the FIFO gets filled and the lost messages counter starts to count up. This is an indicator that events (messages) will be unavoidably lost. The second element returns the current bus state. Possible values are:
Sample time -- The fourth control (edit field) defines the sample time at which the FIFO Read block is executed during a model (target application) run.
It is strongly recommended that you only use one instance of this block per physical CAN board in your model. Otherwise you may get the unwanted behavior that one instance would read events while they have to be processed by blocks connected to the other, second instance.
![]() | FIFO Write Driver Block | FIFO Read Filter Block | ![]() |