Skip to main content

A CLI tool providing rich monitoring of CAN data

Project description

Canviewer


Table of Contents

Installation

  • From PyPi This package is available on PyPi and can be directly installed with: pip install canviewer

  • From source:
    Clone this repository and simply run pip install . at the root (preferrably in a virtual environment). This tool uses hatchling backend for building, you can consider using hatch as a frontend (hatch shell).

Usage

After installing, you can summon this utility with canviewer:

Usage: canviewer [OPTIONS]

  For every CAN ID found on the CAN bus, displays the data for the last
  message received. If the message is declared in one of the passed databases,
  shows the decoded data.

Options:
  -c, --channel TEXT              Name of the CAN channel to monitor
  -d, --driver TEXT               Specifies which CAN driver to use if
                                  multiple available
  -db, --databases TEXT           Path to .kcd files or to a folder containing
                                  kcd files
  -f, --filters TEXT              Either a name or a numeric ID, only passed
                                  messages will be displayed
  -s, --single-message TEXT       Tracks a single message, shows a custom
                                  table with one column per signal
  -i, --ignore-unknown-messages   Hides messages that are not declared in one
                                  of your databases
  -r, --record-signals TEXT       Records the values for a given signal,
                                  exports them to CSV on exiting. You shall
                                  pass your target signal as
                                  message_name.signal_name
  -n, --inline                    Disables full-screen
  -sf, --snapshot-format [json|csv]
                                  Format to use for snapshots
  --help                          Show this message and exit.

canviewer will show the latest data for every message received on your CAN bus.
You can pass dbc or kcd databases to the tool if you want it to decode your data as follows:

canviewer -db path/to/afolder path/to/a_database.kcd

When passing a folder, dbc or kcd files will be automatically discovered in the folder. You can pass many items after the -db flag.

If omitting the CAN channel the tool will use the default on your system: can0 on Linux and PCAN_USBBUS1 on Windows. You can specify the channel with -c flag. Same applies to the CAN driver, which can be passed with -d.

Filtering

You can filter out unknown messages by passsing -i.
You can only display some selected messages by passing their name or ID to -f flag (flag can be passed multiple times):

canviewer -db my_db.kcd -f My_Message_Name

Plotting signals

You can ask canviewer to plot one or multiple signals in real-time by using the pl (--plot) flag. It should be apssed as-pl message_name.signal_name and you can pass this flag as many times as you want (one plot will be spawned per signal). The signal will also be recorded to csv file. Note that if you'd like to only record without plotting, use -r instead.

Pagination

If the tables cannot fit on your screen, it will be splitted in multiple tables. You can press enter to navigate (enter goes forwards and b + enter goes backward, see live commands below).

Live commands

There are a few interactive commands you can use whil canviewer is running. Not that all commands require to press enter (to flush stdin) to be applied, as canviewer is a simple textual program and not a full-fledged user interface.

Taking snapshots

While running, press s + ENTER to take a snapshot. The snapshot will contain a dump of the current value for every known signal of the loaded databases. Your filters will be applied. You may select the snapshot format when starting the utility through the -sf/--snapshot-format flag (csv or json supported).
The snapshot is created in your current working directory and will be named snapshot_canviewer_{datetime}.{format}.

Navigating

To navigate through pages, you can:

  • Use an empty string ([ENTER]) to go one page forward
  • Use b (b + [ENTER]) to go one page backward
  • type any page number to go to that page directly

Zooming in and out

Use + and - to decrease or increase the number of lines per page.

Other utilities

canviewer-jsonify

Linux-only

This is an alternate entrypoint you can call with canviewer-jsonify. This command expects to receive the path to a database file, and will spawn one JSON file per message in a temporary folder (note: everything will be wiped on exiting the command). This command monitors the can bus actively and odes the following:

  • RX: everytime a message is received, the corresponding JSON file will be updated with the new values. You can watch them in real time.with tail -f or similar commands.
  • TX: Whenever a JSON file for TX message is edited manually, the new values will be sent automatically to the CAN bus.

[!WARNING] Modifications on JSON files are monitored using inotify. Any message received on the bus that's not sent by this command itself will be considered RX and filtered out from inotify monitoring, so modifying them manually will not trigger a message send.

Usage: canviewer-jsonify [OPTIONS] DATABASE

  database: Path to the database to JSONify

Options:
  -c, --channel TEXT              Name of the CAN channel to monitor
  -l, --log-level [critical|fatal|error|warn|warning|info|debug|notset]
                                  Log level to apply
  --help                          Show this message and exit.

(e.g.) If calling canviewer-jsonify my_database.kcd you should get something like this:

Path to model:
/tmp/tmp0zkw00sm
Use Ctrl + C to leave

Simply cd to the displayed path and you shoPath to model: /tmp/tmp0zkw00sm Use Ctrl + C to leaveuld find all the JSON files for the messages in the passed database there. Files should be named following the schema {message_name}.json.

License

canviewer is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

canviewer-1.4.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

canviewer-1.4.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file canviewer-1.4.0.tar.gz.

File metadata

  • Download URL: canviewer-1.4.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for canviewer-1.4.0.tar.gz
Algorithm Hash digest
SHA256 fbcc312a397a5a3d8d4b9fcf914aacce405ef4c4ffd59b71cd927d605747080a
MD5 74fba826b8deabcbaea470de75581304
BLAKE2b-256 b628647c075b87c7c0eb25222a241b88e6f59174ff9d8f87e77fb98067631444

See more details on using hashes here.

Provenance

The following attestation bundles were made for canviewer-1.4.0.tar.gz:

Publisher: publish-to-pypi.yml on Hedwyn/python-canviewer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file canviewer-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: canviewer-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for canviewer-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bfac6bd112e4d6ca84e781b2c4067f997f81488899d371d4de4b5a8a271512f
MD5 3dd17b8df0f85d08a697966d5e1a3cdb
BLAKE2b-256 7d8e1364a4fa4d9c76778b0378b5590ef931353ce95a7486bb4bd251a9f2fa70

See more details on using hashes here.

Provenance

The following attestation bundles were made for canviewer-1.4.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on Hedwyn/python-canviewer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page