Skip to main content

Open-source macOS/Linux driver for SM2 Pro (Scanmatik 2 Pro) J2534 CAN adapter

Project description

SM2CAN — Open-Source Driver for SM2 Pro CAN Adapters on macOS & Linux

License: MIT Python 3.8+ PyPI CI

SM2CAN is a userspace USB driver that enables SM2 Pro (and compatible) J2534 CAN adapters to work on macOS and Linux — platforms the manufacturer's driver does not support. It integrates with python-can, making it a drop-in replacement for any CAN interface.

Disclaimer: This project is not affiliated with, endorsed by, or sponsored by the manufacturer of the SM2 Pro hardware. All trademarks are property of their respective owners. This driver was developed using clean room reverse engineering of a legitimately purchased device for the sole purpose of interoperability. See LEGAL.md for full details.

Project Status

Component Status Notes
USB transport (libusb) ✅ Complete Tested on macOS 13+ and Ubuntu 22.04+
USB hardware detection ✅ Complete Auto-detects VID 0x20A2 PID 0x0001
Protocol decoder 🔧 Needs capture Community USB captures welcome
Protocol auto-detection ✅ Scaffolded Tries multiple frame format variants
python-can Bus interface ✅ Complete interface='sm2' via entry point
CLI tools ✅ Complete sm2can probe, monitor, send
USB capture analysis ✅ Complete Parses pcap/pcapng from USBPcap
Homebrew formula ✅ Ready brew tap aldoguzman97/sm2can
Linux udev rules ✅ Included Non-root USB access
Bluetooth SPP transport 📋 Planned Architecture ready for future support

How You Can Help

One USB capture from a Windows session completes this driver. If you can run Wireshark + USBPcap on Windows while connected to a vehicle:

pip install sm2can
sm2can-capture guide     # Step-by-step capture instructions
sm2can-capture decode mycapture.pcapng  # Auto-analyzes the protocol

See CONTRIBUTING.md for the 5-minute capture guide.

Installation

Homebrew (macOS)

brew tap aldoguzman97/sm2can
brew install sm2can

pip (macOS & Linux)

pip install sm2can

From source

git clone https://github.com/aldoguzman97/sm2can.git
cd sm2can
pip install -e ".[dev]"

Prerequisites

Platform Command
macOS brew install libusb
Debian/Ubuntu sudo apt install libusb-1.0-0-dev
Fedora/RHEL sudo dnf install libusb1-devel
Arch sudo pacman -S libusb

Python 3.8 or later required.

Linux: USB Permissions

To use without sudo:

sudo cp scripts/99-sm2pro.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger
# Log out and back in (user must be in 'plugdev' group)

Quick Start

Detect hardware

sm2can probe

Monitor CAN bus

sm2can monitor --bitrate 500000

Send a CAN frame

sm2can send 0x7DF 0201000000000000 --bitrate 500000

Use with python-can

import can

# SM2CAN registers as a python-can interface plugin automatically
bus = can.Bus(interface='sm2', channel=0, bitrate=500000)

# Receive
msg = bus.recv(timeout=1.0)
if msg:
    print(f"0x{msg.arbitration_id:03X}: {msg.data.hex()}")

# Send
bus.send(can.Message(
    arbitration_id=0x7DF,
    data=bytes([0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
))

bus.shutdown()

Direct API

from sm2can import SM2Device

with SM2Device() as dev:
    dev.open(bitrate=500000)
    dev.send(0x7DF, bytes([0x02, 0x01, 0x00, 0, 0, 0, 0, 0]))
    frame = dev.recv(timeout=1.0)
    if frame:
        print(f"0x{frame.arbitration_id:03X}: {frame.data.hex()}")

Supported Hardware

Device USB ID Interface Status
SM2 Pro (original) 20A2:0001 USB + BT Primary target
SM2 Pro (clones) 20A2:0001 USB Should work (same USB protocol)

Power Requirements

Important: The SM2 Pro requires 12V on the OBD-II connector to boot its application firmware. On USB 5V power alone, the microcontroller enumerates on the bus but the CAN transceiver and command handler do not start. Connect to a vehicle with ignition ON, or supply 12V externally.

OBD-II bench power pinout:

Pin Function
16 +12V (battery)
4 Chassis ground
5 Signal ground

A 12V / 1A wall adapter wired to these pins is sufficient.

Architecture

┌──────────────────────────────────────────────────────────┐
│  Your Application / python-can / opendbc / UDS client    │
├──────────────────────────────────────────────────────────┤
│  SM2Bus (can_interface.py)                               │
│  python-can BusABC — registered via entry point          │
├──────────────────────────────────────────────────────────┤
│  SM2Device (device.py)                                   │
│  High-level: open / close / send / recv / background RX  │
├──────────────────────────────────────────────────────────┤
│  ProtocolCodec (protocol.py)                             │
│  Encode / decode binary protocol frames                  │
├────────────────────┬─────────────────────────────────────┤
│  USBTransport      │  BluetoothTransport (planned)       │
│  (usb_transport.py)│  (bluetooth_transport.py)           │
│  Bulk EP via libusb│  SPP via platform-native APIs       │
├────────────────────┴─────────────────────────────────────┤
│  Hardware: EP 0x02 OUT / EP 0x81 IN / 64-byte packets   │
└──────────────────────────────────────────────────────────┘

Why userspace instead of a kernel driver? A kernel extension (kext on macOS, .ko on Linux) requires code signing, kernel version compatibility, and administrator installation. A userspace driver via libusb installs with pip, works everywhere, and cannot crash your kernel. The SM2 Pro's simple 2-endpoint bulk design is ideal for this approach.

Roadmap

  • USB transport layer
  • Protocol codec with auto-detection framework
  • python-can Bus interface
  • CLI tools (probe, monitor, send)
  • USB capture decoder for protocol analysis
  • Homebrew formula
  • Linux udev rules
  • Complete protocol specification (pending community captures)
  • Bluetooth SPP transport
  • CAN-FD support (if hardware supports it)
  • ISO-TP (ISO 15765) pass-through
  • SAE J2534 API shim layer

Contributing

See CONTRIBUTING.md. The most impactful contribution is a USB capture from Windows — one file completes the protocol specification for everyone.

Legal

This project uses clean room reverse engineering to achieve interoperability with legitimately purchased hardware. No proprietary code, firmware, or documentation was used. See LEGAL.md for full details including applicable case law.

License

MIT — see LICENSE.

Copyright (c) 2026 Aldo Guzman (@aldoguzman97)

Acknowledgments

  • pyusb — Cross-platform USB access
  • python-can — CAN bus abstraction
  • libusb — Userspace USB I/O
  • Everyone who contributes USB captures

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

sm2can-0.1.2.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

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

sm2can-0.1.2-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file sm2can-0.1.2.tar.gz.

File metadata

  • Download URL: sm2can-0.1.2.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for sm2can-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e6ed2f1bc9fe412dcb8580078090d82f084d9cae2d67403072c450b867e20df3
MD5 fad509d937d7f797d338c887f180dc06
BLAKE2b-256 0200b071f71a275257c7254cbd9932533de01fdba12cde33b9dc40e0301e57c0

See more details on using hashes here.

File details

Details for the file sm2can-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sm2can-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for sm2can-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 31c849289fbca9674fc6a6a5338732c4006c04080a358a6be2f3544e344896c1
MD5 1ec254db2661766760d50e56a78b6b2f
BLAKE2b-256 ffe8930f5caf702ab10ccbd758192d96cc1529b2a8d1ceed2647ce53b8e1ef6a

See more details on using hashes here.

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