1

As the title says, I used the command candump can0 can1 to watch frames on the CAN bus, but I can't distinguish which frames are received and which are sent.

Sometimes I need the timestamp of received frames to analyze problems.

I don`t know if candump supports these.

candump screenshot

Adrian W
  • 4,563
  • 11
  • 38
  • 52
YunYanan
  • 478
  • 1
  • 5
  • 12
  • Have you already tried Wireshark? – yegorich Sep 27 '18 at 13:52
  • CAN data is identified by CAN ID and you will always see everything that is on the bus, no matter who sent it. I don't know of any tool which would have a different approach. Even Wireshark. See [here](https://www.ixxat.com/technologies/all4can/can-news-blog/can-news-blog/2016/11/07/analysis-of-can-networks-under-linux-with-wireshark): no source, no destination. However each node should have a set of IDs it sends. So, you should be able to solve the problem with filters: one instance filtering the IDs your node sends, another instance filtering everything else. – Adrian W Sep 27 '18 at 16:03
  • On CAN PHY and Data Link layer, you have no information about the sender/receiver. You need the Communication Matrix saying which ID comes from which node, if you want to see from external perspective everything. Tx/Rx attribute is only a conclusion based on the ID and the associated Communication schedule. – VioletVynil Oct 11 '18 at 21:19
  • But the adapter can know if a frame was sent by it or not ; the latter represents a received frame. – Milind R Aug 04 '22 at 14:40

3 Answers3

2

As said in the comments, the CAN protocol does not keep tracks of sender/receiver. The only data identifying a message is the message ID. In a common CAN network, each devices is assigned specifc ID for transmission and reception. You need to know the CAN network definition (or CAN matrix) to properly understand the content of a CAN bus.

The definition are most commonly stored into a .dbc file, a proprietary file format that many tools supports. These file describe how to interpret CAN messages, but also list the nodes in the network and what message ID is attributed to each node. Car manufacturers normally don't share these definition files. Some big manufacturer won't even share them with their partners developping ECU going inside the car... (and I am talking of experience here)

Note that some protocols layered above the CAN layer encode a source/destination address in the message ID (generally only through extended CAN frame with 29bits ID). Protocol such as J1939 and ISO-15765-3 (used with UDS) does that.

2

It's a long time since any update on this topic. But maybe it helps someone.

You can show the timestamp with the options as shown on this Site:

-ta : absolute
-td : delta
-tz : zero
-tA : Absolute with date

So for your problem you can use:

candump -ta can0 can1
Surfer
  • 121
  • 9
2

The -x argument prints extra message info, rx/tx brs esi

e.g. candump -ta -x -c -c can0 can1

For additional details: candump -h

  • This is the right answer, I am not sure why the others have written lengthily about its impossibility. – Milind R Aug 05 '22 at 09:26