Getting CAN identifier bits when using broad mask

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting CAN identifier bits when using broad mask

468 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Jodie Robinson on Mon Oct 12 08:21:20 MST 2015
Hi there.

I'm using the LPC11C24 in an SAE J1939 application.

I've done a bit of research, and have the built-in CAN drivers working, but can't find a way to differentiate messages based on their identifiers when using a broad mask.

I would like to capture all packets on a CAN bus in a certain range (larger than the available 32 filter slots).

Thanks for any help

Jodie
Labels (1)
0 Kudos
3 Replies

403 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Oct 13 00:58:15 MST 2015

Quote: Jodie Robinson
It seems msg_obj doesn't have an id on this part. Is there any way to add it?



In your case (original sample) that's mode_id & 0x7FF for 11-bit CAN...

mode_id is including CAN id and CAN mode as explained in User manual:


Quote:
// control bits for CAN_MSG_OBJ.mode_id
#define CAN_MSGOBJ_STD 0x00000000UL // CAN 2.0a 11-bit ID
#define CAN_MSGOBJ_EXT 0x20000000UL // CAN 2.0b 29-bit ID
#define CAN_MSGOBJ_DAT 0x00000000UL // data frame
#define CAN_MSGOBJ_RTR 0x40000000UL // rtr frame
typedef struct _CAN_MSG_OBJ {
uint32_t mode_id;
uint32_t mask;
uint8_t data[8];
uint8_t dlc;
uint8_t msgobj;
} CAN_MSG_OBJ;

0 Kudos

403 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Jodie Robinson on Mon Oct 12 22:56:48 MST 2015
Hi R2D2

It seems msg_obj doesn't have an id on this part. Is there any way to add it?

This is what CCAN_MSG_OBJ is declared as in my environment:

typedef struct _CAN_MSG_OBJ {
  uint32_t mode_id;
  uint32_t mask;
  uint8_t data[8];
  uint8_t dlc;
  uint8_t msgobj;
} CAN_MSG_OBJ;


Thanks
0 Kudos

403 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Oct 12 09:25:54 MST 2015
What's wrong with differentiating them in their message  :quest: 

void CAN_rx(uint8_t msg_obj_num)
{
/* Determine which CAN message has been received */
 msg_obj.msgobj = msg_obj_num;
/* Now load up the msg_obj structure with the CAN message */
 (*rom)->pCAND->can_receive(&msg_obj);
//message number 10: command data
[color=#f00] if (msg_obj_num == 10)//message number 10
 {
  if(msg_obj.id == (0x280))//ID 0x280[/color]
...
  {
0 Kudos