Raw CAN Receive Messages -
Intrepidcs API
Main
Overview
When neoVI receives a CAN message it assembles the message in a byte sequence. These formats are depicted in tables 1 and 2 below.
Table 1 - Standard ID (SID) Frame Format
| BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 |
BYTES 7-14 |
||||||||||||||||||||
| NETID_XX
NETID OF CAN NETWORK: NETID_HSCAN, NETID_MSCAN, NETID_SWCAN, NETID_LSFTCAN |
TIMESTAMP MSB |
TIMESTAMP LSB | STANDARD ID BITS 10:3 |
IDE = Set to 0 when this is a standard frame. EID Bit 17 and 16 = undefined for a standard ID message
|
Reserved Bits = Undefined (Mask off to determine length of data)
|
CAN Data bytes 0 - 8
Remote Frame Have No Data |
Table 2 - Extended ID (EID) Frame Format
| BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 | BYTE 8 | BYTE 9-16 | ||||||||||||||||||||||||||||
| NETID_XX
NETID OF CAN NETWORK: NETID_HSCAN, NETID_MSCAN, NETID_SWCAN, NETID_LSFTCAN |
TIMESTAMP MSB | TIMESTAMP LSB | EXTENDED ID BITS 28:21 |
IDE = Set to 1 when this is an extended frame. EID Bit 17 and 16 = undefined for a standard ID message
|
EXTENDED ID BITS 15:8 |
EXTENDED ID BITS 7:0 |
ERTR =Set to 1 when a remote frame Rb1 and Rb0 = undefined |
CAN Data bytes 0 - 8
Remote Frame Have No Data |
C/C++ Examples:
Getting Standard Frame Arb ID
uiArbID = (((unsigned int) bPacket[3]) << 3) + ((bPacket[4] & 0xE0) >> 5);
Getting a Extended Frame Arb ID
uiArbID = ( ((unsigned int) bPacket[3]) << 21) +
((((unsigned int)bPacket[4]) & 0xE0) << 13) +
((((unsigned int)bPacket[4]) & 0x03) << 16) +
(((unsigned int)bPacket[5]) << 8) + bPacket[6];
Determining if the message is
an Extended or Standard ID
// is this frame a standard or extended frame (Xtd indicated by bit 3 =1)
if (bPacket[4]
& 0x8)
{
// Extended}
else
{
// Standard}
Determining if the Standard Message is a Remote Frame
// is this frame a remote one (indicated by bit 4)
if (bPacket[4] & 0x10)
{ // Standard ID Remote Frame}
else
{ // Regular Standard Frame }
// is this frame a remote one (indicated by bit 6)Determining if the Extended Message is a Remote Frame
Determining Number of Data Bytes for a Standard Frame
// Mask off upper nibble
NumberBytesData
= bPacket[5] &
0x0F;
Determining Number of Data Bytes for an Extended Frame
// Mask off upper nibble
NumberBytesData
= bPacket[7] &
0x0F;
| intrepidcs API Documentation - (C) Copyright 2000-2012 Intrepid Control Systems, Inc. |
Last Update: Sunday, October 06, 2002