Skip to content

CSS-Electronics/api-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

CAN bus API examples (Python/MATLAB) | CANedge [LEGACY]

Update: Legacy notice + new Python/MATLAB integration methods

If you need to work with the CANedge data in Python/MATLAB, we now recommend to use the methods described in the below documentations:

The Python methods/modules shown in repository under examples/data-processing/ can still be used, but will not be updated going forward (this refers to the sub modules of our Python API, mdf-iter, canedge-browser and can-decoder). We instead refer to our new integration with python-can - and our examples of how to work with DBC decoded Parquet data lakes in Python. The script examples found in examples/other/ will still be relevant going forward.


Overview

This project includes Python and MATLAB examples of how to process MF4 log files with CAN/LIN data from your CANedge data loggers. Most examples focus on the use of our Python API modules (canedge_browser, mdf_iter, can_decoder) for use with the CANedge log file formats (MF4, MFC, MFE, MFM). However, you'll also find other script examples incl. for the asammdf Python API, MATLAB, S3 and more.


Features

For most use cases we recommend to start with the below examples:
- data-processing: List log files, load them and DBC decode the data (local, S3)

For some use cases the below examples may be useful:
- other/asammdf-basics: Load and concatenate MF4 logs, DBC decode them - and save as new MF4 files
- other/matlab-basics: Examples of how to load and use MF4/MAT CAN bus data 
- other/s3-basics: Examples of how to download, upload or list specific objects on your server
- other/s3-events: Using AWS Lambda or MinIO notifications (for event based data processing)
- other/misc: Example of automating the use of the MDF4 converters and misc tools


Installation

  • Install Python 3.9.13 for Windows (32 bit/64 bit) or Linux (enable 'Add to PATH')
  • Download this project as a zip via the green button and unzip it
  • Open the folder with the requirements.txt file and enter below in your command prompt:
Windows
python -m venv env & env\Scripts\activate & pip install -r requirements.txt
python script_to_run.py
Linux
python -m venv env && source env/bin/activate && pip install -r requirements.txt
python script_to_run.py

If you later need to re-activate the virtual environment, use env\Scripts\activate.


Sample data (MDF4 & DBC)

The various folders include sample log files and DBC files. Once you've tested a script with the sample data, you can replace it with your own.


Usage info

  • Some example folders contain their own README.md files for extra information
  • These example scripts are designed to be minimal and to help you get started - not for production
  • Some S3 scripts use hardcoded credentials to ease testing - for production see e.g. this guide

Which API modules to use?

There are many ways that you can work with the data from your CANedge devices. Most automation use cases involve fetching data from a specific device and time period - and DBC decoding this into a dataframe for further processing. Here, we recommend to look at the examples from the data-processing/ folder. These examples use our custom modules designed for use with the CANedge: The mdf_iter (for loading MDF4 data), the canedge_browser (for fetching specific data locally or from S3) and the can_decoder (for DBC decoding the data). In combination, these modules serve to support most use cases.

If you have needs that are not covered by these modules, you can check out the other examples using the asammdf API, the AWS/MinIO S3 API and our MDF4 converters.

If in doubt, contact us for sparring.


About the CANedge

For details on installation and how to get started, see the documentation:


Contribution & support

Feature suggestions, pull requests or questions are welcome!

You can contact us at CSS Electronics below: