igor-krechetov / hsmcpp

C++ based Hierarchical / Finite State Machine library oriented for embedded and RTOS systems.
https://hsmcpp.readthedocs.io
MIT License
62 stars 7 forks source link

Example of issue with timers #8

Closed wiktorpi closed 5 months ago

wiktorpi commented 8 months ago

Hello! First of all, i just want to say great work on this library! Coming from tinyFSM, it has been a pleasure to use so far. I have run into an issue though. Let's say I have started a timer on state entry, then stopped it at the same state exit. Then, i created internal callback in the same state, reacting to the timer events, and calling a condition callback. Essentially what i wanted to have is a periodic callback that is bound to the state itself, that starts being called when you enter the state and stops once you leave it. Below is the image from QT creator.

Screenshot from 2023-11-07 10-34-409

In the case i have described, everything works as expected. But, if i start another timer in the entry of the same state, the callbacks are being called constantly, without regard for the timer interval. It is enough to just start another timer, not even use the callback in anything else.

Is it an issue with my implementation or actually a bug? In this PR i have included an example implementation that demonstrates the issue.

igor-krechetov commented 5 months ago

Hi @wiktorpi , Issue was fixed with commit a9a5b002219a64ae3608e43b82b11eaeaaf2e914 (version 1.0.1). And thank you for the example - it made it very easy to reproduce the bug. I converted it to unit-test.