[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request cantools#252 from erzoe/master
Browse files Browse the repository at this point in the history
New subcommand plot
  • Loading branch information
eerimoq committed Jan 4, 2021
2 parents 7d97b43 + 0b87191 commit 6ab0eac
Show file tree
Hide file tree
Showing 9 changed files with 2,146 additions and 1 deletion.
44 changes: 44 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ CAN BUS tools in Python 3.

- CAN bus monitor.

- Graphical plots of signals.

Project homepage: https://github.com/eerimoq/cantools

Documentation: https://cantools.readthedocs.io
Expand Down Expand Up @@ -119,6 +121,46 @@ Alternatively, the decoded message can be printed on a single line:
vcan0 1F0 [8] 80 4A 0F 00 00 00 00 00 :: ExampleMessage(Enable: 'Enabled' -, AverageRadius: 0.0 m, Temperature: 255.92 degK)
vcan0 1F0 [8] 80 4A 0F 00 00 00 00 00 :: ExampleMessage(Enable: 'Enabled' -, AverageRadius: 0.0 m, Temperature: 255.92 degK)
The plot subcommand
^^^^^^^^^^^^^^^^^^^

The plot subcommand is similar to the decode subcommand but messages are visualized using `matplotlib`_ instead of being printed to stdout.

.. code-block:: bash
$ cat candump-2021-01-04_180521.log
(1609779922.655421) vcan0 00000343#B204B9049C049C04
(1609779922.655735) vcan0 0000024A#120527052E051905
(1609779923.657524) vcan0 00000343#C404C404CB04C404
(1609779923.658086) vcan0 0000024A#8B058B058B059205
(1609779924.659912) vcan0 00000343#5C04790479045504
(1609779924.660471) vcan0 0000024A#44064B0659064406
(1609779925.662277) vcan0 00000343#15040704F203F203
(1609779925.662837) vcan0 0000024A#8B069906A706A706
(1609779926.664191) vcan0 00000343#BC03B503A703BC03
(1609779926.664751) vcan0 0000024A#A006A706C406C406
$ cat candump-2021-01-04_180521.log | cantools plot tests/files/dbc/abs.dbc
.. image:: docs/plot-1.png

If you don't want to show all signals you can select the desired signals with command line arguments.
A ``*`` can stand for any number of any character, a ``?`` for exactly one arbitrary character.
Signals separated by a ``-`` are displayed in separate subplots.
Optionally a format can be specified after a signal, separated by a colon.

.. code-block:: bash
$ cat candump-2021-01-04_180521.log | cantools plot tests/files/dbc/abs.dbc '*33.*fl:-<' '*33.*fr:->' - '*33.*rl:-<' '*33.*rr:->'
.. image:: docs/plot-2.png

For more information see

.. code-block:: bash
$ cantools plot --help
The dump subcommand
^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -343,3 +385,5 @@ Contributing
.. _motohawk_no_floating_point_numbers.h: https://github.com/eerimoq/cantools/blob/master/tests/files/c_source/motohawk_no_floating_point_numbers.h

.. _motohawk_no_floating_point_numbers.c: https://github.com/eerimoq/cantools/blob/master/tests/files/c_source/motohawk_no_floating_point_numbers.c

.. _matplotlib: https://matplotlib.org/
2 changes: 2 additions & 0 deletions cantools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ def _main():
from .subparsers import dump
from .subparsers import convert
from .subparsers import generate_c_source
from .subparsers import plot

decode.add_subparser(subparsers)
monitor.add_subparser(subparsers)
dump.add_subparser(subparsers)
convert.add_subparser(subparsers)
generate_c_source.add_subparser(subparsers)
plot.add_subparser(subparsers)

args = parser.parse_args()

Expand Down
Loading

0 comments on commit 6ab0eac

Please sign in to comment.