CAN cmd 6, Read message

CAN cmd 6, Read message

Function = 6:

Syntax:

CAN(channel, 6, message, variable)

Description:

Read in the message from the specified buffer to a VR array.

The first VR holds the identifier. The subsequent values hold the data bytes from the CAN packet.

Parameters:

message:

the message buffer to read in

variable:

the start position in the VR memory for the message to be written


The first VR holds the CAN message Identifier (ie the COB ID) so is the same as the identifier that was wet up with CAN function 5.  If you initialise the CAN buffer with a data size,then that is the number of subsequent VRs that will be populated.

For example this has size 8 so it will populate 8 VRS even if the transmitted CAN message has fewer than 8 bytes.

CAN(-1,5,1,110,8,0) 'receive buffer

IF CAN(-1,3,1)=TRUE THEN
    CAN(-1,6,1,200) ' identifier (110) + 8 bytes
ENDIF

This one is set to 2 bytes so fills only 2 VRs but if the other end sends more than 2 bytes, the rest will be lost.

CAN(-1,5,2,120,2,0) 'receive buffer

IF CAN(-1,3,2)=TRUE THEN
    CAN(-1,6,2,210) ' identifier (120) + 2 bytes
ENDIF