Python CAN Bus USB Streaming API [+Grafana-MQTT Dashboards]

Python CAN bus USB Serial API Streaming

Need to stream CAN bus data via USB in Python?

With our Python API you can easily connect CLX000 or CANmod devices via USB to your PC - and integrate the CAN data with the popular python-can library.

In this intro we outline key features and use cases - including e.g. streaming your data in real-time Grafana dashboards!

Python CAN-USB Streaming API Script Integration
Simple-to-use python-can USB streaming API SIMPLE-TO-USE

Pip install, then stream data in <5 lines of code

Receive/Transmit CAN bus data in real-time STREAM DATA

Send/receive raw CAN frames via CLX000/CANmod(s)

DBC decode DBC DECODE

Easily DBC decode data to physical values

Windows/Linux Python API WINDOWS/LINUX

Deploy on Windows and Linux (incl. Raspberry)

python-can ecosystem extensions ECOSYSTEM

Leverage the extensive python-can extension tools

API examples Python CAN-USB API EXAMPLES

Benefit from excellent docs and script examples




The CLX000 (CL1000/CL2000) can be used as a CAN bus serial interface by connecting the device to your CAN bus and via USB to your PC. This is often relevant in automotive/industrial OEM development, reverse engineering and CAN bus diagnostics. Similarly, our sensor-to-CAN CANmod series can be used via USB to stream GPS/temperature/analog sensor data in real-time.





View data via CLI

View your raw CAN bus data via the command line (with zero code required) using the can-viewer tool (part of the cantools library)

Log data via CLI

View/log your raw CAN data via the command line using the can-logger tool - with extensive output support (MF4, CSV, LOG, TRC, ASC, …)

Replay data via CLI

Easily load e.g. CANedge/CLX000 log files and replay them via USB onto your CAN bus using the simple can-player tool

Receive/transmit raw CAN frames in scripts

Receive/transmit raw CAN frames in a few lines of code - enabling tons of powerful use cases, incl. e.g. dynamic/conditional communication flows

DBC decode data in real-time

Load your own DBC file(s) to decode data in real-time, enabling e.g. visualization, alerting, conditional logic and more

Visualize your data in real-time via Grafana-MQTT

As an example demo use case, you can forward decoded CLX000/CANmod CAN-bus messages to an MQTT-broker - and visualise it in customizable Grafana dashboards

Leverage CAN protocol extensions

Benefit from the powerful extensions to python-can across protocols, including J1939, CANopen, ISO-TP, UDS, XCP and more

python-can extensions protocols

Try the Python API now!




Setup CAN based monitoring & alerting systems

Need to continuously monitor CAN based systems and automate alerts?

In many production/testing/development use cases, you may need to deploy automation scripts that records CAN data, DBC decodes it - and reacts according to e.g. certain patterns. For example, you may have a temperature-sensitive process where you could deploy one or more CANmod.temp units to measure temperatures, stream this data to a PC - and send an alert if certain thresholds are crossed. Or, you could use a CLX000 to record CAN bus data during e.g. an automotive lab test and script it to transmit certain CAN based commands when event X, Y or Z happens.

Monitor CAN bus data in real-time via USB and Python


Visualize CAN bus data in real-time via Grafana-MQTT dashboards

Visualize data in 100% free & customizable dashboards

Need to deploy customized dashboards for visualizing your data?

Most CAN-USB software tools offer very limited visualization options. However, with the Python API you can easily integrate your CLX000/CANmod data streams with Grafana dashboards using the MQTT protocol. This lets you visualize your DBC decoded data in beautiful and customizable dashboardsa. This can be used locally on the host PC as a development/diagnostic tool - or it can be port forwarded for remote access, e.g. for systematic process monitoring.



Perform advanced CAN bus diagnostics/simulation

Need to perform tailored diagnostics of your CAN bus?

With the Python API, you gain far more granular control in your CAN bus diagnostics efforts, making it an excellent supplement to using e.g. the SavvyCAN GUI tool. For example, you can selectively extract specific CAN frames (or DBC decoded signals) of interest and perform targeted statistical analyses. Or, you can replay entire/partial log files by e.g. loading data recorded from the CANedge/CLX000 and outputting it onto your CAN bus. Replaying can be done quickly via the can-player tool - or with more granular control using Python scripts.

Diagnose CAN bus data via Python incl. log file replay


Leverage higher-layer protocol extensions for python-can

Create protocol-specific communication flows

Need to set up advanced and protocol-specific communication?

The python-can library offers a wide array of extensions, incl. for protocols like J1939, UDS, XCP, ISO-TP, CANopen and more. This lets you abstract away a lot of the code complexity required to work with a specific protocol - and lets you focus on quickly writing the communication required for your use case. With this, there are practically no limits to what you can achieve - as long as you know your way around Python.






FAQ


Yes, you can connect any number of CANmod and/or CLX000 devices in parallel. Each device is registered with a unique COM port, which can be referenced via the various command line tools and in your Python scripts. This is useful if you e.g. need to monitor multiple CAN buses in parallel, or if you e.g. need to hook up several CANmod devices for monitoring.


We offer technical support on the basics, i.e. ensuring that you can get started with receiving/transmitting data as per our 'basic' script examples in the Python API documentation.

However, we do not offer technical support on custom scripts or general Python coding. Further, some of the demos we showcase (such as the Grafana-MQTT integration) come without support, though the documentation should make it fairly simple to set up.


Our CANedge/CLX000/CANmod devices all integrate with Python. We refer in general to this integration as a Python API. To be more specific, the 'Python API' refers to the below Python packages:

  1. python-can-csscan-mf4: This Python package adds support in python-can for the CANedge MDF log file format
  2. python-can-csscan-txt: This Python package adds support in python-can for the CLX000 TXT log file format
  3. python-can-csscan-serial: This Python package adds support in python-can for the serial interface used by the CLX000/CANmod

This article focuses on the python-can-csscan-serial package, while you can read about the log file Python API in our separate Python API article. Note also that the three packages above provide identical interfaces, meaning you can to a large extent abstract away the source of the data, whether it is a log file or a USB data stream.


As a supplement to the above Python packages, we also sometimes refer to processing Parquet data lakes in Python, see e.g. our intro to our MF4 decoders. This reflects the fact that we provide simple-to-use executables for DBC decoding CANedge/CLX000 log files to Parquet files. Python can be used to both run the executables (via sub processes) as well as analyze the Parquet files, hence this offers a very useful alternative route for analysing data - ideally suited for large-scale data processing.




Ready to analyze your CAN-USB data in Python?

Get your CANmod/CLX000 today!







Recommended for you