From 254a34935a88f0f4a27aef85ea0e4f61115c48ec Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 10:11:57 +0100 Subject: [PATCH 1/8] Added more checks for STLPort --- include/etl/largest.h | 2 +- include/etl/message_router.h | 2 +- include/etl/pool.h | 6 +++--- include/etl/smallest.h | 2 +- include/etl/type_traits_generator.h | 4 ++-- include/etl/variant.h | 2 +- include/etl/variant_pool.h | 2 +- include/etl/variant_pool_generator.h | 2 +- include/etl/version.h | 4 ++-- support/Release notes.txt | 4 ++++ 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/etl/largest.h b/include/etl/largest.h index 0bb51c11..a352a582 100644 --- a/include/etl/largest.h +++ b/include/etl/largest.h @@ -33,7 +33,7 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** //*************************************************************************** diff --git a/include/etl/message_router.h b/include/etl/message_router.h index 62f591df..ff1ba20b 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -31,7 +31,7 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** //*************************************************************************** diff --git a/include/etl/pool.h b/include/etl/pool.h index 8ce26fe1..e110fa43 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -134,7 +134,7 @@ namespace etl return reinterpret_cast(allocate_item()); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) //************************************************************************* /// Allocate storage for an object from the pool and create default. /// If asserts or exceptions are enabled and there are no more free items an @@ -499,7 +499,7 @@ namespace etl return ipool::allocate(); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) //************************************************************************* /// Allocate storage for an object from the pool and create with default. /// If asserts or exceptions are enabled and there are no more free items an @@ -650,7 +650,7 @@ namespace etl return base_t::template allocate(); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) //************************************************************************* /// Allocate storage for an object from the pool and create with default. /// If asserts or exceptions are enabled and there are no more free items an diff --git a/include/etl/smallest.h b/include/etl/smallest.h index 33eaaf6a..8b1337e1 100644 --- a/include/etl/smallest.h +++ b/include/etl/smallest.h @@ -33,7 +33,7 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** //*************************************************************************** diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index c993d746..5151b34e 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -281,14 +281,14 @@ namespace etl /// is_pod /// For C++03, only fundamental and pointers types are recognised. ///\ingroup type_traits -#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO)) && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO) && !defined(ETL_STLPORT)) && !defined(ETL_IN_UNIT_TEST) // For compilers that support C++11 template struct is_pod : std::is_pod {}; #else template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; #endif -#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_STLPORT) && !defined(ETL_IN_UNIT_TEST) /// is_trivially_constructible ///\ingroup type_traits template struct is_trivially_constructible : std::is_trivially_constructible {}; diff --git a/include/etl/variant.h b/include/etl/variant.h index 182e19c8..db22a746 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -711,7 +711,7 @@ namespace etl type_id = other.type_id; } -#if !ETL_CPP11_SUPPORTED +#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) //*************************************************************************** /// Emplace with one constructor parameter. //*************************************************************************** diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index c08dac50..bc66274a 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -133,7 +133,7 @@ namespace etl { } -#if !ETL_CPP11_SUPPORTED +#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) //************************************************************************* /// Creates the object. Default constructor. //************************************************************************* diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index 5c117bdf..5c859697 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -140,7 +140,7 @@ namespace etl { } -#if !ETL_CPP11_SUPPORTED +#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) //************************************************************************* /// Creates the object. Default constructor. //************************************************************************* diff --git a/include/etl/version.h b/include/etl/version.h index 015898b2..1f59cc16 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.11.0" +#define ETL_VERSION "11.11.1" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 11 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 3501b177..c182077b 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +11.11.1 +Compatibilty changes for Segger IDE, GCC & STLPort + =============================================================================== 11.11.0 Compatibilty changes for Segger IDE, GCC & STLPort From bf16ee4f5ce85d7f2a37bb11df12e3acb78e84c0 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 21:08:03 +0100 Subject: [PATCH 2/8] Comment change --- include/etl/largest.h | 2 +- include/etl/smallest.h | 2 +- include/etl/type_traits.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/etl/largest.h b/include/etl/largest.h index 0bb51c11..a352a582 100644 --- a/include/etl/largest.h +++ b/include/etl/largest.h @@ -33,7 +33,7 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** //*************************************************************************** diff --git a/include/etl/smallest.h b/include/etl/smallest.h index 33eaaf6a..8b1337e1 100644 --- a/include/etl/smallest.h +++ b/include/etl/smallest.h @@ -33,7 +33,7 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** //*************************************************************************** diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index a28a2065..a1a21df8 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -33,7 +33,7 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** //*************************************************************************** From fb2d2e96f687e9ac9cc52d0d289156259ece5c67 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 21:09:26 +0100 Subject: [PATCH 3/8] Added flag to call on_enter_state on start. Default true. --- include/etl/fsm.h | 59 +++++++++++++++++++++---------------- include/etl/fsm_generator.h | 59 +++++++++++++++++++++---------------- 2 files changed, 68 insertions(+), 50 deletions(-) diff --git a/include/etl/fsm.h b/include/etl/fsm.h index d350467d..1514b0af 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -242,17 +242,26 @@ namespace etl //******************************************* void start(bool call_on_enter_state = true) { - // Can only be started once. - if (p_state == nullptr) - { - p_state = state_list[0]; - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + // Can only be started once. + if (p_state == nullptr) + { + p_state = state_list[0]; + ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); - if (call_on_enter_state) - { - p_state->on_enter_state(); - } - } + if (call_on_enter_state) + { + etl::fsm_state_id_t next_state_id; + etl::ifsm_state* p_last_state; + + do + { + p_last_state = p_state; + next_state_id = p_state->on_enter_state(); + p_state = state_list[next_state_id]; + + } while (p_last_state != p_state); + } + } } //******************************************* @@ -260,7 +269,7 @@ namespace etl //******************************************* void receive(const etl::imessage& message) { - etl::null_message_router nmr; + static etl::null_message_router nmr; receive(nmr, message); } @@ -269,26 +278,26 @@ namespace etl //******************************************* void receive(etl::imessage_router& source, const etl::imessage& message) { - etl::fsm_state_id_t next_state_id = p_state->process_event(source, message); - ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); + etl::fsm_state_id_t next_state_id = p_state->process_event(source, message); + ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); - etl::ifsm_state* p_next_state = state_list[next_state_id]; + etl::ifsm_state* p_next_state = state_list[next_state_id]; - // Have we changed state? - if (p_next_state != p_state) - { - do + // Have we changed state? + if (p_next_state != p_state) { - p_state->on_exit_state(); - p_state = p_next_state; + do + { + p_state->on_exit_state(); + p_state = p_next_state; - next_state_id = p_state->on_enter_state(); - ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); + next_state_id = p_state->on_enter_state(); + ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); - p_next_state = state_list[next_state_id]; + p_next_state = state_list[next_state_id]; - } while (p_next_state != p_state); // Have we changed state again? - } + } while (p_next_state != p_state); // Have we changed state again? + } } using imessage_router::accepts; diff --git a/include/etl/fsm_generator.h b/include/etl/fsm_generator.h index 37007900..a937542e 100644 --- a/include/etl/fsm_generator.h +++ b/include/etl/fsm_generator.h @@ -254,17 +254,26 @@ namespace etl //******************************************* void start(bool call_on_enter_state = true) { - // Can only be started once. - if (p_state == nullptr) - { - p_state = state_list[0]; - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + // Can only be started once. + if (p_state == nullptr) + { + p_state = state_list[0]; + ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); - if (call_on_enter_state) - { - p_state->on_enter_state(); - } - } + if (call_on_enter_state) + { + etl::fsm_state_id_t next_state_id; + etl::ifsm_state* p_last_state; + + do + { + p_last_state = p_state; + next_state_id = p_state->on_enter_state(); + p_state = state_list[next_state_id]; + + } while (p_last_state != p_state); + } + } } //******************************************* @@ -272,7 +281,7 @@ namespace etl //******************************************* void receive(const etl::imessage& message) { - etl::null_message_router nmr; + static etl::null_message_router nmr; receive(nmr, message); } @@ -281,26 +290,26 @@ namespace etl //******************************************* void receive(etl::imessage_router& source, const etl::imessage& message) { - etl::fsm_state_id_t next_state_id = p_state->process_event(source, message); - ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); + etl::fsm_state_id_t next_state_id = p_state->process_event(source, message); + ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); - etl::ifsm_state* p_next_state = state_list[next_state_id]; + etl::ifsm_state* p_next_state = state_list[next_state_id]; - // Have we changed state? - if (p_next_state != p_state) - { - do + // Have we changed state? + if (p_next_state != p_state) { - p_state->on_exit_state(); - p_state = p_next_state; + do + { + p_state->on_exit_state(); + p_state = p_next_state; - next_state_id = p_state->on_enter_state(); - ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); + next_state_id = p_state->on_enter_state(); + ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); - p_next_state = state_list[next_state_id]; + p_next_state = state_list[next_state_id]; - } while (p_next_state != p_state); // Have we changed state again? - } + } while (p_next_state != p_state); // Have we changed state again? + } } using imessage_router::accepts; From acc317c3d461428287ad7a13e5e5917d376fa95c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 21:09:59 +0100 Subject: [PATCH 4/8] Non-virtual message is no longer protected. --- include/etl/message.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/etl/message.h b/include/etl/message.h index 64d1bb96..83714cb3 100644 --- a/include/etl/message.h +++ b/include/etl/message.h @@ -76,12 +76,10 @@ namespace etl const etl::message_id_t message_id; #if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES) - public: virtual ~imessage() { } #else - protected: ~imessage() { } From 52176c84f095f3e631851d4e5f030f97f433f2ef Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 21:10:16 +0100 Subject: [PATCH 5/8] Comment change --- include/etl/message_router.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/etl/message_router.h b/include/etl/message_router.h index 62f591df..ff1ba20b 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -31,7 +31,7 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** //*************************************************************************** From 9ce21fb07142e5d7fc790ac68753e7d262e7743c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 21:10:48 +0100 Subject: [PATCH 6/8] Added tests for recursive messages. --- test/test_fsm.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 5 deletions(-) diff --git a/test/test_fsm.cpp b/test/test_fsm.cpp index 37c2a8ec..74cb9b45 100644 --- a/test/test_fsm.cpp +++ b/test/test_fsm.cpp @@ -31,9 +31,12 @@ SOFTWARE. #include "fsm.h" #include "enum_type.h" #include "container.h" +#include "packet.h" +#include "queue.h" #include + namespace { const etl::message_router_id_t MOTOR_CONTROL = 0; @@ -49,6 +52,7 @@ namespace STOP, STOPPED, SET_SPEED, + RECURSIVE, UNSUPPORTED }; @@ -57,6 +61,7 @@ namespace ETL_ENUM_TYPE(STOP, "Stop") ETL_ENUM_TYPE(STOPPED, "Stopped") ETL_ENUM_TYPE(SET_SPEED, "Set Speed") + ETL_ENUM_TYPE(RECURSIVE, "Recursive") ETL_ENUM_TYPE(UNSUPPORTED, "Unsupported") ETL_END_ENUM_TYPE }; @@ -92,6 +97,11 @@ namespace { }; + //*********************************** + class Recursive : public etl::message + { + }; + //*********************************** class Unsupported : public etl::message { @@ -145,7 +155,7 @@ namespace } //*********************************** - void SetSpeed(int speed_) + void SetSpeedValue(int speed_) { speed = speed_; } @@ -162,6 +172,19 @@ namespace isLampOn = false; } + //*********************************** + template + void queue_recursive_message(const T& message) + { + messageQueue.emplace(message); + } + + typedef etl::largest Largest_t; + + typedef etl::packet Packet_t; + + etl::queue messageQueue; + int startCount; int stopCount; int setSpeedCount; @@ -174,7 +197,7 @@ namespace //*********************************** // The idle state. //*********************************** - class Idle : public etl::fsm_state + class Idle : public etl::fsm_state { public: @@ -185,6 +208,13 @@ namespace return StateId::RUNNING; } + //*********************************** + etl::fsm_state_id_t on_event(etl::imessage_router&, const Recursive&) + { + get_fsm_context().queue_recursive_message(Start()); + return StateId::IDLE; + } + //*********************************** etl::fsm_state_id_t on_event_unknown(etl::imessage_router&, const etl::imessage&) { @@ -226,7 +256,7 @@ namespace etl::fsm_state_id_t on_event(etl::imessage_router&, const SetSpeed& event) { ++get_fsm_context().setSpeedCount; - get_fsm_context().SetSpeed(event.speed); + get_fsm_context().SetSpeedValue(event.speed); return STATE_ID; } @@ -309,7 +339,7 @@ namespace CHECK(!motorControl.is_started()); // Start the FSM. - motorControl.start(); + motorControl.start(false); CHECK(motorControl.is_started()); // Now in Idle state. @@ -447,7 +477,7 @@ namespace CHECK(!motorControl.is_started()); // Start the FSM. - motorControl.start(); + motorControl.start(false); CHECK(motorControl.is_started()); // Now in Idle state. @@ -484,6 +514,43 @@ namespace CHECK_EQUAL(0, motorControl.unknownCount); } + //************************************************************************* + TEST(test_fsm_recursive_event) + { + etl::null_message_router nmr; + + motorControl.reset(); + motorControl.ClearStatistics(); + + motorControl.messageQueue.clear(); + + // Start the FSM. + motorControl.start(false); + + // Now in Idle state. + // Send Start event. + motorControl.receive(nmr, Recursive()); + + CHECK_EQUAL(1, motorControl.messageQueue.size()); + + // Send the queued message. + motorControl.receive(nmr, motorControl.messageQueue.front().get()); + motorControl.messageQueue.pop(); + + // Now in Running state. + + CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state().get_state_id())); + + CHECK_EQUAL(true, motorControl.isLampOn); + CHECK_EQUAL(0, motorControl.setSpeedCount); + CHECK_EQUAL(0, motorControl.speed); + CHECK_EQUAL(1, motorControl.startCount); + CHECK_EQUAL(0, motorControl.stopCount); + CHECK_EQUAL(0, motorControl.stoppedCount); + CHECK_EQUAL(0, motorControl.unknownCount); + } + //************************************************************************* TEST(test_fsm_supported) { From 91cf9713fe8bbec71c92da7b227841323ee7264b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 21:12:06 +0100 Subject: [PATCH 7/8] Comment change --- include/etl/fsm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 1514b0af..3a837f39 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -238,7 +238,7 @@ namespace etl /// Starts the FSM. /// Can only be called once. /// Subsequent calls will do nothing. - ///\param call_on_enter_state If true will call on_enter_state() for the first state. Default = true. + ///\param call_on_enter_state If will call on_enter_state() for the first state. Default = true. //******************************************* void start(bool call_on_enter_state = true) { From 10a00724e0c09a88782d4f6daff932f66bd761e7 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 22:14:19 +0100 Subject: [PATCH 8/8] Updated version --- include/etl/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 1f59cc16..5b4b22be 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.11.1" +#define ETL_VERSION "11.11.2" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 11 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_PATCH 2 #endif