# openethercatsociety/soem architecture

> Architecture diagram of the GitHub repository openethercatsociety/soem, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openethercatsociety/soem
- Repository: https://github.com/openethercatsociety/soem

## Overview

SOEM is a C library for building EtherCAT MainDevices. An application uses the public SOEM interface to access master operations and protocol-specific capabilities; the master communicates with EtherCAT slaves through a platform-specific NIC driver. The source index confirms the shared OS abstraction and several driver dependencies. The README is brief, and many domain implementations were not sampled, so protocol-stage links beyond documented includes are omitted rather than inferred.

Main entry points: [`include/soem/soem.h`](https://github.com/openethercatsociety/soem/blob/master/include/soem/soem.h) (SOEM interface), [`osal/osal.h`](https://github.com/openethercatsociety/soem/blob/master/osal/osal.h) (OS abstraction), [`src/ec_main.c`](https://github.com/openethercatsociety/soem/blob/master/src/ec_main.c) (Master operations), [`oshw/rtk/nicdrv.c`](https://github.com/openethercatsociety/soem/blob/master/oshw/rtk/nicdrv.c) (RTK NIC driver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_soem_api["SOEM interface<br/>[soem.h]"]
end

subgraph group_master["Master Protocol"]
  node_master_ops["Master operations<br/>[ec_main.c]"]
  node_base["Base services<br/>[ec_base.c]"]
  node_configuration["Slave configuration<br/>[ec_config.c]"]
  node_distributed_clocks["Distributed clocks<br/>[ec_dc.c]"]
  node_coe["CoE services<br/>[ec_coe.c]"]
  node_eoe["EoE services<br/>[ec_eoe.c]"]
  node_foe["FoE services<br/>[ec_foe.c]"]
  node_soe["SoE services<br/>[ec_soe.c]"]
  node_printing["Print utilities<br/>[ec_print.c]"]
end

subgraph group_platform["Platform I/O"]
  node_linux_driver["Linux NIC driver<br/>[nicdrv.c]"]
  node_windows_driver["Windows NIC driver<br/>[nicdrv.c]"]
  node_rtk_driver["RTK NIC driver<br/>[nicdrv.c]"]
end

subgraph group_runtime["Runtime Support"]
  node_osal["OS abstraction<br/>[osal.h]"]
end

node_application(("MainDevice application"))
node_slaves{{"EtherCAT slaves"}}

node_application -->|"uses"| node_soem_api
node_soem_api -->|"exposes"| node_master_ops
node_soem_api -->|"exposes"| node_base
node_soem_api -->|"exposes"| node_configuration
node_soem_api -->|"exposes"| node_distributed_clocks
node_soem_api -->|"exposes"| node_coe
node_soem_api -->|"exposes"| node_eoe
node_soem_api -->|"exposes"| node_foe
node_soem_api -->|"exposes"| node_soe
node_soem_api -->|"exposes"| node_printing
node_master_ops -->|"references"| node_rtk_driver
node_master_ops -->|"uses"| node_osal
node_coe -->|"uses"| node_osal
node_eoe -->|"uses"| node_osal
node_linux_driver -->|"uses"| node_osal
node_windows_driver -->|"references"| node_soem_api
node_rtk_driver -->|"uses"| node_osal
node_linux_driver -.->|"exchanges frames"| node_slaves
node_windows_driver -.->|"exchanges frames"| node_slaves
node_rtk_driver -.->|"exchanges frames"| node_slaves

click node_soem_api "https://github.com/openethercatsociety/soem/blob/master/include/soem/soem.h"
click node_master_ops "https://github.com/openethercatsociety/soem/blob/master/src/ec_main.c"
click node_base "https://github.com/openethercatsociety/soem/blob/master/src/ec_base.c"
click node_configuration "https://github.com/openethercatsociety/soem/blob/master/src/ec_config.c"
click node_distributed_clocks "https://github.com/openethercatsociety/soem/blob/master/src/ec_dc.c"
click node_coe "https://github.com/openethercatsociety/soem/blob/master/src/ec_coe.c"
click node_eoe "https://github.com/openethercatsociety/soem/blob/master/src/ec_eoe.c"
click node_foe "https://github.com/openethercatsociety/soem/blob/master/src/ec_foe.c"
click node_soe "https://github.com/openethercatsociety/soem/blob/master/src/ec_soe.c"
click node_printing "https://github.com/openethercatsociety/soem/blob/master/src/ec_print.c"
click node_linux_driver "https://github.com/openethercatsociety/soem/blob/master/oshw/linux/nicdrv.c"
click node_windows_driver "https://github.com/openethercatsociety/soem/blob/master/oshw/win32/nicdrv.c"
click node_rtk_driver "https://github.com/openethercatsociety/soem/blob/master/oshw/rtk/nicdrv.c"
click node_osal "https://github.com/openethercatsociety/soem/blob/master/osal/osal.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_soem_api toneBlue
class node_master_ops,node_base,node_configuration,node_distributed_clocks,node_coe,node_eoe,node_foe,node_soe,node_printing toneAmber
class node_linux_driver,node_windows_driver,node_rtk_driver toneMint
class node_osal toneRose
class node_application,node_slaves toneIndigo
```

## Components

### Public API

- [SOEM interface](https://github.com/openethercatsociety/soem/blob/master/include/soem/soem.h): `include/soem/soem.h`

### Master Protocol

- [Master operations](https://github.com/openethercatsociety/soem/blob/master/src/ec_main.c): `src/ec_main.c`
- [Base services](https://github.com/openethercatsociety/soem/blob/master/src/ec_base.c): `src/ec_base.c`
- [Slave configuration](https://github.com/openethercatsociety/soem/blob/master/src/ec_config.c): `src/ec_config.c`
- [Distributed clocks](https://github.com/openethercatsociety/soem/blob/master/src/ec_dc.c): `src/ec_dc.c`
- [CoE services](https://github.com/openethercatsociety/soem/blob/master/src/ec_coe.c): `src/ec_coe.c`
- [EoE services](https://github.com/openethercatsociety/soem/blob/master/src/ec_eoe.c): `src/ec_eoe.c`
- [FoE services](https://github.com/openethercatsociety/soem/blob/master/src/ec_foe.c): `src/ec_foe.c`
- [SoE services](https://github.com/openethercatsociety/soem/blob/master/src/ec_soe.c): `src/ec_soe.c`
- [Print utilities](https://github.com/openethercatsociety/soem/blob/master/src/ec_print.c): `src/ec_print.c`

### Platform I/O

- [Linux NIC driver](https://github.com/openethercatsociety/soem/blob/master/oshw/linux/nicdrv.c): `oshw/linux/nicdrv.c`
- [Windows NIC driver](https://github.com/openethercatsociety/soem/blob/master/oshw/win32/nicdrv.c): `oshw/win32/nicdrv.c`
- [RTK NIC driver](https://github.com/openethercatsociety/soem/blob/master/oshw/rtk/nicdrv.c): `oshw/rtk/nicdrv.c`

### Runtime Support

- [OS abstraction](https://github.com/openethercatsociety/soem/blob/master/osal/osal.h): `osal/osal.h`

### Other components

- **MainDevice application**
- **EtherCAT slaves**

## Connections

- MainDevice application → SOEM interface: uses (evidence: `README.md`)
- SOEM interface → Master operations: exposes (evidence: `include/soem/soem.h`)
- SOEM interface → Base services: exposes (evidence: `include/soem/soem.h`)
- SOEM interface → Slave configuration: exposes (evidence: `include/soem/soem.h`)
- SOEM interface → Distributed clocks: exposes (evidence: `include/soem/soem.h`)
- SOEM interface → CoE services: exposes (evidence: `include/soem/soem.h`)
- SOEM interface → EoE services: exposes (evidence: `include/soem/soem.h`)
- SOEM interface → FoE services: exposes (evidence: `include/soem/soem.h`)
- SOEM interface → SoE services: exposes (evidence: `include/soem/soem.h`)
- SOEM interface → Print utilities: exposes (evidence: `include/soem/soem.h`)
- Master operations → RTK NIC driver: references (evidence: `src/ec_main.c`)
- Master operations → OS abstraction: uses (evidence: `src/ec_main.c`)
- CoE services → OS abstraction: uses (evidence: `src/ec_coe.c`)
- EoE services → OS abstraction: uses (evidence: `src/ec_eoe.c`)
- Linux NIC driver → OS abstraction: uses (evidence: `oshw/linux/nicdrv.c`)
- Windows NIC driver → SOEM interface: references (evidence: `oshw/win32/nicdrv.c`)
- RTK NIC driver → OS abstraction: uses (evidence: `oshw/rtk/nicdrv.c`)
- Linux NIC driver → EtherCAT slaves: exchanges frames
- Windows NIC driver → EtherCAT slaves: exchanges frames
- RTK NIC driver → EtherCAT slaves: exchanges frames
