cantools


Namecantools JSON
Version 39.4.5 PyPI version JSON
download
home_page
SummaryCAN BUS tools.
upload_time2024-02-25 23:12:24
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT
keywords can can bus arxml dbc kcd automotive
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |github-actions| |coverage| |nala|

About
=====

CAN BUS tools in Python 3.

- `DBC`_, `KCD`_, SYM, ARXML 3&4 and CDD file parsing.

- CAN message encoding and decoding.

- Simple and extended signal multiplexing.

- Diagnostic DID encoding and decoding.

- ``candump`` output decoder.

- Node `tester`_.

- `C` source code generator.

- CAN bus monitor.

- Graphical plots of signals.

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

Documentation: https://cantools.readthedocs.io

Installation
============

.. code-block:: bash

    python3 -m pip install cantools

Example usage
=============

Scripting
---------

The example starts by parsing a `small DBC-file`_ and printing its
messages and signals.

.. code-block:: python

   >>> import cantools
   >>> from pprint import pprint
   >>> db = cantools.database.load_file('tests/files/dbc/motohawk.dbc')
   >>> db.messages
   [message('ExampleMessage', 0x1f0, False, 8, 'Example message used as template in MotoHawk models.')]
   >>> example_message = db.get_message_by_name('ExampleMessage')
   >>> pprint(example_message.signals)
   [signal('Enable', 7, 1, 'big_endian', False, 1.0, 0, 0.0, 0.0, '-', False, None, {0: 'Disabled', 1: 'Enabled'}, None),
    signal('AverageRadius', 6, 6, 'big_endian', False, 0.1, 0, 0.0, 5.0, 'm', False, None, None, ''),
    signal('Temperature', 0, 12, 'big_endian', True, 0.01, 250, 229.53, 270.47, 'degK', False, None, None, None)]

The example continues `encoding`_ a message and sending it on a CAN
bus using the `python-can`_ package.

.. code-block:: python

   >>> import can
   >>> can_bus = can.interface.Bus('vcan0', bustype='socketcan')
   >>> data = example_message.encode({'Temperature': 250.1, 'AverageRadius': 3.2, 'Enable': 1})
   >>> message = can.Message(arbitration_id=example_message.frame_id, data=data)
   >>> can_bus.send(message)

Alternatively, a message can be encoded using the `encode_message()`_
method on the database object.

The last part of the example receives and `decodes`_ a CAN message.

.. code-block:: python

   >>> message = can_bus.recv()
   >>> db.decode_message(message.arbitration_id, message.data)
   {'AverageRadius': 3.2, 'Enable': 'Enabled', 'Temperature': 250.09}

See `examples`_ for additional examples.

Command line tool
-----------------

The decode subcommand
^^^^^^^^^^^^^^^^^^^^^

Decode CAN frames captured with the Linux program ``candump``.

.. code-block:: text

   $ candump vcan0 | python3 -m cantools decode tests/files/dbc/motohawk.dbc
     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
   )
     vcan0  1F0   [8]  80 4A 0F 00 00 00 00 00 ::
   ExampleMessage(
       Enable: 'Enabled' -,
       AverageRadius: 0.0 m,
       Temperature: 255.92 degK
   )

Alternatively, the decoded message can be printed on a single line:

.. code-block:: text

   $ candump vcan0 | python3 -m cantools decode --single-line tests/files/dbc/motohawk.dbc
     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)
     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

    $ candump -l vcan0
    $ 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 | python3 -m cantools plot tests/files/dbc/abs.dbc

.. image:: https://github.com/cantools/cantools/raw/master/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 | python3 -m cantools plot tests/files/dbc/abs.dbc '*33.*fl:-<' '*33.*fr:->' - '*33.*rl:-<' '*33.*rr:->'

.. image:: https://github.com/cantools/cantools/raw/master/docs/plot-2-subplots.png

Signals with a different range of values can be displayed in the same subplot on different vertical axes by separating them with a comma.

.. code-block:: bash

   $ cat candump-2021-01-04_180521.log | cantools plot --auto-color tests/files/dbc/abs.dbc -- \
      --ylabel 'Bremse 33' '*_33.*fl*:-<' '*_33.*fr*:>' '*_33.*rl*:3' '*_33.*rr*:4' , \
      --ylabel 'Bremse 2' '*_2.*fl*:-<' '*_2.*fr*:>' '*_2.*rl*:3' '*_2.*rr*:4'

.. image:: https://github.com/cantools/cantools/raw/master/docs/plot-2-axes.png

Matplotlib comes with different preinstalled styles that you can use:

.. code-block:: bash

   $ cat candump-2021-01-04_180521.log | cantools plot tests/files/dbc/abs.dbc --style seaborn

.. image:: https://github.com/cantools/cantools/raw/master/docs/plot-seaborn.png

You can try all available styles with

.. code-block:: bash

   $ cantools plot --list-styles . | sed -n '/^- /s/^- //p' | while IFS= read -r style; do
         cat candump-2021-01-04_180521.log | cantools plot tests/files/dbc/abs.dbc --style "$style" --title "--style '$style'"
     done

For more information see

.. code-block:: bash

    $ python3 -m cantools plot --help

Note that by default matplotlib is not installed with cantools. But it can be by specifying an extra
at installation:

.. code-block:: bash

    $ python3 -m pip install cantools[plot]

The dump subcommand
^^^^^^^^^^^^^^^^^^^

Dump given database in a human readable format:

.. code-block:: text

   $ python3 -m cantools dump tests/files/dbc/motohawk.dbc
   ================================= Messages =================================

     ------------------------------------------------------------------------

     Name:       ExampleMessage
     Id:         0x1f0
     Length:     8 bytes
     Cycle time: - ms
     Senders:    PCM1
     Layout:

                             Bit

                7   6   5   4   3   2   1   0
              +---+---+---+---+---+---+---+---+
            0 |<-x|<---------------------x|<--|
              +---+---+---+---+---+---+---+---+
                |                       +-- AverageRadius
                +-- Enable
              +---+---+---+---+---+---+---+---+
            1 |-------------------------------|
              +---+---+---+---+---+---+---+---+
            2 |----------x|   |   |   |   |   |
        B     +---+---+---+---+---+---+---+---+
        y               +-- Temperature
        t     +---+---+---+---+---+---+---+---+
        e   3 |   |   |   |   |   |   |   |   |
              +---+---+---+---+---+---+---+---+
            4 |   |   |   |   |   |   |   |   |
              +---+---+---+---+---+---+---+---+
            5 |   |   |   |   |   |   |   |   |
              +---+---+---+---+---+---+---+---+
            6 |   |   |   |   |   |   |   |   |
              +---+---+---+---+---+---+---+---+
            7 |   |   |   |   |   |   |   |   |
              +---+---+---+---+---+---+---+---+

     Signal tree:

       -- {root}
          +-- Enable
          +-- AverageRadius
          +-- Temperature

     Signal choices:

       Enable
           0 Disabled
           1 Enabled

     ------------------------------------------------------------------------

The list subcommand
^^^^^^^^^^^^^^^^^^^

Print all information of a given database in a human readable
format. This is very similar to the "dump" subcommand, but the output
is less pretty, slightly more comprehensive and easier to parse by
shell scripts:

.. code-block:: bash

    $ python3 -m cantools list -a tests/files/dbc/motohawk.dbc
    ExampleMessage:
      Comment[None]: Example message used as template in MotoHawk models.
      Frame ID: 0x1f0 (496)
      Size: 8 bytes
      Is extended frame: False
      Signals:
        Enable:
          Type: Integer
          Start bit: 7
          Length: 1 bits
          Unit: -
          Is signed: False
          Named values:
            0: Disabled

The generate C source subcommand
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Generate `C` source code from given database.

The generated code contains:

- Message `structs`_.

- Message `pack`_ and `unpack`_ functions.

- Signal `encode`_ and `decode`_ functions.

- Frame id, length, type, cycle time and signal choices `defines`_.

Known limitations:

- The maximum signal size is 64 bits, which in practice is never
  exceeded.

Below is an example of how to generate C source code from a
database. The database is ``tests/files/dbc/motohawk.dbc``.

.. code-block:: text

   $ python3 -m cantools generate_c_source tests/files/dbc/motohawk.dbc
   Successfully generated motohawk.h and motohawk.c.

See `motohawk.h`_ and `motohawk.c`_ for the contents of the generated
files.

In this example we use ``--use-float`` so floating point numbers in the generated
code are single precision (``float``) instead of double precision (``double``).

.. code-block:: text

   $ python3 -m cantools generate_c_source --use-float tests/files/dbc/motohawk.dbc
   Successfully generated motohawk.h and motohawk.c.

In the next example we use ``--database-name`` to set a custom
namespace for all generated types, defines and functions. The output
file names are also changed by this option.

.. code-block:: text

   $ python3 -m cantools generate_c_source --database-name my_database_name tests/files/dbc/motohawk.dbc
   Successfully generated my_database_name.h and my_database_name.c.

See `my_database_name.h`_ and `my_database_name.c`_ for the contents
of the generated files.

In the next example we use ``--no-floating-point-numbers`` to generate
code without floating point types, i.e. ``float`` and ``double``.

.. code-block:: text

   $ python3 -m cantools generate_c_source --no-floating-point-numbers tests/files/dbc/motohawk.dbc
   Successfully generated motohawk.h and motohawk.c.

See `motohawk_no_floating_point_numbers.h`_ and
`motohawk_no_floating_point_numbers.c`_ for the contents of the
generated files.

In the last example ``--node`` is used to generate
message pack functions only for messages sent by the specified node and unpack
functions only for messages with its signal receivers belonging to that node. 

.. code-block:: text

   $ cantools generate_c_source tests/files/dbc/motohawk.dbc --node PCM1
   Successfully generated motohawk.h and motohawk.c.

See `motohawk_sender_node.h`_ and
`motohawk_sender_node.c`_ for the contents of the
generated files.

Other C code generators:

- http://www.coderdbc.com

- https://github.com/howerj/dbcc

- https://github.com/lonkamikaze/hsk-libs/blob/master/scripts/dbc2c.awk

- https://sourceforge.net/projects/comframe/

The monitor subcommand
^^^^^^^^^^^^^^^^^^^^^^

Monitor CAN bus traffic in a text based user interface.

.. code-block:: text

   $ python3 -m cantools monitor tests/files/dbc/motohawk.dbc

.. image:: https://github.com/cantools/cantools/raw/master/docs/monitor.png

The menu at the bottom of the monitor shows the available commands.

- Quit: Quit the monitor. Ctrl-C can be used as well.

- Filter: Only display messages matching given regular
  expression. Press <Enter> to return to the menu from the filter
  input line.

- Play/Pause: Toggle between playing and paused (or running and freezed).

- Reset: Reset the monitor to its initial state.

Contributing
============

#. Fork the repository.

#. Install prerequisites.

   .. code-block:: text

      python3 -m pip install -e .[dev]

#. Implement the new feature or bug fix.

#. Implement test case(s) to ensure that future changes do not break
   legacy.

#. Run the linters

   .. code-block:: text

      ruff check src
      mypy src

#. Run the tests.

   .. code-block:: text

      tox -e py

#. Create a pull request.

.. |github-actions| image:: https://github.com/cantools/cantools/actions/workflows/pythonpackage.yml/badge.svg?branch=master
   :target: https://github.com/cantools/cantools/actions/workflows/pythonpackage.yml
   :alt: Github Actions workflow status

.. |coverage| image:: https://coveralls.io/repos/github/cantools/cantools/badge.svg?branch=master
   :target: https://coveralls.io/github/cantoolscantools?branch=master
   :alt: Test coverage reports on Coveralls.io

.. |nala| image:: https://img.shields.io/badge/nala-test-blue.svg
   :target: https://github.com/cantools/nala

.. _small DBC-file: https://github.com/cantools/cantools/blob/master/tests/files/dbc/motohawk.dbc

.. _motohawk.dbc: https://github.com/cantools/cantools/blob/master/tests/files/dbc/motohawk.dbc

.. _python-can: https://python-can.readthedocs.io/en/master/

.. _DBC: http://www.socialledge.com/sjsu/index.php?title=DBC_Format

.. _KCD: https://github.com/julietkilo/kcd

.. _tester: http://cantools.readthedocs.io/en/latest/#cantools.tester.Tester

.. _encoding: http://cantools.readthedocs.io/en/latest/#cantools.database.can.Message.encode

.. _encode_message(): http://cantools.readthedocs.io/en/latest/#cantools.database.can.Database.encode_message

.. _decodes: http://cantools.readthedocs.io/en/latest/#cantools.database.can.Database.decode_message

.. _examples: https://github.com/cantools/cantools/blob/master/examples

.. _structs: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L58

.. _pack: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L88

.. _unpack: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L102

.. _encode: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L116

.. _decode: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L125

.. _defines: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L42

.. _motohawk.h: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h

.. _motohawk.c: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.c

.. _my_database_name.h: https://github.com/cantools/cantools/blob/master/tests/files/c_source/my_database_name.h

.. _my_database_name.c: https://github.com/cantools/cantools/blob/master/tests/files/c_source/my_database_name.c

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

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

.. _motohawk_sender_node.h: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk_sender_node.h

.. _motohawk_sender_node.c: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk_sender_node.c

.. _matplotlib: https://matplotlib.org/

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cantools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "can,can bus,arxml,dbc,kcd,automotive",
    "author": "",
    "author_email": "Erik Moqvist <erik.moqvist@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/fd/a4/6c8497906d8641740a5fb45c15ef340bfa38aff2ac68305b02468d45f3e6/cantools-39.4.5.tar.gz",
    "platform": null,
    "description": "|github-actions| |coverage| |nala|\n\nAbout\n=====\n\nCAN BUS tools in Python 3.\n\n- `DBC`_, `KCD`_, SYM, ARXML 3&4 and CDD file parsing.\n\n- CAN message encoding and decoding.\n\n- Simple and extended signal multiplexing.\n\n- Diagnostic DID encoding and decoding.\n\n- ``candump`` output decoder.\n\n- Node `tester`_.\n\n- `C` source code generator.\n\n- CAN bus monitor.\n\n- Graphical plots of signals.\n\nProject homepage: https://github.com/cantools/cantools\n\nDocumentation: https://cantools.readthedocs.io\n\nInstallation\n============\n\n.. code-block:: bash\n\n    python3 -m pip install cantools\n\nExample usage\n=============\n\nScripting\n---------\n\nThe example starts by parsing a `small DBC-file`_ and printing its\nmessages and signals.\n\n.. code-block:: python\n\n   >>> import cantools\n   >>> from pprint import pprint\n   >>> db = cantools.database.load_file('tests/files/dbc/motohawk.dbc')\n   >>> db.messages\n   [message('ExampleMessage', 0x1f0, False, 8, 'Example message used as template in MotoHawk models.')]\n   >>> example_message = db.get_message_by_name('ExampleMessage')\n   >>> pprint(example_message.signals)\n   [signal('Enable', 7, 1, 'big_endian', False, 1.0, 0, 0.0, 0.0, '-', False, None, {0: 'Disabled', 1: 'Enabled'}, None),\n    signal('AverageRadius', 6, 6, 'big_endian', False, 0.1, 0, 0.0, 5.0, 'm', False, None, None, ''),\n    signal('Temperature', 0, 12, 'big_endian', True, 0.01, 250, 229.53, 270.47, 'degK', False, None, None, None)]\n\nThe example continues `encoding`_ a message and sending it on a CAN\nbus using the `python-can`_ package.\n\n.. code-block:: python\n\n   >>> import can\n   >>> can_bus = can.interface.Bus('vcan0', bustype='socketcan')\n   >>> data = example_message.encode({'Temperature': 250.1, 'AverageRadius': 3.2, 'Enable': 1})\n   >>> message = can.Message(arbitration_id=example_message.frame_id, data=data)\n   >>> can_bus.send(message)\n\nAlternatively, a message can be encoded using the `encode_message()`_\nmethod on the database object.\n\nThe last part of the example receives and `decodes`_ a CAN message.\n\n.. code-block:: python\n\n   >>> message = can_bus.recv()\n   >>> db.decode_message(message.arbitration_id, message.data)\n   {'AverageRadius': 3.2, 'Enable': 'Enabled', 'Temperature': 250.09}\n\nSee `examples`_ for additional examples.\n\nCommand line tool\n-----------------\n\nThe decode subcommand\n^^^^^^^^^^^^^^^^^^^^^\n\nDecode CAN frames captured with the Linux program ``candump``.\n\n.. code-block:: text\n\n   $ candump vcan0 | python3 -m cantools decode tests/files/dbc/motohawk.dbc\n     vcan0  1F0   [8]  80 4A 0F 00 00 00 00 00 ::\n   ExampleMessage(\n       Enable: 'Enabled' -,\n       AverageRadius: 0.0 m,\n       Temperature: 255.92 degK\n   )\n     vcan0  1F0   [8]  80 4A 0F 00 00 00 00 00 ::\n   ExampleMessage(\n       Enable: 'Enabled' -,\n       AverageRadius: 0.0 m,\n       Temperature: 255.92 degK\n   )\n     vcan0  1F0   [8]  80 4A 0F 00 00 00 00 00 ::\n   ExampleMessage(\n       Enable: 'Enabled' -,\n       AverageRadius: 0.0 m,\n       Temperature: 255.92 degK\n   )\n\nAlternatively, the decoded message can be printed on a single line:\n\n.. code-block:: text\n\n   $ candump vcan0 | python3 -m cantools decode --single-line tests/files/dbc/motohawk.dbc\n     vcan0  1F0   [8]  80 4A 0F 00 00 00 00 00 :: ExampleMessage(Enable: 'Enabled' -, AverageRadius: 0.0 m, Temperature: 255.92 degK)\n     vcan0  1F0   [8]  80 4A 0F 00 00 00 00 00 :: ExampleMessage(Enable: 'Enabled' -, AverageRadius: 0.0 m, Temperature: 255.92 degK)\n     vcan0  1F0   [8]  80 4A 0F 00 00 00 00 00 :: ExampleMessage(Enable: 'Enabled' -, AverageRadius: 0.0 m, Temperature: 255.92 degK)\n\nThe plot subcommand\n^^^^^^^^^^^^^^^^^^^\n\nThe plot subcommand is similar to the decode subcommand but messages are visualized using `matplotlib`_ instead of being printed to stdout.\n\n.. code-block:: bash\n\n    $ candump -l vcan0\n    $ cat candump-2021-01-04_180521.log\n    (1609779922.655421) vcan0 00000343#B204B9049C049C04\n    (1609779922.655735) vcan0 0000024A#120527052E051905\n    (1609779923.657524) vcan0 00000343#C404C404CB04C404\n    (1609779923.658086) vcan0 0000024A#8B058B058B059205\n    (1609779924.659912) vcan0 00000343#5C04790479045504\n    (1609779924.660471) vcan0 0000024A#44064B0659064406\n    (1609779925.662277) vcan0 00000343#15040704F203F203\n    (1609779925.662837) vcan0 0000024A#8B069906A706A706\n    (1609779926.664191) vcan0 00000343#BC03B503A703BC03\n    (1609779926.664751) vcan0 0000024A#A006A706C406C406\n\n    $ cat candump-2021-01-04_180521.log | python3 -m cantools plot tests/files/dbc/abs.dbc\n\n.. image:: https://github.com/cantools/cantools/raw/master/docs/plot-1.png\n\nIf you don't want to show all signals you can select the desired signals with command line arguments.\nA ``*`` can stand for any number of any character, a ``?`` for exactly one arbitrary character.\nSignals separated by a ``-`` are displayed in separate subplots.\nOptionally a format can be specified after a signal, separated by a colon.\n\n.. code-block:: bash\n\n    $ cat candump-2021-01-04_180521.log | python3 -m cantools plot tests/files/dbc/abs.dbc '*33.*fl:-<' '*33.*fr:->' - '*33.*rl:-<' '*33.*rr:->'\n\n.. image:: https://github.com/cantools/cantools/raw/master/docs/plot-2-subplots.png\n\nSignals with a different range of values can be displayed in the same subplot on different vertical axes by separating them with a comma.\n\n.. code-block:: bash\n\n   $ cat candump-2021-01-04_180521.log | cantools plot --auto-color tests/files/dbc/abs.dbc -- \\\n      --ylabel 'Bremse 33' '*_33.*fl*:-<' '*_33.*fr*:>' '*_33.*rl*:3' '*_33.*rr*:4' , \\\n      --ylabel 'Bremse 2' '*_2.*fl*:-<' '*_2.*fr*:>' '*_2.*rl*:3' '*_2.*rr*:4'\n\n.. image:: https://github.com/cantools/cantools/raw/master/docs/plot-2-axes.png\n\nMatplotlib comes with different preinstalled styles that you can use:\n\n.. code-block:: bash\n\n   $ cat candump-2021-01-04_180521.log | cantools plot tests/files/dbc/abs.dbc --style seaborn\n\n.. image:: https://github.com/cantools/cantools/raw/master/docs/plot-seaborn.png\n\nYou can try all available styles with\n\n.. code-block:: bash\n\n   $ cantools plot --list-styles . | sed -n '/^- /s/^- //p' | while IFS= read -r style; do\n         cat candump-2021-01-04_180521.log | cantools plot tests/files/dbc/abs.dbc --style \"$style\" --title \"--style '$style'\"\n     done\n\nFor more information see\n\n.. code-block:: bash\n\n    $ python3 -m cantools plot --help\n\nNote that by default matplotlib is not installed with cantools. But it can be by specifying an extra\nat installation:\n\n.. code-block:: bash\n\n    $ python3 -m pip install cantools[plot]\n\nThe dump subcommand\n^^^^^^^^^^^^^^^^^^^\n\nDump given database in a human readable format:\n\n.. code-block:: text\n\n   $ python3 -m cantools dump tests/files/dbc/motohawk.dbc\n   ================================= Messages =================================\n\n     ------------------------------------------------------------------------\n\n     Name:       ExampleMessage\n     Id:         0x1f0\n     Length:     8 bytes\n     Cycle time: - ms\n     Senders:    PCM1\n     Layout:\n\n                             Bit\n\n                7   6   5   4   3   2   1   0\n              +---+---+---+---+---+---+---+---+\n            0 |<-x|<---------------------x|<--|\n              +---+---+---+---+---+---+---+---+\n                |                       +-- AverageRadius\n                +-- Enable\n              +---+---+---+---+---+---+---+---+\n            1 |-------------------------------|\n              +---+---+---+---+---+---+---+---+\n            2 |----------x|   |   |   |   |   |\n        B     +---+---+---+---+---+---+---+---+\n        y               +-- Temperature\n        t     +---+---+---+---+---+---+---+---+\n        e   3 |   |   |   |   |   |   |   |   |\n              +---+---+---+---+---+---+---+---+\n            4 |   |   |   |   |   |   |   |   |\n              +---+---+---+---+---+---+---+---+\n            5 |   |   |   |   |   |   |   |   |\n              +---+---+---+---+---+---+---+---+\n            6 |   |   |   |   |   |   |   |   |\n              +---+---+---+---+---+---+---+---+\n            7 |   |   |   |   |   |   |   |   |\n              +---+---+---+---+---+---+---+---+\n\n     Signal tree:\n\n       -- {root}\n          +-- Enable\n          +-- AverageRadius\n          +-- Temperature\n\n     Signal choices:\n\n       Enable\n           0 Disabled\n           1 Enabled\n\n     ------------------------------------------------------------------------\n\nThe list subcommand\n^^^^^^^^^^^^^^^^^^^\n\nPrint all information of a given database in a human readable\nformat. This is very similar to the \"dump\" subcommand, but the output\nis less pretty, slightly more comprehensive and easier to parse by\nshell scripts:\n\n.. code-block:: bash\n\n    $ python3 -m cantools list -a tests/files/dbc/motohawk.dbc\n    ExampleMessage:\n      Comment[None]: Example message used as template in MotoHawk models.\n      Frame ID: 0x1f0 (496)\n      Size: 8 bytes\n      Is extended frame: False\n      Signals:\n        Enable:\n          Type: Integer\n          Start bit: 7\n          Length: 1 bits\n          Unit: -\n          Is signed: False\n          Named values:\n            0: Disabled\n\nThe generate C source subcommand\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nGenerate `C` source code from given database.\n\nThe generated code contains:\n\n- Message `structs`_.\n\n- Message `pack`_ and `unpack`_ functions.\n\n- Signal `encode`_ and `decode`_ functions.\n\n- Frame id, length, type, cycle time and signal choices `defines`_.\n\nKnown limitations:\n\n- The maximum signal size is 64 bits, which in practice is never\n  exceeded.\n\nBelow is an example of how to generate C source code from a\ndatabase. The database is ``tests/files/dbc/motohawk.dbc``.\n\n.. code-block:: text\n\n   $ python3 -m cantools generate_c_source tests/files/dbc/motohawk.dbc\n   Successfully generated motohawk.h and motohawk.c.\n\nSee `motohawk.h`_ and `motohawk.c`_ for the contents of the generated\nfiles.\n\nIn this example we use ``--use-float`` so floating point numbers in the generated\ncode are single precision (``float``) instead of double precision (``double``).\n\n.. code-block:: text\n\n   $ python3 -m cantools generate_c_source --use-float tests/files/dbc/motohawk.dbc\n   Successfully generated motohawk.h and motohawk.c.\n\nIn the next example we use ``--database-name`` to set a custom\nnamespace for all generated types, defines and functions. The output\nfile names are also changed by this option.\n\n.. code-block:: text\n\n   $ python3 -m cantools generate_c_source --database-name my_database_name tests/files/dbc/motohawk.dbc\n   Successfully generated my_database_name.h and my_database_name.c.\n\nSee `my_database_name.h`_ and `my_database_name.c`_ for the contents\nof the generated files.\n\nIn the next example we use ``--no-floating-point-numbers`` to generate\ncode without floating point types, i.e. ``float`` and ``double``.\n\n.. code-block:: text\n\n   $ python3 -m cantools generate_c_source --no-floating-point-numbers tests/files/dbc/motohawk.dbc\n   Successfully generated motohawk.h and motohawk.c.\n\nSee `motohawk_no_floating_point_numbers.h`_ and\n`motohawk_no_floating_point_numbers.c`_ for the contents of the\ngenerated files.\n\nIn the last example ``--node`` is used to generate\nmessage pack functions only for messages sent by the specified node and unpack\nfunctions only for messages with its signal receivers belonging to that node. \n\n.. code-block:: text\n\n   $ cantools generate_c_source tests/files/dbc/motohawk.dbc --node PCM1\n   Successfully generated motohawk.h and motohawk.c.\n\nSee `motohawk_sender_node.h`_ and\n`motohawk_sender_node.c`_ for the contents of the\ngenerated files.\n\nOther C code generators:\n\n- http://www.coderdbc.com\n\n- https://github.com/howerj/dbcc\n\n- https://github.com/lonkamikaze/hsk-libs/blob/master/scripts/dbc2c.awk\n\n- https://sourceforge.net/projects/comframe/\n\nThe monitor subcommand\n^^^^^^^^^^^^^^^^^^^^^^\n\nMonitor CAN bus traffic in a text based user interface.\n\n.. code-block:: text\n\n   $ python3 -m cantools monitor tests/files/dbc/motohawk.dbc\n\n.. image:: https://github.com/cantools/cantools/raw/master/docs/monitor.png\n\nThe menu at the bottom of the monitor shows the available commands.\n\n- Quit: Quit the monitor. Ctrl-C can be used as well.\n\n- Filter: Only display messages matching given regular\n  expression. Press <Enter> to return to the menu from the filter\n  input line.\n\n- Play/Pause: Toggle between playing and paused (or running and freezed).\n\n- Reset: Reset the monitor to its initial state.\n\nContributing\n============\n\n#. Fork the repository.\n\n#. Install prerequisites.\n\n   .. code-block:: text\n\n      python3 -m pip install -e .[dev]\n\n#. Implement the new feature or bug fix.\n\n#. Implement test case(s) to ensure that future changes do not break\n   legacy.\n\n#. Run the linters\n\n   .. code-block:: text\n\n      ruff check src\n      mypy src\n\n#. Run the tests.\n\n   .. code-block:: text\n\n      tox -e py\n\n#. Create a pull request.\n\n.. |github-actions| image:: https://github.com/cantools/cantools/actions/workflows/pythonpackage.yml/badge.svg?branch=master\n   :target: https://github.com/cantools/cantools/actions/workflows/pythonpackage.yml\n   :alt: Github Actions workflow status\n\n.. |coverage| image:: https://coveralls.io/repos/github/cantools/cantools/badge.svg?branch=master\n   :target: https://coveralls.io/github/cantoolscantools?branch=master\n   :alt: Test coverage reports on Coveralls.io\n\n.. |nala| image:: https://img.shields.io/badge/nala-test-blue.svg\n   :target: https://github.com/cantools/nala\n\n.. _small DBC-file: https://github.com/cantools/cantools/blob/master/tests/files/dbc/motohawk.dbc\n\n.. _motohawk.dbc: https://github.com/cantools/cantools/blob/master/tests/files/dbc/motohawk.dbc\n\n.. _python-can: https://python-can.readthedocs.io/en/master/\n\n.. _DBC: http://www.socialledge.com/sjsu/index.php?title=DBC_Format\n\n.. _KCD: https://github.com/julietkilo/kcd\n\n.. _tester: http://cantools.readthedocs.io/en/latest/#cantools.tester.Tester\n\n.. _encoding: http://cantools.readthedocs.io/en/latest/#cantools.database.can.Message.encode\n\n.. _encode_message(): http://cantools.readthedocs.io/en/latest/#cantools.database.can.Database.encode_message\n\n.. _decodes: http://cantools.readthedocs.io/en/latest/#cantools.database.can.Database.decode_message\n\n.. _examples: https://github.com/cantools/cantools/blob/master/examples\n\n.. _structs: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L58\n\n.. _pack: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L88\n\n.. _unpack: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L102\n\n.. _encode: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L116\n\n.. _decode: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L125\n\n.. _defines: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h#L42\n\n.. _motohawk.h: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.h\n\n.. _motohawk.c: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk.c\n\n.. _my_database_name.h: https://github.com/cantools/cantools/blob/master/tests/files/c_source/my_database_name.h\n\n.. _my_database_name.c: https://github.com/cantools/cantools/blob/master/tests/files/c_source/my_database_name.c\n\n.. _motohawk_no_floating_point_numbers.h: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk_no_floating_point_numbers.h\n\n.. _motohawk_no_floating_point_numbers.c: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk_no_floating_point_numbers.c\n\n.. _motohawk_sender_node.h: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk_sender_node.h\n\n.. _motohawk_sender_node.c: https://github.com/cantools/cantools/blob/master/tests/files/c_source/motohawk_sender_node.c\n\n.. _matplotlib: https://matplotlib.org/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "CAN BUS tools.",
    "version": "39.4.5",
    "project_urls": {
        "documentation": "https://cantools.readthedocs.io/",
        "homepage": "https://github.com/cantools/cantools",
        "repository": "https://github.com/cantools/cantools"
    },
    "split_keywords": [
        "can",
        "can bus",
        "arxml",
        "dbc",
        "kcd",
        "automotive"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d6bb100aeb6c155990f29a159a477752f1f4deb8ad8343f0034dc3ff796d18f",
                "md5": "504c409a526cef79de4ae0b8715f37fe",
                "sha256": "d05b428c2d0afa9fb27a1f9f16b943ef573e0138aa466990dfa4e162d14a8a61"
            },
            "downloads": -1,
            "filename": "cantools-39.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "504c409a526cef79de4ae0b8715f37fe",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 153283,
            "upload_time": "2024-02-25T23:12:19",
            "upload_time_iso_8601": "2024-02-25T23:12:19.663304Z",
            "url": "https://files.pythonhosted.org/packages/3d/6b/b100aeb6c155990f29a159a477752f1f4deb8ad8343f0034dc3ff796d18f/cantools-39.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fda46c8497906d8641740a5fb45c15ef340bfa38aff2ac68305b02468d45f3e6",
                "md5": "7c603dae9713bb7429dc2eb14141af8f",
                "sha256": "594f2ae80deadb8c6b08e8e1322d42e258f40d42c80d6886d84e0143f90b5a23"
            },
            "downloads": -1,
            "filename": "cantools-39.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "7c603dae9713bb7429dc2eb14141af8f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 977210,
            "upload_time": "2024-02-25T23:12:24",
            "upload_time_iso_8601": "2024-02-25T23:12:24.569448Z",
            "url": "https://files.pythonhosted.org/packages/fd/a4/6c8497906d8641740a5fb45c15ef340bfa38aff2ac68305b02468d45f3e6/cantools-39.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-25 23:12:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cantools",
    "github_project": "cantools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "appveyor": true,
    "tox": true,
    "lcname": "cantools"
}
        
Elapsed time: 0.26795s