diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index 13cbd4a..fa3c189 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/App/Inc/sta/config.hpp b/App/Inc/sta/config.hpp
index ac9da2c..667052e 100644
--- a/App/Inc/sta/config.hpp
+++ b/App/Inc/sta/config.hpp
@@ -33,7 +33,7 @@
#define STA_TACOS_STATEMACHINE_PRIORITY osPriorityNormal
// Statemachine settings. Here, we only have a single state which is also the initial state.
-#define STA_TACOS_NUM_STATES 2
+#define STA_TACOS_NUM_STATES 3
#define STA_TACOS_INITIAL_STATE 0
#endif /* INC_STA_CONFIG_HPP_ */
diff --git a/App/Inc/tasks/disturb.hpp b/App/Inc/tasks/disturb.hpp
new file mode 100644
index 0000000..4919fee
--- /dev/null
+++ b/App/Inc/tasks/disturb.hpp
@@ -0,0 +1,26 @@
+/*
+ * disturb.hpp
+ *
+ * Created on: Nov 20, 2023
+ * Author: Dario
+ */
+
+#ifndef INC_TASKS_DISTURB_HPP_
+#define INC_TASKS_DISTURB_HPP_
+
+#include
+
+namespace demo
+{
+ class DisturbTask : public sta::tacos::TacosThread {
+ public:
+ DisturbTask();
+
+ void init() override;
+
+ void func() override;
+ };
+} // namespace demo
+
+
+#endif /* INC_TASKS_DISTURB_HPP_ */
diff --git a/App/Inc/tasks/dummy.hpp b/App/Inc/tasks/dummy.hpp
index 0c7de2b..aea9df6 100644
--- a/App/Inc/tasks/dummy.hpp
+++ b/App/Inc/tasks/dummy.hpp
@@ -15,7 +15,6 @@ namespace demo
class DummyTask : public sta::tacos::TacosThread {
public:
DummyTask(const char* name);
- ~DummyTask() override;
void init() override;
diff --git a/App/Src/startup.cpp b/App/Src/startup.cpp
index 646ca9c..87dfde0 100644
--- a/App/Src/startup.cpp
+++ b/App/Src/startup.cpp
@@ -13,6 +13,7 @@
#include
#include
#include
+#include
#include
#include
@@ -35,7 +36,9 @@ namespace sta
// The dummy task runs for state 0.
Manager::instance()->registerThread(std::make_shared("State 0"), {0});
Manager::instance()->registerThread(std::make_shared("State 1"), {1});
+ Manager::instance()->registerThread(std::make_shared("State 2 - FAIL"), {2});
Manager::instance()->registerThread(std::make_shared(), {0, 1});
+ Manager::instance()->registerThread(std::make_shared(), {0, 1});
}
} // namespace tacos
} // namespace sta
diff --git a/App/Src/tasks/disturb.cpp b/App/Src/tasks/disturb.cpp
new file mode 100644
index 0000000..8315c96
--- /dev/null
+++ b/App/Src/tasks/disturb.cpp
@@ -0,0 +1,35 @@
+/*
+ * disturb.cpp
+ *
+ * Created on: Nov 20, 2023
+ * Author: Dario
+ */
+
+#include
+#include
+#include
+
+namespace demo
+{
+ DisturbTask::DisturbTask()
+ : sta::tacos::TacosThread("Disturb", osPriorityNormal)
+ {
+
+ }
+
+ void DisturbTask::init()
+ {
+
+ }
+
+ void DisturbTask::func()
+ {
+ STA_DEBUG_PRINTLN(this->getName());
+
+ sta::tacos::Statemachine::instance()->stateChangeEvent.wait(sta::tacos::EventFlags::ALL, osWaitForever);
+
+ uint16_t currentState = sta::tacos::Statemachine::instance()->getCurrentState();
+ sta::tacos::Statemachine::instance()->requestTimedStateTransition(currentState, 2, 4000, 0);
+ }
+} // namespace demo
+
diff --git a/App/Src/tasks/dummy.cpp b/App/Src/tasks/dummy.cpp
index 5046319..41b0a8c 100644
--- a/App/Src/tasks/dummy.cpp
+++ b/App/Src/tasks/dummy.cpp
@@ -19,8 +19,6 @@ namespace demo
}
- DummyTask::~DummyTask(){}
-
void DummyTask::init()
{
diff --git a/App/Src/tasks/toggle.cpp b/App/Src/tasks/toggle.cpp
index f4efe41..e43b296 100644
--- a/App/Src/tasks/toggle.cpp
+++ b/App/Src/tasks/toggle.cpp
@@ -26,8 +26,23 @@ namespace demo
{
osDelay(5000);
+ // Have we been requested to terminate while waiting?
+ if (!isRunning())
+ return;
+
+ // Do some important stuff...
+
uint16_t state = sta::tacos::Statemachine::instance()->getCurrentState();
- uint16_t next = 1 - state;
+ uint16_t next;
+
+ if (state != 2)
+ {
+ next = 1 - state;
+ }
+ else
+ {
+ next = 0;
+ }
STA_DEBUG_PRINTLN("Toggle!");
sta::tacos::Statemachine::instance()->requestStateTransition(state, next, 0);
diff --git a/Libs/sta-core b/Libs/sta-core
index 71170d4..4da1f0b 160000
--- a/Libs/sta-core
+++ b/Libs/sta-core
@@ -1 +1 @@
-Subproject commit 71170d4cea428fffb05fc2666201d390ff411fc4
+Subproject commit 4da1f0bb7dd48f89e9dd5ee0ec181638894e55e2