diff --git a/src/boards/AutomatedAntennas/Sensors.cpp b/src/boards/AutomatedAntennas/Sensors.cpp deleted file mode 100644 index f17f5288390b45a7b3d3eb5a904ae100827c0fb6..0000000000000000000000000000000000000000 --- a/src/boards/AutomatedAntennas/Sensors.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2023 Skyward Experimental Rocketry - * Author: Emilio Corigliano - * - * 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. - */ - -#include "Sensors.h" - -#include <utils/ModuleManager/ModuleManager.hpp> - -using namespace std; -using namespace miosix; -using namespace Boardcore; - -constexpr int SAMPLE_PERIOD_VN300 = 20; - -namespace Antennas -{ -Sensors::Sensors() {} - -bool Sensors::start() -{ - if (!vn300Init()) - { - return false; - } - - sm = new SensorManager(sensorsMap); - if (!sm->start()) - { - LOG_ERR(logger, "Sensor Manager failed to start"); - return false; - } -} - -bool Sensors::vn300Init() -{ - vn300 = new Boardcore::VN300( - ModuleManager::getInstance().get<Buses>()->uart4, 115200); - - if (!vn300->init()) - { - LOG_ERR(logger, "VN300 not initialized"); - return false; - } - - if (!vn300->selfTest()) - { - LOG_ERR(logger, "VN300 self-test failed"); - return false; - } - - SensorInfo info("VN300", SAMPLE_PERIOD_VN300, - bind(&Sensors::vn300Callback, this)); - - sensorsMap.emplace(make_pair(vn300, info)); - return true; -} - -void Sensors::vn300Callback() -{ - Logger::getInstance().log(vn300->getLastSample()); - Logger::getInstance().log(vn300->getLastError()); -} - -VN300Data Sensors::getVN300LastSample() { return vn300->getLastSample(); } - -} // namespace Antennas \ No newline at end of file diff --git a/src/boards/AutomatedAntennas/Sensors.h b/src/boards/AutomatedAntennas/Sensors.h deleted file mode 100644 index 852607ec8365aef727bf7984d3a09b16276ef371..0000000000000000000000000000000000000000 --- a/src/boards/AutomatedAntennas/Sensors.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2023 Skyward Experimental Rocketry - * Author: Emilio Corigliano - * - * 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 <utils/ModuleManager/ModuleManager.hpp> - -#include "Buses.h" -#include "sensors/SensorManager.h" -#include "sensors/Vectornav/VN300/VN300.h" - -namespace Antennas -{ -class Sensors : public Boardcore::Module -{ -public: - Sensors(); - - /** - * @brief Starts the SensorManager. - */ - bool start(); - - /** - * @brief Returns the last sample of the VN300. - */ - VN300Data getVN300LastSample(); - -private: - bool vn300Init(); - void vn300Callback(); - - Boardcore::VN300 *vn300 = nullptr; - - SensorManager *sm = nullptr; - Boardcore::SensorManager::SensorMap_t sensorsMap; - Boardcore::PrintLogger logger = Boardcore::Logging::getLogger("sensors"); -}; -} // namespace Antennas \ No newline at end of file diff --git a/src/boards/Groundstation/Base/BoardStatus.cpp b/src/boards/Groundstation/Base/BoardStatus.cpp deleted file mode 100644 index 35c82c839c5ac72f365c79de3ac725caece70bb3..0000000000000000000000000000000000000000 --- a/src/boards/Groundstation/Base/BoardStatus.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* Copyright (c) 2023 Skyward Experimental Rocketry - * Author: Davide Mor - * - * 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. - */ - -#include "BoardStatus.h" - -#include <Groundstation/Base/Ports/Ethernet.h> -#include <Groundstation/Base/Radio/Radio.h> -#include <Groundstation/Common/Config/GeneralConfig.h> -#include <Groundstation/Common/HubBase.h> -#include <common/Mavlink.h> -#include <drivers/timer/TimestampTimer.h> - -using namespace Boardcore; -using namespace Groundstation; -using namespace GroundstationBase; - -bool BoardStatus::isMainRadioPresent() { return main_radio_present; } -bool BoardStatus::isPayloadRadioPresent() { return payload_radio_present; } -bool BoardStatus::isEthernetPresent() { return ethernet_present; } - -bool BoardStatus::start() -{ - if (!ActiveObject::start()) - { - return false; - } - - return true; -} - -void BoardStatus::setMainRadioPresent(bool present) -{ - main_radio_present = present; -} - -void BoardStatus::setPayloadRadioPresent(bool present) -{ - payload_radio_present = present; -} - -void BoardStatus::setEthernetPresent(bool present) -{ - ethernet_present = present; -} - -void BoardStatus::run() -{ - while (!shouldStop()) - { - miosix::Thread::sleep(RADIO_STATUS_PERIOD); - - mavlink_arp_tm_t tm = {0}; - - tm.timestamp = TimestampTimer::getTimestamp(); - tm.battery_voltage = -420.0; - - if (main_radio_present) - { - tm.main_radio_present = 1; - - auto stats = - ModuleManager::getInstance().get<RadioMain>()->getStats(); - tm.main_packet_tx_error_count = stats.send_errors; - tm.main_tx_bitrate = main_tx_bitrate.update(stats.bits_tx_count); - tm.main_packet_rx_success_count = stats.packet_rx_success_count; - tm.main_packet_rx_drop_count = stats.packet_rx_drop_count; - tm.main_rx_bitrate = main_rx_bitrate.update(stats.bits_rx_count); - tm.main_rx_rssi = stats.rx_rssi; - - last_main_stats = stats; - } - - if (payload_radio_present) - { - tm.payload_radio_present = 1; - - auto stats = - ModuleManager::getInstance().get<RadioPayload>()->getStats(); - tm.payload_packet_tx_error_count = stats.send_errors; - tm.payload_tx_bitrate = - payload_tx_bitrate.update(stats.bits_tx_count); - tm.payload_packet_rx_success_count = stats.packet_rx_success_count; - tm.payload_packet_rx_drop_count = stats.packet_rx_drop_count; - tm.payload_rx_bitrate = - payload_rx_bitrate.update(stats.bits_rx_count); - tm.payload_rx_rssi = stats.rx_rssi; - - last_payload_stats = stats; - } - - if (ethernet_present) - { - auto stats = - ModuleManager::getInstance().get<Ethernet>()->getState(); - - tm.ethernet_present = 1; - tm.ethernet_status = (stats.link_up ? 1 : 0) | - (stats.full_duplex ? 2 : 0) | - (stats.based_100mbps ? 4 : 0); - } - - mavlink_message_t msg; - mavlink_msg_arp_tm_encode(GS_SYSTEM_ID, GS_COMPONENT_ID, &msg, &tm); - - ModuleManager::getInstance().get<HubBase>()->dispatchIncomingMsg(msg); - } -} \ No newline at end of file