8

I'm trying to use canplayer to replay some candump files, with no success. When I try to run the canplayer it just executes and returns, giving me no clue of what is happening.

What I've tried up to now:

Setup 1

  • Set up a vcan interface
  • Sent data to the vcan interface using cansend and cangen, with success (verified with candump).
  • Recorded a candump file from vcan0 when running cangen. Recorded files with absolute timestamps (-t a) and without.
  • Tried using canplayer to reproduce the file. Tried using several arguments, no avail. canplayer just returns immediately without any complaint. If I mess up the the file or arguments it complains.

Setup 2

  • Connected 2 PEAK CAN USB adapter devices to the PC.
  • Connected the adapters to each other using a 120ohm terminated cable
  • Started cangen pointing to can0 and verified that the messages got to can1 using candump
  • Recorded candump files from can0 interface.
  • Tried using canplayer to reproduce the file., with no success.

I've tried these tests on two different machines, both running Ubuntu 12.04, with the same results.

Do you know what might be the cause of it?

Jordan.J.D
  • 7,999
  • 11
  • 48
  • 78
Arthur Nunes
  • 6,718
  • 7
  • 33
  • 46
  • The "canutils" is a set of tools that are used for testing, logging and debugging SocketCAN applications in a Linux environment. It is difficult to find information about programming SocketCAN and canutils usage around the internet, only place I've found up to now is a mailing list (http://socket-can.996257.n3.nabble.com/Socket-CAN-Users-f3.html). I believe others programmers that also work with SocketCAN would benefit from using StackOverflow to share their questions and answers. That is why I decided to post it here. – Arthur Nunes Jul 17 '15 at 17:39
  • Fair enough, I'm glad I asked. I'd still encourage you to create good tag wikis for these tags, to help others understand what they're about. – Mogsdad Jul 17 '15 at 19:12
  • I didn't know about the tag wiki thing, I'll look into that, thank you. I've also removed one of the new tags, I believe just the "canutils" one is enough. – Arthur Nunes Jul 17 '15 at 20:36
  • 1
    Cool. When you hover over a tag, look for an "info" link. That will take you to the tag info, aka tag wiki. Have a look at some established tags to get an idea of what info makes sense (for example [[tag:google-apps-script]]). If you edit the tag info, you'll find it has two parts, a excerpt or summary, and the wiki body. The summary gets shown when people are typing a tag on a question, so it's good if it's short and to the point, so people might read it and avoid using the wrong tag. – Mogsdad Jul 17 '15 at 21:03

3 Answers3

21

It seems I had recorded the log files in a wrong manner.

My logs files where recording using the following command:

$ candump -ta vcan0 "log.candump"

That command, however, records the log in human readable format:

  vcan0  1B3   [8]  8E 02 74 22 55 70 49 30
  vcan0  658   [6]  27 48 2C 56 14 0A
  vcan0  1F8   [2]  77 99
  vcan0  7B7   [8]  33 A2 24 38 B2 78 86 72
  vcan0  43C   [8]  92 C6 81 2E FC 5E 38 35
  vcan0  7B0   [2]  2D 1B

In order to record log files that can be playback with canplayer, they should be recorded using either

$ candump -l vcan0

or

$ candump -L vcan0 > myfile.log

The recorded file will look like this:

(1436509052.249713) vcan0 044#2A366C2BBA
(1436509052.449847) vcan0 0F6#7ADFE07BD2
(1436509052.650004) vcan0 236#C3406B09F4C88036
(1436509052.850131) vcan0 6F1#98508676A32734
(1436509053.050284) vcan0 17F#C7
(1436509053.250417) vcan0 25B#6EAAC56C77D15E27
(1436509053.450557) vcan0 56E#46F02E79A2B28C7C
(1436509053.650713) vcan0 19E#6FE1CB7DE2218456
(1436509053.850870) vcan0 1A0#9C20407F96EA167B
(1436509054.051025) vcan0 6DE#68FF147114D1

Files in that format can be replayed in canplayer using the following commands:

$ canplayer -I candump-2015-07-10_081824.log

or

$ cat candump-2015-07-10_081824.log | canplayer

Credits for this answer go to Oliver Hartkopp.

Arthur Nunes
  • 6,718
  • 7
  • 33
  • 46
  • 1
    Do you know if there is a utility for converting already recorded data from one format to the other? – Aras Nov 01 '16 at 21:49
  • @Aras There is a "asc2log" app (see https://github.com/linux-can/can-utils), but I've never used it, though. If you try it, please let me know if it works. – Arthur Nunes Nov 03 '16 at 10:25
  • 1
    `cat infile | awk '{print "(0.000000) "$1" "$2"#"$4$5$6$7$8$9$10$11 }' > outfile` did the trick for me, however all timestamps are set to zero. – tillz Feb 10 '21 at 11:41
1

I found this article with some great information about using can and vcan. After taking a log of a physical CAN bus with candump using

$ candump -l can0

as stated in the previous answer. I used the following to play it back over a virtual CAN bus.

$ canplayer vcan0=can0 -I candump-may-14-2015.log
Barbara Gendron
  • 385
  • 1
  • 2
  • 16
J.Sunderland
  • 50
  • 1
  • 3
  • 2
    That link is dead now. If you still want to access the content then go to archived snapshot at https://web.archive.org/web/20170907045429/http://www.embeddedhobbyist.com/2015/09/linux-can-development/ – avra Jun 15 '21 at 06:33
0

Here it is:

cat input | awk '{print $1" "$2" "$3"#"$5$6$7$8$9$10$11$12}' > output.log