Invalid state now frees up allocated memory

Semaphore is reset so receiver can reuse said entry
This commit is contained in:
GHOSCHT 2023-04-01 11:02:29 +02:00
parent 7eebc7b997
commit 0ca9ca8ad2

View file

@ -398,7 +398,7 @@ auto message::parser::StateVisitor::operator()(state::Complete) -> State {
} }
auto message::parser::StateVisitor::operator()(state::Invalid) -> State { auto message::parser::StateVisitor::operator()(state::Invalid) -> State {
message->second.give(); message->second.give();
return state::Invalid{}; return state::Complete{};
} }
auto message::parser::parse( auto message::parser::parse(
@ -406,8 +406,7 @@ auto message::parser::parse(
freertos::Queue<LightController::LightAction> &lightActionQueue) -> void { freertos::Queue<LightController::LightAction> &lightActionQueue) -> void {
StateVisitor visitor{message, lightActionQueue}; StateVisitor visitor{message, lightActionQueue};
State state{state::ModeSelection{}}; State state{state::ModeSelection{}};
while (!etl::holds_alternative<state::Invalid>(state) && while (!etl::holds_alternative<state::Complete>(state)) {
!etl::holds_alternative<state::Complete>(state)) {
state = etl::visit(visitor, state); state = etl::visit(visitor, state);
} }
} }