diff --git a/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentStateMachines.scala b/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentStateMachines.scala index afbb5190e..d49304f32 100644 --- a/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentStateMachines.scala +++ b/compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentStateMachines.scala @@ -63,16 +63,19 @@ case class ComponentStateMachines( Line.blank :: List.concat( lines( - s"""|// Deserialize the state machine ID + s"""|// Deserialize the state machine ID to an FwEnumStoreType |FwEnumStoreType enumStoreSmId = 0; |Fw::SerializeStatus deserStatus = msg.deserialize(enumStoreSmId); |FW_ASSERT( | deserStatus == Fw::FW_SERIALIZE_OK, | static_cast(deserStatus) |); + |// Cast it to the correct type |SmId stateMachineId = static_cast(enumStoreSmId); | - |// Deserialize the state machine signal + |// Deserialize the state machine signal to an FwEnumStoreType. + |// This value will be cast to the correct type in the + |// switch statement that calls the state machine update function. |FwEnumStoreType enumStoreSmSignal = 0; |deserStatus = msg.deserialize(enumStoreSmSignal); |FW_ASSERT( @@ -217,8 +220,7 @@ case class ComponentStateMachines( }), Line.blank :: lines( s"""|default: - | FW_ASSERT(0, static_cast(stateMachineId)); - | break;""" + | return MSG_DISPATCH_ERROR;""" ) ) ) diff --git a/compiler/tools/fpp-to-cpp/test/component/base/ActiveStateMachinesComponentAc.ref.cpp b/compiler/tools/fpp-to-cpp/test/component/base/ActiveStateMachinesComponentAc.ref.cpp index fe599cac0..be092675a 100644 --- a/compiler/tools/fpp-to-cpp/test/component/base/ActiveStateMachinesComponentAc.ref.cpp +++ b/compiler/tools/fpp-to-cpp/test/component/base/ActiveStateMachinesComponentAc.ref.cpp @@ -490,16 +490,19 @@ namespace M { // Handle state machine signals case STATEMACHINE_SENDSIGNALS: { - // Deserialize the state machine ID + // Deserialize the state machine ID to an FwEnumStoreType FwEnumStoreType enumStoreSmId = 0; Fw::SerializeStatus deserStatus = msg.deserialize(enumStoreSmId); FW_ASSERT( deserStatus == Fw::FW_SERIALIZE_OK, static_cast(deserStatus) ); + // Cast it to the correct type SmId stateMachineId = static_cast(enumStoreSmId); - // Deserialize the state machine signal + // Deserialize the state machine signal to an FwEnumStoreType. + // This value will be cast to the correct type in the + // switch statement that calls the state machine update function. FwEnumStoreType enumStoreSmSignal = 0; deserStatus = msg.deserialize(enumStoreSmSignal); FW_ASSERT( @@ -568,8 +571,7 @@ namespace M { } default: - FW_ASSERT(0, static_cast(stateMachineId)); - break; + return MSG_DISPATCH_ERROR; } break;