Skip to contentSkip to conversation

Finding a transmitter's CAN ID

Socketcan-users Marc Kleine-Budde 2 participants 3 messages Aug 19, 2013 – Aug 21, 2013 1 message not in the archive CAN network drivers

lore
Share & tools
lore

Marc Kleine-Budde

author maintainer
#1 lore raw
In reply to a message not in the archive

Hello Rob,

please come to the new mailinglist [email protected]

Marc

Quoted 33 lines · Rob__V

Hi all,

I am currently working on a project with several embedded platforms connect via CAN:
1 x Linux board connected via SocketCAN
N x embedded boards using the Atmega16M1 (CAN) MCU.

The Linux board is 'treated' as the master and needs to know the CAN ID of each
atmega board that sends it a CAN message. So my question is :

How is the Linux/SocketCAN board able to determine the CAN ID of other networked nodes when they transmit ?

Of course, each CAN node can determine the target ID for each message but I am not sure if the source ID is known ... outside of arbitration.

Thank you for your time.

All the best,
Rob

--
View this message in context: http://socket-can.996257.n3.nabble.com/Finding-a-transmitter-s-CAN-ID-tp7678.html
Sent from the Socket-CAN Users mailing list archive at Nabble.com.
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
author maintainer
#2 lore raw
Quoted 11 lines · Marc Kleine-Budde
Quoted 11 lines

I am currently working on a project with several embedded platforms connect via CAN:
1 x Linux board connected via SocketCAN
N x embedded boards using the Atmega16M1 (CAN) MCU.

The Linux board is 'treated' as the master and needs to know the CAN ID of each
atmega board that sends it a CAN message. So my question is :

How is the Linux/SocketCAN board able to determine the CAN ID of other networked nodes when they transmit ?

When we're talking about RAW CAN frames, there is no such thing as CAN id of a node, it's not an address. Neither sending nor receiving. Think of the CAN id more as a part of the data of the CAN frame.

Depending on your higher level protocol there might be an addressing scheme which makes use of the CAN id. Then there is probably a CAN id (or part of) associated which each node.

Are you using some kind of (standardised) protocol on top of RAW CAN?

Quoted 2 lines
Quoted 2 lines

Of course, each CAN node can determine the target ID for each message but I am not sure if the source ID is known ... outside of arbitration.

For arbitration purpose the CAN id of each CAN frame is used. All nodes that receive the CAN frame receive the same CAN id, in particular the CAN id the sending node put into the CAN frame.

Under Linux the CAN if is stored in the "can_id" member of the "struct can_frame" (which is used for both sending and receiving CAN frames).

Quoted 5 lines

struct can_frame {
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
__u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
};

Hope that helps,
Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
#3 lore raw
In reply to Marc Kleine-Budde

Hello again,

Thanks all for the helpful information.
I am a little clearer on how the CAN bus works now.

All the best,
Rob

Quoted 33 lines · Rob__V

Hi all,

I am currently working on a project with several embedded platforms connect via CAN:
1 x Linux board connected via SocketCAN
N x embedded boards using the Atmega16M1 (CAN) MCU.

The Linux board is 'treated' as the master and needs to know the CAN ID of each
atmega board that sends it a CAN message. So my question is :

How is the Linux/SocketCAN board able to determine the CAN ID of other networked nodes when they transmit ?

Of course, each CAN node can determine the target ID for each message but I am not sure if the source ID is known ... outside of arbitration.

Thank you for your time.

All the best,
Rob

--
View this message in context: http://socket-can.996257.n3.nabble.com/Finding-a-transmitter-s-CAN-ID-tp7678.html
Sent from the Socket-CAN Users mailing list archive at Nabble.com.
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users