Skip to content
Ralf Steinert edited this page Nov 22, 2026 · 2 revisions

canopen-sim simulates CANopen devices that behave: a servo drive that walks through its power state machine, ramps to a target velocity and goes into FAULT when you inject one; an I/O module whose inputs follow its outputs or a signal you define; a multi-turn encoder that counts. They speak NMT with heartbeat, SDO (expedited, segmented, block), PDOs (event, timer and SYNC driven), SYNC and EMCY, on a virtual CAN bus (any platform) or on SocketCAN such as vcan0 (Linux). So you can develop and test a CANopen master, a gateway or your own commissioning scripts without a drive on the bench, also in CI.

What it is for

  • Master and gateway code before the hardware is there, or while the machine runs and nobody lets you touch it.
  • Running CANopen code in CI. A bench starts in milliseconds in a pytest fixture, on every OS; on Linux runners also on a real vcan0.
  • Testing the unhappy paths. Lost heartbeats, SDO aborts and timeouts, a node that restarts behind your back, dropped or frozen PDOs, EMCY messages, a drive that trips.

Where to start

If you want to … read
serve a drive and watch it on candump Getting started
make your master survive real-world failures Fault injection recipes
describe your own device Custom profiles
put it into automated tests Testing in CI
look something up the README (reference)

Devices

profile what it is follows
generic-drive servo drive: power state machine, profile velocity, profile position, homing (methods 35 and 37) public CANopen manuals of Kollmorgen (AKD), SEW-EURODRIVE and Synapticon (SOMANET)
generic-io 8 DI, 8 DO, 2 AI, 2 AO; outputs loop back to the inputs CiA 401-1 v3.1.0
generic-encoder multi-turn rotary encoder, 4096 steps per revolution, class C1 CiA 406 v4.1.0

canopen-sim map PROFILE shows each profile's objects, PDO mappings, sources and limits.

Cross-checks

The test suite cross-checks the simulator against the independent canopen Python library, including a full drive commissioning with its BaseNode402, and CI runs it on Linux, Windows and macOS plus a job on a real vcan0. It has not been tested against a real CANopen master or device, and it is not certified by CiA.

Clone this wiki locally