ethercat-master 0.1.9__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. ethercat_master-0.2.0/.github/workflows/release.yml +150 -0
  2. ethercat_master-0.2.0/.gitignore +55 -0
  3. ethercat_master-0.2.0/AGENTS.md +45 -0
  4. ethercat_master-0.2.0/CMakeLists.txt +10 -0
  5. ethercat_master-0.2.0/LICENSE +674 -0
  6. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/PKG-INFO +378 -370
  7. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/README.md +342 -336
  8. ethercat_master-0.2.0/benchmarks/__init__.py +0 -0
  9. ethercat_master-0.2.0/benchmarks/common.py +57 -0
  10. ethercat_master-0.2.0/benchmarks/pdo_loop.py +79 -0
  11. ethercat_master-0.2.0/benchmarks/thread_isolation_effect.py +88 -0
  12. ethercat_master-0.2.0/benchmarks/timer_resolution_effect.py +52 -0
  13. ethercat_master-0.2.0/benchmarks/timing_precision.py +50 -0
  14. ethercat_master-0.2.0/ci/make_wheel.py +102 -0
  15. ethercat_master-0.2.0/ci/mingw-toolchain.cmake +13 -0
  16. ethercat_master-0.2.0/csrc/ecm.c +258 -0
  17. ethercat_master-0.2.0/docs/images/01-bus-overview.png +0 -0
  18. ethercat_master-0.2.0/docs/images/02-network-test.png +0 -0
  19. ethercat_master-0.2.0/docs/images/03-bus-discovery-mixed.png +0 -0
  20. ethercat_master-0.2.0/docs/web-interface.md +93 -0
  21. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/ethercat_master/__init__.py +9 -2
  22. ethercat_master-0.2.0/ethercat_master/_backend.py +11 -0
  23. ethercat_master-0.2.0/ethercat_master/_soem.py +620 -0
  24. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/ethercat_master/bus.py +1651 -1514
  25. ethercat_master-0.2.0/ethercat_master/webgui/index.html +440 -0
  26. ethercat_master-0.2.0/ethercat_master/webgui/style.css +179 -0
  27. ethercat_master-0.2.0/examples/beckhoff.py +55 -0
  28. ethercat_master-0.2.0/examples/discover.py +33 -0
  29. ethercat_master-0.2.0/examples/mixed_bus.py +48 -0
  30. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/pyproject.toml +64 -66
  31. ethercat_master-0.2.0/tests/__init__.py +0 -0
  32. ethercat_master-0.2.0/tests/test_bus.py +414 -0
  33. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/tests/test_pdo.py +58 -58
  34. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/tests/test_slave.py +22 -22
  35. ethercat_master-0.2.0/third_party/SOEM/.clang-format +26 -0
  36. ethercat_master-0.2.0/third_party/SOEM/CMakeLists.txt +191 -0
  37. ethercat_master-0.2.0/third_party/SOEM/CMakePresets.json +39 -0
  38. ethercat_master-0.2.0/third_party/SOEM/LICENSE.md +25 -0
  39. ethercat_master-0.2.0/third_party/SOEM/README.md +29 -0
  40. ethercat_master-0.2.0/third_party/SOEM/cmake/AddENI.cmake +39 -0
  41. ethercat_master-0.2.0/third_party/SOEM/cmake/Linux.cmake +43 -0
  42. ethercat_master-0.2.0/third_party/SOEM/cmake/Windows.cmake +75 -0
  43. ethercat_master-0.2.0/third_party/SOEM/cmake/rt-kernel.cmake +52 -0
  44. ethercat_master-0.2.0/third_party/SOEM/cmake/tools/FindSphinx.cmake +16 -0
  45. ethercat_master-0.2.0/third_party/SOEM/contrib/cmake/Modules/Platform/rtems.cmake +22 -0
  46. ethercat_master-0.2.0/third_party/SOEM/contrib/cmake/rtems.cmake +34 -0
  47. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/erika/README.md +4 -0
  48. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/erika/osal.c +106 -0
  49. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/erika/osal_defs.h +42 -0
  50. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/intime/osal.c +89 -0
  51. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/intime/osal_defs.h +44 -0
  52. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/macosx/osal.c +147 -0
  53. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/macosx/osal_defs.h +39 -0
  54. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/rtems/osal.c +147 -0
  55. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/rtems/osal_defs.h +39 -0
  56. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/vxworks/osal.c +188 -0
  57. ethercat_master-0.2.0/third_party/SOEM/contrib/osal/vxworks/osal_defs.h +30 -0
  58. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/erika/nicdrv.c +541 -0
  59. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/erika/nicdrv.h +107 -0
  60. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/erika/oshw.c +82 -0
  61. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/erika/oshw.h +31 -0
  62. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/intime/nicdrv.c +695 -0
  63. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/intime/nicdrv.h +117 -0
  64. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/intime/oshw.c +48 -0
  65. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/intime/oshw.h +31 -0
  66. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/macosx/nicdrv.c +597 -0
  67. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/macosx/nicdrv.h +106 -0
  68. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/macosx/oshw.c +117 -0
  69. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/macosx/oshw.h +31 -0
  70. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/rtems/nicdrv.c +657 -0
  71. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/rtems/nicdrv.h +106 -0
  72. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/rtems/oshw.c +117 -0
  73. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/rtems/oshw.h +31 -0
  74. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/vxworks/nicdrv.c +930 -0
  75. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/vxworks/nicdrv.h +116 -0
  76. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/vxworks/oshw.c +61 -0
  77. ethercat_master-0.2.0/third_party/SOEM/contrib/oshw/vxworks/oshw.h +23 -0
  78. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_base.h +42 -0
  79. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_coe.h +73 -0
  80. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_config.h +31 -0
  81. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_dc.h +27 -0
  82. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_eoe.h +217 -0
  83. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_foe.h +27 -0
  84. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_main.h +627 -0
  85. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_options.h.in +128 -0
  86. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_print.h +30 -0
  87. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_soe.h +121 -0
  88. ethercat_master-0.2.0/third_party/SOEM/include/soem/ec_type.h +571 -0
  89. ethercat_master-0.2.0/third_party/SOEM/include/soem/soem.h +28 -0
  90. ethercat_master-0.2.0/third_party/SOEM/osal/linux/osal.c +154 -0
  91. ethercat_master-0.2.0/third_party/SOEM/osal/linux/osal_defs.h +46 -0
  92. ethercat_master-0.2.0/third_party/SOEM/osal/osal.h +222 -0
  93. ethercat_master-0.2.0/third_party/SOEM/osal/rtk/osal.c +109 -0
  94. ethercat_master-0.2.0/third_party/SOEM/osal/rtk/osal_defs.h +45 -0
  95. ethercat_master-0.2.0/third_party/SOEM/osal/win32/osal.c +176 -0
  96. ethercat_master-0.2.0/third_party/SOEM/osal/win32/osal_defs.h +51 -0
  97. ethercat_master-0.2.0/third_party/SOEM/oshw/linux/nicdrv.c +639 -0
  98. ethercat_master-0.2.0/third_party/SOEM/oshw/linux/nicdrv.h +108 -0
  99. ethercat_master-0.2.0/third_party/SOEM/oshw/linux/oshw.c +116 -0
  100. ethercat_master-0.2.0/third_party/SOEM/oshw/linux/oshw.h +31 -0
  101. ethercat_master-0.2.0/third_party/SOEM/oshw/rtk/nicdrv.c +589 -0
  102. ethercat_master-0.2.0/third_party/SOEM/oshw/rtk/nicdrv.h +100 -0
  103. ethercat_master-0.2.0/third_party/SOEM/oshw/rtk/oshw.c +54 -0
  104. ethercat_master-0.2.0/third_party/SOEM/oshw/rtk/oshw.h +37 -0
  105. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/nicdrv.c +602 -0
  106. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/nicdrv.h +111 -0
  107. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/oshw.c +120 -0
  108. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/oshw.h +31 -0
  109. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/Packet32.h +359 -0
  110. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/Win32-Extensions.h +113 -0
  111. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/bittypes.h +137 -0
  112. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/ip6_misc.h +163 -0
  113. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap/bluetooth.h +48 -0
  114. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap/bpf.h +934 -0
  115. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap/namedb.h +89 -0
  116. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap/pcap.h +407 -0
  117. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap/sll.h +129 -0
  118. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap/usb.h +90 -0
  119. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap/vlan.h +46 -0
  120. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap-bpf.h +47 -0
  121. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap-namedb.h +42 -0
  122. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap-stdinc.h +93 -0
  123. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/pcap.h +45 -0
  124. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Include/remote-ext.h +444 -0
  125. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Lib/Packet.lib +0 -0
  126. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Lib/libpacket.a +0 -0
  127. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Lib/libwpcap.a +0 -0
  128. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Lib/wpcap.lib +0 -0
  129. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Lib/x64/Packet.lib +0 -0
  130. ethercat_master-0.2.0/third_party/SOEM/oshw/win32/wpcap/Lib/x64/wpcap.lib +0 -0
  131. ethercat_master-0.2.0/third_party/SOEM/scripts/eniconv.py +231 -0
  132. ethercat_master-0.2.0/third_party/SOEM/soem.spdx +19 -0
  133. ethercat_master-0.2.0/third_party/SOEM/src/ec_base.c +534 -0
  134. ethercat_master-0.2.0/third_party/SOEM/src/ec_coe.c +1437 -0
  135. ethercat_master-0.2.0/third_party/SOEM/src/ec_config.c +1735 -0
  136. ethercat_master-0.2.0/third_party/SOEM/src/ec_dc.c +428 -0
  137. ethercat_master-0.2.0/third_party/SOEM/src/ec_eoe.c +701 -0
  138. ethercat_master-0.2.0/third_party/SOEM/src/ec_foe.c +460 -0
  139. ethercat_master-0.2.0/third_party/SOEM/src/ec_main.c +2798 -0
  140. ethercat_master-0.2.0/third_party/SOEM/src/ec_print.c +378 -0
  141. ethercat_master-0.2.0/third_party/SOEM/src/ec_soe.c +401 -0
  142. ethercat_master-0.1.9/ethercat_master/webgui/index.html +0 -430
  143. ethercat_master-0.1.9/ethercat_master/webgui/style.css +0 -57
  144. ethercat_master-0.1.9/ethercat_master.egg-info/PKG-INFO +0 -370
  145. ethercat_master-0.1.9/ethercat_master.egg-info/SOURCES.txt +0 -21
  146. ethercat_master-0.1.9/ethercat_master.egg-info/dependency_links.txt +0 -1
  147. ethercat_master-0.1.9/ethercat_master.egg-info/entry_points.txt +0 -2
  148. ethercat_master-0.1.9/ethercat_master.egg-info/requires.txt +0 -7
  149. ethercat_master-0.1.9/ethercat_master.egg-info/top_level.txt +0 -1
  150. ethercat_master-0.1.9/setup.cfg +0 -4
  151. ethercat_master-0.1.9/tests/test_bus.py +0 -199
  152. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/ethercat_master/ethercat_config.json +0 -0
  153. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/ethercat_master/exceptions.py +0 -0
  154. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/ethercat_master/network_test.py +0 -0
  155. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/ethercat_master/pdo.py +0 -0
  156. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/ethercat_master/slave.py +0 -0
  157. {ethercat_master-0.1.9 → ethercat_master-0.2.0}/ethercat_master/webserver.py +0 -0
@@ -0,0 +1,150 @@
1
+ # Builds the SOEM shim for Linux + Windows, runs tests, packages the
2
+ # wheel/sdist and publishes to PyPI on version tags via trusted publishing
3
+ # (OIDC — no API token needed).
4
+ #
5
+ # PyPI setup (once, on pypi.org -> Publishing -> GitHub):
6
+ # owner = henschel-robotics, repository = python-ethercat-master,
7
+ # workflow filename = release.yml, environment = pypi
8
+ # Fallback without OIDC: create a repository secret PYPI_API_TOKEN and replace
9
+ # the gh-action-pypi-publish step with
10
+ # - run: pip install twine && twine upload --non-interactive -u __token__ -p "$PYPI_API_TOKEN" dist/*
11
+ # env: { PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} }
12
+
13
+ name: release
14
+
15
+ on:
16
+ push:
17
+ tags: ["v*", "[0-9]*.[0-9]*.[0-9]*"]
18
+ workflow_dispatch:
19
+
20
+ env:
21
+ LLVM_MINGW_VERSION: "20261117"
22
+ LLVM_MINGW_DIR: "llvm-mingw-20261117-ucrt-ubuntu-22.04-x86_64"
23
+
24
+ jobs:
25
+ # Compiles libecm.so (host gcc) and libecm.dll (llvm-mingw cross-compile).
26
+ natives:
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+
31
+ - uses: actions/setup-python@v5
32
+ with:
33
+ python-version: "3.12"
34
+
35
+ - run: pip install --quiet cmake ninja
36
+
37
+ - name: Install llvm-mingw
38
+ run: |
39
+ curl -fsSL "https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_VERSION}/${LLVM_MINGW_DIR}.tar.xz" | sudo tar -xJ -C /opt
40
+ echo "/opt/${LLVM_MINGW_DIR}/bin" >> "$GITHUB_PATH"
41
+
42
+ - name: Build libecm.so (Linux)
43
+ run: |
44
+ cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
45
+ cmake --build build-linux --target ecm
46
+ cp build-linux/libecm.so ethercat_master/
47
+
48
+ - name: Build libecm.dll (Windows cross-compile)
49
+ run: |
50
+ cmake -B build-win -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=ci/mingw-toolchain.cmake
51
+ cmake --build build-win --target ecm
52
+ cp build-win/libecm.dll ethercat_master/
53
+
54
+ - uses: actions/upload-artifact@v4
55
+ with:
56
+ name: natives
57
+ path: |
58
+ ethercat_master/libecm.so
59
+ ethercat_master/libecm.dll
60
+ retention-days: 7
61
+
62
+ # Editable install rebuilds the shim for the host, then run the test suite.
63
+ test:
64
+ runs-on: ubuntu-latest
65
+ steps:
66
+ - uses: actions/checkout@v4
67
+
68
+ - uses: actions/setup-python@v5
69
+ with:
70
+ python-version: "3.12"
71
+
72
+ - run: pip install --quiet -e .[dev]
73
+
74
+ - run: python -m pytest tests -q
75
+
76
+ # Reports lint findings without blocking the release. Broad `except
77
+ # Exception:` blocks and the mutable _AL_STATUS_CODES dict are intentional
78
+ # for fault tolerance — see AGENTS.md.
79
+ lint:
80
+ runs-on: ubuntu-latest
81
+ continue-on-error: true
82
+ steps:
83
+ - uses: actions/checkout@v4
84
+
85
+ - uses: actions/setup-python@v5
86
+ with:
87
+ python-version: "3.12"
88
+
89
+ - run: pip install --quiet ruff
90
+
91
+ - run: ruff check ethercat_master tests benchmarks
92
+
93
+ # One universal wheel: it ships libecm.so + libecm.dll and _soem picks the
94
+ # right one per platform. The sdist includes csrc/ + third_party/SOEM.
95
+ package:
96
+ runs-on: ubuntu-latest
97
+ needs: [natives, test]
98
+ steps:
99
+ - uses: actions/checkout@v4
100
+
101
+ - uses: actions/setup-python@v5
102
+ with:
103
+ python-version: "3.12"
104
+
105
+ - uses: actions/download-artifact@v4
106
+ with:
107
+ name: natives
108
+ path: ethercat_master/
109
+
110
+ - run: pip install --quiet build
111
+
112
+ - run: python ci/make_wheel.py
113
+
114
+ - run: python -m build --sdist --outdir dist
115
+
116
+ - uses: actions/upload-artifact@v4
117
+ with:
118
+ name: dist
119
+ path: dist/
120
+ retention-days: 7
121
+
122
+ # Publish on version tags (v0.2.0 / 0.2.0 must match project.version).
123
+ publish:
124
+ runs-on: ubuntu-latest
125
+ needs: package
126
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
127
+ environment: pypi
128
+ permissions:
129
+ id-token: write
130
+ steps:
131
+ - uses: actions/checkout@v4
132
+
133
+ - uses: actions/setup-python@v5
134
+ with:
135
+ python-version: "3.12"
136
+
137
+ - uses: actions/download-artifact@v4
138
+ with:
139
+ name: dist
140
+ path: dist/
141
+
142
+ - name: Check tag matches project.version
143
+ run: |
144
+ V=$(python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
145
+ if [ "${GITHUB_REF_NAME#v}" != "$V" ]; then
146
+ echo "Tag '$GITHUB_REF_NAME' does not match pyproject version '$V'" >&2
147
+ exit 1
148
+ fi
149
+
150
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,55 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ *.egg
6
+ .eggs/
7
+ .venv/
8
+ venv/
9
+ .pytest_cache/
10
+ .ruff_cache/
11
+ .mypy_cache/
12
+ .coverage
13
+ htmlcov/
14
+
15
+ # Packaging (build, scikit-build-core, cibuildwheel)
16
+ dist/
17
+ build/
18
+ build-*/
19
+ _skbuild/
20
+ wheelhouse/
21
+
22
+ # Local llvm-mingw toolchain (see .github/workflows/release.yml)
23
+ .llvm-mingw/
24
+
25
+ # CMake
26
+ CMakeCache.txt
27
+ CMakeFiles/
28
+ CMakeUserPresets.json
29
+ cmake-build-*/
30
+ cmake_install.cmake
31
+ compile_commands.json
32
+
33
+ # Built SOEM shim and native artifacts
34
+ ethercat_master/libecm.*
35
+ ethercat_master/ecm.*
36
+ *.o
37
+ *.obj
38
+ *.a
39
+ *.lib
40
+ *.exp
41
+ *.pdb
42
+ *.ilk
43
+ *.so
44
+ *.dylib
45
+ *.dll
46
+ # SOEM ships the wpcap import libraries needed for the Windows build
47
+ !third_party/SOEM/oshw/win32/wpcap/**
48
+
49
+ # IDEs / OS
50
+ .vs/
51
+ .vscode/
52
+ .idea/
53
+ *.swp
54
+ .DS_Store
55
+ Thumbs.db
@@ -0,0 +1,45 @@
1
+ # Agent Notes — python-ethercat-master
2
+
3
+ ## Verification commands
4
+
5
+ Run tests:
6
+ ```bash
7
+ python -m pytest tests -q
8
+ ```
9
+
10
+ Lint (new/modified files):
11
+ ```bash
12
+ ruff check ethercat_master tests benchmarks
13
+ ```
14
+
15
+ Build package:
16
+ ```bash
17
+ python -m build
18
+ ```
19
+
20
+ Install development dependencies:
21
+ ```bash
22
+ pip install -e .[dev]
23
+ ```
24
+
25
+ ## Benchmarks
26
+
27
+ Micro-benchmark timing policies without hardware:
28
+ ```bash
29
+ python -m benchmarks.timing_precision --cycle-ms 0.7 --iterations 2000 --policy precise
30
+ python -m benchmarks.timing_precision --cycle-ms 0.7 --iterations 2000 --policy balanced
31
+ python -m benchmarks.timing_precision --cycle-ms 0.7 --iterations 2000 --policy low_cpu
32
+ ```
33
+
34
+ Full PDO loop benchmark on real hardware:
35
+ ```bash
36
+ python -m benchmarks.pdo_loop --adapter "\\Device\\NPF_{...}" --cycle-ms 0.7 --duration 10
37
+ ```
38
+
39
+ ## Notes
40
+
41
+ - Sub-millisecond cycles rely on the `precise` timing policy (busy-yield). The `balanced` policy reduces CPU for cycles > ~2 ms but is still close to `precise` for sub-ms. `low_cpu` is only suitable when jitter requirements are relaxed or cycle times are well above the OS timer resolution.
42
+ - `EtherCATBus` now accepts `timing_stats=True` to collect per-loop timing statistics and `timing_policy="precise|balanced|low_cpu"`.
43
+ - `open()` and `_attempt_reconnect()` share `_bring_up()` (`_configure_pdos` → `_map_io` → SAFE-OP → `_configure_dc` → `_reach_op`). Subclass and override a step for device quirks instead of monkey-patching. Opt-in constructor options: `dc_sync0_cycle_ns`, `op_attempts`/`op_timeout_s`, `sdo_read_timeout_us`/`sdo_write_timeout_us`, `config_map_error_filter`, `reconnect_lock`, `on_connection_lost`/`on_reconnected`. Defaults preserve the previous behaviour.
44
+ - After (re)connect `bus.settled` is set once all slaves ran clean in OP for `settle_time_s`; applications should hold non-essential SDO traffic until then (blocking SDO calls stall the ProcessData thread and trip SM watchdogs). The state-check loop ignores SAFE-OP(+ERROR) recoveries within `recover_grace_s` of the last OP sighting.
45
+ - `ruff` still reports pre-existing broad `except Exception:` blocks and a mutable `_AL_STATUS_CODES` class dict; these were intentionally left unchanged to preserve existing fault-tolerance behavior.
@@ -0,0 +1,10 @@
1
+ cmake_minimum_required(VERSION 3.16)
2
+ project(ecm C)
3
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
5
+ set(SOEM_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
6
+ add_subdirectory(third_party/SOEM)
7
+ add_library(ecm SHARED csrc/ecm.c)
8
+ set_target_properties(ecm PROPERTIES C_VISIBILITY_PRESET hidden PREFIX "lib")
9
+ target_link_libraries(ecm PRIVATE soem)
10
+ install(TARGETS ecm LIBRARY DESTINATION ethercat_master RUNTIME DESTINATION ethercat_master)