diff --git a/skyward-boardcore b/skyward-boardcore index 19d8ecc6c9ebe24ac864857cbe175181a92d7b81..17bb3db31b6cce1d3097b80e96c27eda59f88ee5 160000 --- a/skyward-boardcore +++ b/skyward-boardcore @@ -1 +1 @@ -Subproject commit 19d8ecc6c9ebe24ac864857cbe175181a92d7b81 +Subproject commit 17bb3db31b6cce1d3097b80e96c27eda59f88ee5 diff --git a/src/boards/MockupMain/PinHandler/PinHandler.cpp b/src/boards/MockupMain/PinHandler/PinHandler.cpp index f760f15aa0229657e0ce31439fe08b357e267243..8b5eb6d8bc5897ab2df0c38e6bb30acc44dd2fd2 100644 --- a/src/boards/MockupMain/PinHandler/PinHandler.cpp +++ b/src/boards/MockupMain/PinHandler/PinHandler.cpp @@ -19,17 +19,19 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - #include "PinHandler.h" #include <MockupMain/Configs/PinHandlerConfig.h> #include <common/Events.h> +#include <drivers/timer/TimestampTimer.h> #include <events/EventBroker.h> #include <interfaces-impl/hwmapping.h> #include <miosix.h> #include <functional> +#include "PinHandlerData.h" + using namespace std::placeholders; using namespace miosix; using namespace Boardcore; @@ -40,8 +42,11 @@ namespace MockupMain void PinHandler::onExpulsionPinTransition(PinTransition transition) { - if (transition == NC_DETACH_PIN_TRIGGER) - EventBroker::getInstance().post(FLIGHT_NC_DETACHED, TOPIC_FLIGHT); + PinHandlerData data; + data.timestamp = TimestampTimer::getTimestamp(); + data.numberTransition = + pinObserver.getPinData(inputs::expulsion::getPin()).changesCount; + Logger::getInstance().log(data); } bool PinHandler::start() diff --git a/src/boards/MockupMain/PinHandler/PinHandlerData.h b/src/boards/MockupMain/PinHandler/PinHandlerData.h new file mode 100644 index 0000000000000000000000000000000000000000..2b359372f44ae93dd216a2e49700c031dce707f6 --- /dev/null +++ b/src/boards/MockupMain/PinHandler/PinHandlerData.h @@ -0,0 +1,43 @@ +/* Copyright (c) 2023 Skyward Experimental Rocketry + * Author: Giulia Ghirardini + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include <sensors/SensorData.h> + +namespace MockupMain +{ + +struct PinHandlerData +{ + long long timestamp = 0; + int numberTransition = 0; + + static std::string header() { return "timestamp,state\n"; } + + void print(std::ostream& os) const + { + os << timestamp << "," << (int)numberTransition << "\n"; + } +}; + +} // namespace MockupMain diff --git a/src/entrypoints/MockupMain/main-entry.cpp b/src/entrypoints/MockupMain/main-entry.cpp index 717a85c81a211a9dd1c22e4c25f7a2f87fe2889f..b062ddbed334896ce00f5056de7b54c54c32a812 100644 --- a/src/entrypoints/MockupMain/main-entry.cpp +++ b/src/entrypoints/MockupMain/main-entry.cpp @@ -164,11 +164,11 @@ int main() LOG_ERR(logger, "Error starting the Radio module"); } - // if (!modules.get<PinHandler>()->start()) - // { - // initResult = false; - // LOG_ERR(logger, "Error starting the PinHandler module"); - // } + if (!modules.get<PinHandler>()->start()) + { + initResult = false; + LOG_ERR(logger, "Error starting the PinHandler module"); + } if (!modules.get<BoardScheduler>()->start()) { diff --git a/src/scripts/logdecoder/MockupMain/logdecoder b/src/scripts/logdecoder/MockupMain/logdecoder index 9df9b89c053ef4a1d2ccded6abc44746f9fade96..b0ede9b4149d6cd77e6c1ffd5cea53c91651b9c6 100755 Binary files a/src/scripts/logdecoder/MockupMain/logdecoder and b/src/scripts/logdecoder/MockupMain/logdecoder differ diff --git a/src/scripts/logdecoder/MockupMain/logdecoder.cpp b/src/scripts/logdecoder/MockupMain/logdecoder.cpp index 5cee431c2ceb74d30543c623f596009d94b58929..93427789801034bae2f3acb2347f8dfca91331fa 100644 --- a/src/scripts/logdecoder/MockupMain/logdecoder.cpp +++ b/src/scripts/logdecoder/MockupMain/logdecoder.cpp @@ -20,6 +20,7 @@ * THE SOFTWARE. */ +#include <MockupMain/PinHandler/PinHandlerData.h> #include <MockupMain/Sensors/AnalogLoadCellSensor.h> #include <MockupMain/StateMachines/FlightModeManager/FlightModeManagerData.h> #include <MockupMain/StateMachines/NASController/NASControllerData.h> @@ -66,6 +67,7 @@ void registerTypes(Deserializer& ds) ds.registerType<ModemStatusFrameLog>(); ds.registerType<TXStatusFrameLog>(); ds.registerType<RXPacketFrameLog>(); + ds.registerType<PinHandlerData>(); } void showUsage(const string& cmdName)