From bb0c4ac03eb01a8d52f7b7ef81fc69fa1c520676 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Mar 2023 17:37:39 +0100 Subject: [PATCH] check file validity --- bsp_q7s/core/CoreController.cpp | 4 ++-- bsp_q7s/core/CoreController.h | 5 +++-- bsp_q7s/core/ObjectFactory.h | 2 +- linux/devices/GpsHyperionLinuxController.cpp | 2 +- linux/devices/ImtqPollingTask.cpp | 9 ++++----- linux/devices/ImtqPollingTask.h | 3 ++- linux/devices/startracker/StarTrackerHandler.cpp | 4 ++-- linux/devices/startracker/StrHelper.cpp | 4 ++++ tmtc | 2 +- 9 files changed, 20 insertions(+), 15 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 61e7ee67..9d772a86 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -31,7 +31,7 @@ xsc::Chip CoreController::CURRENT_CHIP = xsc::Chip::NO_CHIP; xsc::Copy CoreController::CURRENT_COPY = xsc::Copy::NO_COPY; -CoreController::CoreController(object_id_t objectId, const std::atomic_uint16_t& i2cErrors) +CoreController::CoreController(object_id_t objectId, const std::atomic_uint16_t &i2cErrors) : ExtendedControllerBase(objectId, 5), cmdExecutor(4096), cmdReplyBuf(4096, true), @@ -108,7 +108,7 @@ void CoreController::performControlOperation() { sdStateMachine(); performMountedSdCardOperations(); readHkData(); - if(i2cErrors >= 5) { + if (i2cErrors >= 5) { bool protOpPerformed = false; triggerEvent(I2C_UNAVAILABLE_REBOOT); gracefulShutdownTasks(CURRENT_CHIP, CURRENT_COPY, protOpPerformed); diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index cd504e3c..aaaba8ac 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -6,6 +6,7 @@ #include #include +#include #include #include "CoreDefinitions.h" @@ -15,7 +16,6 @@ #include "fsfw/controller/ExtendedControllerBase.h" #include "mission/devices/devicedefinitions/GPSDefinitions.h" #include "mission/trace.h" -#include class Timer; class SdCardManager; @@ -132,7 +132,8 @@ class CoreController : public ExtendedControllerBase { //! P1: First 16 bits boot count of image 0 0, last 16 bits boot count of image 0 1. //! P2: First 16 bits boot count of image 1 0, last 16 bits boot count of image 1 1. static constexpr Event INDIVIDUAL_BOOT_COUNTS = event::makeEvent(SUBSYSTEM_ID, 8, severity::INFO); - static constexpr Event I2C_UNAVAILABLE_REBOOT = event::makeEvent(SUBSYSTEM_ID, 10, severity::MEDIUM); + static constexpr Event I2C_UNAVAILABLE_REBOOT = + event::makeEvent(SUBSYSTEM_ID, 10, severity::MEDIUM); CoreController(object_id_t objectId, const std::atomic_uint16_t& i2cErrors); virtual ~CoreController(); diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 66ece5cd..68c64450 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -11,8 +11,8 @@ #include #include -#include #include +#include class LinuxLibgpioIF; class SerialComIF; diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index 8b26da5c..0b971f49 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -303,7 +303,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { bool timeValid = false; if (TIME_SET == (TIME_SET & gps.set)) { // To prevent totally incorrect times from being declared valid. - if(gpsSet.satInView.isValid() and gpsSet.satInView.value >= 1) { + if (gpsSet.satInView.isValid() and gpsSet.satInView.value >= 1) { timeValid = true; } timeval time = {}; diff --git a/linux/devices/ImtqPollingTask.cpp b/linux/devices/ImtqPollingTask.cpp index a0e59412..eccb0898 100644 --- a/linux/devices/ImtqPollingTask.cpp +++ b/linux/devices/ImtqPollingTask.cpp @@ -10,9 +10,8 @@ #include "fsfw/FSFW.h" -ImtqPollingTask::ImtqPollingTask(object_id_t imtqPollingTask, - std::atomic_uint16_t& i2cFatalErrors): SystemObject(imtqPollingTask), - i2cFatalErrors(i2cFatalErrors) { +ImtqPollingTask::ImtqPollingTask(object_id_t imtqPollingTask, std::atomic_uint16_t& i2cFatalErrors) + : SystemObject(imtqPollingTask), i2cFatalErrors(i2cFatalErrors) { semaphore = SemaphoreFactory::instance()->createBinarySemaphore(); semaphore->acquire(); ipcLock = MutexFactory::instance()->createMutex(); @@ -429,7 +428,7 @@ ReturnValue_t ImtqPollingTask::performI2cFullRequest(uint8_t* reply, size_t repl if (ioctl(fd, I2C_SLAVE, i2cAddr) < 0) { sif::warning << "Opening IMTQ slave device failed with code " << errno << ": " << strerror(errno) << std::endl; - if(errno == EBUSY) { + if (errno == EBUSY) { i2cFatalErrors++; } } @@ -440,7 +439,7 @@ ReturnValue_t ImtqPollingTask::performI2cFullRequest(uint8_t* reply, size_t repl << ". Error description: " << strerror(errno) << std::endl; // This is a weird issue which sometimes occurs on debug builds. All I2C buses are busy // for all writes, - if(errno == EBUSY) { + if (errno == EBUSY) { i2cFatalErrors++; } return returnvalue::FAILED; diff --git a/linux/devices/ImtqPollingTask.h b/linux/devices/ImtqPollingTask.h index efe6a01b..592433c9 100644 --- a/linux/devices/ImtqPollingTask.h +++ b/linux/devices/ImtqPollingTask.h @@ -4,11 +4,12 @@ #include #include +#include + #include "fsfw/devicehandlers/DeviceCommunicationIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "mission/devices/devicedefinitions/imtqHelpers.h" -#include class ImtqPollingTask : public SystemObject, public ExecutableObjectIF, diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index f2fd4813..30971d5b 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -2147,13 +2147,13 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) { case startracker::REQ_SUBSCRIPTION: case startracker::REQ_LOG_SUBSCRIPTION: case startracker::REQ_DEBUG_CAMERA: - if(getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) { + if (getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) { return STARTRACKER_NOT_RUNNING_FIRMWARE; } break; case startracker::FIRMWARE_UPDATE: case startracker::FLASH_READ: - if(getMode() != MODE_ON or getSubmode() != startracker::Program::BOOTLOADER) { + if (getMode() != MODE_ON or getSubmode() != startracker::Program::BOOTLOADER) { return STARTRACKER_NOT_RUNNING_BOOTLOADER; } break; diff --git a/linux/devices/startracker/StrHelper.cpp b/linux/devices/startracker/StrHelper.cpp index dcf56b59..8dd3641d 100644 --- a/linux/devices/startracker/StrHelper.cpp +++ b/linux/devices/startracker/StrHelper.cpp @@ -263,6 +263,10 @@ ReturnValue_t StrHelper::performImageUpload() { return returnvalue::FAILED; } std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); + if (file.bad()) { + return HasFileSystemIF::GENERIC_FILE_ERROR; + } + // Set position of next character to end of file input stream file.seekg(0, file.end); // tellg returns position of character in input stream diff --git a/tmtc b/tmtc index b32a9273..c9b269b0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit b32a9273ae4186a440685ffde7618f017cfdb268 +Subproject commit c9b269b01a419d0c636e373e09feef55aca27d66