Swiftpack.co - Automotive-Swift/ECUmulator as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Automotive-Swift.
Automotive-Swift/ECUmulator 0.5.1
Emulating Electronic Control Units (ECU)
⭐️ 1
🕓 2 weeks ago
iOS macOS linux
.package(url: "https://github.com/Automotive-Swift/ECUmulator.git", from: "0.5.1")


Emulates Electronic Control Units, typically found in automotive vehicles.


ECUmulator is an invaluable tool for anyone who is developing diagnostics software.

ECUmulator can emulate a number of ECUs with basic support for OBD2, UDS, and KWP. ECUs are configured via a JSON file, which contains the basic features of the ECU, such as

  • Arbitration IDs,
  • Memory Layout,
  • OBD2 measurements,
  • Identifiers,
  • etc.

This package comes with two products:

  1. ECUmulation: The ECU emulation library. This is for integration into your own projects.
  2. ECUmulator: A standalone command line tool.


There are three ways to use ECUmulator, interactively, attached to a real CAN bus, and ELM327 compatible.

Use interactively

Spin an interactive command-line and communicate directly by "injecting" CAN messages.

$ ./ECUmulator -i powertrain:./Resources/ptc-obd2.json
ECUmulator online.

The format to send a CAN message is <id>#<message>. Here, we send the OBD2 PID 0100 to the ECU with the arbitration id 7E0.

> 7e0#020100
7E8   [8]   06 41 00 BF 9F A8 93 AA 

Use attached to a real CANbus

Listen and respond via a CANbus interface:

$ ./ECUmulator -a can0@500000 powertrain:./Resources/ptc-obd2.json

Supported devices:

  • macOS: Rusoku TouCAN
  • Linux: Every SocketCAN-compliant interface

Use in an ELM327-compatible way

When developing diagnostic software, you might not have a CAN bus around. In that case, it would be handy, if the emulation could also provide a simulated OBD2-to-RS232-adapter. Congratulations, we got you covered: Hop over to ELMpersonator, which provides a serial OBD2 interface adapter emulator (think ELM327, STN11xx, STN22xx, etc.) and allows you to attach ECUmulator ECUs to the simulated bus.


I have developed this software in order to implement ECU reprogramming apps. Without this, I could have never completed the task and would have probably bricked hundreds of ECUs.

The diagnostic session implementation is courtesy Swift-UDS which handles most of OBD2, KWP, and UDS.

I consider this being a beta, but don't use this in production yet, it may change a lot before 1.0.

Next things to tackle

  • ☐ Internal: Rework to use the bidirectional ISOTP.Transceiver instead of the old Transmitter and Receiver combo.
  • ☐ Unit tests
  • ☐ Send out periodic messages to other devices (mimicking real ECUs)
  • ☐ Implement UDS service 0x28 (external communication)
  • ☐ Implement clearing DTC
  • ☐ Enable custom responses for custom services


Feel free to use as you see fit under the terms of the MIT. If this is helpful to you, please drop me a note. I always welcome contributions in any form!


Stars: 1
Last commit: 4 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics