Metadata-Version: 2.3
Name: can-logger
Version: 0.4.0
Summary: 
License: MIT
Author: Adam Matusiak
Author-email: adammatusiak@icloude.com
Requires-Python: >=3.12,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: aiosqlite (>=0.21.0,<0.22.0)
Requires-Dist: black (>=25.1.0,<26.0.0)
Requires-Dist: cantools (>=40.2.1,<41.0.0)
Requires-Dist: click (>=8.1.8,<9.0.0)
Requires-Dist: poethepoet (>=0.34.0,<0.35.0)
Requires-Dist: pytest (>=8.3.5,<9.0.0)
Requires-Dist: pytest-asyncio (>=0.23.6,<0.24.0)
Requires-Dist: pytest-mock (>=3.14.0,<4.0.0)
Description-Content-Type: text/markdown

# CAN Logger

**CAN Logger** is a tool for listening to and logging CAN/CAN-FD frames into an SQLite database. It allows easy monitoring of CAN bus traffic, message analysis, and later filtering and browsing of recorded messages.

## How it works

- The program listens on a selected CAN interface (e.g., `vcan0`, `can0`) and displays received frames in a readable format.
- Each received message is saved to an SQLite database (`can_messages.db` by default or as specified by the user).
- You can filter and browse saved messages using tools from the `can_logger/database_tools` directory (e.g., by date, arbitration ID, or last N messages).

## Quick start

First, create a virtual CAN interface:

```shell
# Install dependencies
sudo apt install can-utils iproute2

# Load the vcan module
sudo modprobe vcan

# Create a virtual CAN-FD interface
sudo ip link add dev vcan0 type vcan
sudo ip link set vcan0 mtu 72 # Set MTU for CAN-FD
sudo ip link set vcan0 up

# Verify the interface
ip link show vcan0
```

Then you can run the containers:

```shell
docker compose up --build
```

## Running the logger manually

You can run the logger directly with Python:

```shell
python3 -m can_logger.sniffer -i vcan0
```

or using the asynchronous version:

```shell
python3 -m can_logger --interface vcan0
```

## Browsing the database

To browse and filter saved messages, use:

```shell
python3 -m can_logger.database_tools -d can_messages.db --mode all
python3 -m can_logger.database_tools -d can_messages.db --mode last -n 20
python3 -m can_logger.database_tools -d can_messages.db --mode id --arbitration-id 123
python3 -m can_logger.database_tools -d can_messages.db --mode date --date 2024-06-03
```

## Features

- CAN/CAN-FD listening and logging to SQLite database
- Support for various message filtering modes
- Easy to run in a Docker container or locally
- Simple CLI interface based on [Click](https://click.palletsprojects.com/)

---

For more information, see the source code and the `can_logger/database_tools` directory.
