Skip to content

easycat: clean shutdown, tunable timeouts, feed PDO through SAFE-OP - #461

Merged
leducp merged 1 commit into
leducp:masterfrom
amolypalshetkar:feat/easycat-shutdown-and-tunable-timeouts
Nov 16, 2026
Merged

leducp merged 1 commit into
leducp:masterfrom
amolypalshetkar:feat/easycat-shutdown-and-tunable-timeouts

Conversation

@amolypalshetkar

Copy link
Copy Markdown
Contributor

What

Three independent robustness improvements to the easycat example:

  1. Clean Ctrl-C — a SIGINT/SIGTERM handler sets a flag so the cyclic loop
    exits and main() returns, running the socket destructor.
  2. Tunable timeouts — the Link read timeouts and the Bus::init PDIO watchdog
    are now #ifndef-guarded #defines defaulting to the existing hard-coded
    values
    (KICKCAT_READ_TIMEOUT_MS=2, KICKCAT_RT_TIMEOUT_MS=10,
    KICKCAT_INIT_WATCHDOG_MS=100, where 0 disables the watchdog). A stock build is
    byte-for-byte behaviour-identical; a slow bus can be retuned at build time.
  3. Feed PDO across the OP transition — keep process data flowing during the
    SAFE-OP wait and don't insert slow per-slave state reads before the first cyclic
    exchange, so the SyncManager watchdog stays fed through the transition.

Why

  • Without the handler, Ctrl-C kills the process before destructors run; with the
    TAP transport that leaves the endpoint slot marked and the next run fails with
    TapSocket: Socket is full.
  • A software bus over a real NIC answers slower than hardware; the 2 ms / 100 ms
    defaults can expire mid-transition and the slaves trip
    SYNC_MANAGER_WATCHDOG when entering OP. Exposing the values as opt-in build
    knobs fixes that without changing defaults for everyone.

Testing

With the watchdog/timeouts raised at build time, all slaves reach and hold
OPERATIONAL with live PDO over a slow bus; with defaults, behaviour matches
upstream. SIGINT cleanly frees the TAP slot for an immediate rerun.

Notes

Defaults are deliberately unchanged — the knobs are for slow/non-RT transports and
are documented inline at the top of the file.

@amolypalshetkar
amolypalshetkar force-pushed the feat/easycat-shutdown-and-tunable-timeouts branch from 0a0a2e9 to e20a2a7 Compare November 14, 2026 10:56
- Handle SIGINT/SIGTERM so main() returns and the socket destructor runs,
  releasing a TAP slot (otherwise a rerun hits "Socket is full").
- Add --timeout, --rt-timeout and --watchdog arguments (milliseconds,
  defaulting to the existing 2 / 10 / 100 ms) so a slow software bus over
  a real NIC can be retuned at runtime without changing the defaults.
- Keep process data flowing during the SAFE-OP wait and don't insert slow
  per-slave state reads before the first cyclic exchange, so the
  SyncManager watchdog stays fed across the OP transition.
@amolypalshetkar
amolypalshetkar force-pushed the feat/easycat-shutdown-and-tunable-timeouts branch from e20a2a7 to e1d86a4 Compare November 16, 2026 15:10
@github-actions

Copy link
Copy Markdown

File Coverage Lines Branches
All files 87% 90% 84% ✅
lib/include/kickcat/Error.h 91% 100% 83% ✅
lib/include/kickcat/LockedRing.h 87% 94% 81% ✅
lib/include/kickcat/LoopbackSocket.h 81% 82% 80% ✅
lib/include/kickcat/SimulatorControl.h 84% 97% 70% ✅
lib/include/kickcat/utils/xml.h 98% 100% 97% ✅
lib/master/include/kickcat/AbstractLink.h 95% 90% 100% ✅
lib/master/src/Bus.cc 91% 94% 89% ✅
lib/master/src/CoE.cc 86% 90% 81% ✅
lib/master/src/FoE.cc 98% 100% 96% ✅
lib/master/src/Link.cc 98% 100% 96% ✅
lib/master/src/MailboxSequencer.cc 97% 100% 94% ✅
lib/master/src/MasterOD.cc 96% 99% 93% ✅
lib/master/src/Prints.cc 88% 88% 88% ✅
lib/master/src/Slave.cc 72% 87% 58% ❌
lib/master/src/dc.cc 76% 82% 70% ✅
lib/master/src/CoE/CiA/DS402/Drive.cc 78% 87% 70% ✅
lib/simulation/include/kickcat/simulation/devices/Ds402Motor.h 75% 91% 58% ✅
lib/simulation/src/DirectoryStorage.cc 93% 94% 92% ✅
lib/simulation/src/SimulatedSlave.cc 57% 67% 47% ❌
lib/simulation/src/SimulatorControlServer.cc 91% 97% 84% ✅
lib/simulation/src/Topology.cc 73% 70% 76% ❌
lib/slave/src/AbstractESC.cc 94% 100% 88% ✅
lib/slave/src/AbstractEmulatedEEPROM.cc 0% 0% 0% ❌
lib/slave/src/ESMStates.cc 95% 98% 92% ✅
lib/slave/src/ESM.cc 94% 100% 89% ✅
lib/slave/src/EmulatedNetwork.cc 98% 99% 97% ✅
lib/slave/src/PDO.cc 93% 97% 89% ✅
lib/slave/src/ESC/EmulatedESC.cc 87% 92% 82% ✅
lib/slave/src/ESC/Lan9252.cc 0% 0% 0% ❌
lib/src/Frame.cc 96% 96% 97% ✅
lib/src/Mailbox.cc 93% 96% 89% ✅
lib/src/SIIParser.cc 93% 95% 90% ✅
lib/src/protocol.cc 87% 84% 90% ✅
lib/src/CoE/OD.cc 95% 96% 94% ✅
lib/src/CoE/protocol.cc 92% 92% 92% ✅
lib/src/CoE/CiA/DS402/StateMachine.cc 93% 94% 92% ✅
lib/src/CoE/mailbox/request.cc 84% 86% 83% ✅
lib/src/CoE/mailbox/response.cc 87% 92% 82% ✅
lib/src/ENI/Parser.cc 95% 97% 92% ✅
lib/src/ESI/Parser.cc 86% 89% 83% ✅
lib/src/ESI/SIIBuilder.cc 86% 94% 77% ✅
lib/src/EoE/protocol.cc 0% 0% 0% ❌
lib/src/FoE/protocol.cc 22% 28% 17% ❌
lib/src/FoE/mailbox/request.cc 95% 97% 93% ✅
lib/src/FoE/mailbox/response.cc 89% 93% 86% ✅
lib/src/utils/xml.cc 96% 98% 95% ✅
lib/src/utils/xsd.cc 96% 98% 95% ✅

Minimum allowed coverage is 75%

Generated by 🐒 cobertura-action against e1d86a4

@leducp
leducp merged commit c1796ad into leducp:master Nov 16, 2026
46 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants