CAN | CAN Interface If you have fetched the data, then set Outputs.RxCounter:=Inputs.RxCounter. The CAN interface then knows that it can fill the buffer again. All data must always be read out, because the CAN interface fills all message structures again when necessary.
Sample code for transmission if (Outputs.TxCounter = Inputs.TxCounter) // check if the interface is ready and NumberOfMessagesToSend >0 then // and messages are to send for i:=0 to NumberOfMessagesToSend-1 do // LOOP for copying the CAN message to the // interface Outputs.TxMessage[i] := MessageToSend[i]; // copy End_for Outputs.NoOfTxMessages := NumberOfMessagesToSend; // number of CAN messages you are going to send Outputs.TxCounter := Inputs.TxCounter + 1; // inc.
shows the CAN interface that new data // is available and to send this data end_if Sample code for reading if Outputs.RxCounter Inputs.RxCounter then // check if new data is in the buffer for i := 0 to (Inputs.NoOfRxMessages-1) do // start the LOOP and check how much data // is in the buffer MessageReceived[i] := Inputs.RxMessage [i]; // copy the CAN message End_for Outputs.RxCounter := Inputs.RxCounter; // set equal: the CAN interface then knows, // that you have copied the CAN data end_if Message structure when using the 11-bit identifier The message structure when using the 11-bit identifier consists of the COB ID [2 bytes] and the 8 bytes of data. The COB ID has the following structure:
Bit 0-3: Length of the data (0…8) Bit 4: RTR Bit 5-15: 11-bit identifier Message structure when using the 11-bit identifier I/O 35 Version: 2.3.0