diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 5f9015c3..b65224e5 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -23,7 +23,7 @@ ReturnValue_t openSpi(const std::string& devname, int flags, GpioIF* gpioIF, gpi * @param gpioIF Pointer to gpio interface to drive the chip select * @param mutex The spi mutex */ -void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex); +void closeSpi(int fd, gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex); } // namespace ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, @@ -74,7 +74,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } @@ -99,7 +99,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen } if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } idx++; @@ -111,14 +111,14 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } uint8_t* rxBuf = nullptr; result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); if (result != HasReturnvaluesIF::RETURN_OK) { - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); return result; } @@ -126,7 +126,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen // There must be a delay of at least 20 ms after sending the command. // Delay for 70 ms here and release the SPI bus for that duration. - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); usleep(RwDefinitions::SPI_REPLY_DELAY); result = openSpi(dev, O_RDWR, gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor); if (result != HasReturnvaluesIF::RETURN_OK) { @@ -141,13 +141,13 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen for (int idx = 0; idx < 10; idx++) { if (read(fileDescriptor, &byteRead, 1) != 1) { sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); return RwHandler::SPI_READ_FAILURE; } if (idx == 0) { if (byteRead != FLAG_BYTE) { sif::error << "Invalid data, expected start marker" << std::endl; - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); return RwHandler::NO_START_MARKER; } } @@ -158,7 +158,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (idx == 9) { sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); return RwHandler::NO_REPLY; } } @@ -198,7 +198,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen continue; } else { sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); result = RwHandler::INVALID_SUBSTITUTE; break; } @@ -232,7 +232,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen cookie->setTransferSize(decodedFrameLen); - closeSpi(gpioId, gpioIF, mutex); + closeSpi(fileDescriptor, gpioId, gpioIF, mutex); return result; } @@ -264,7 +264,8 @@ ReturnValue_t openSpi(const std::string& devname, int flags, GpioIF* gpioIF, gpi } return HasReturnvaluesIF::RETURN_OK; } -void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { +void closeSpi(int fd, gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { + close(fd); if (gpioId != gpio::NO_GPIO) { if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { sif::error << "closeSpi: Failed to pull chip select high" << std::endl; diff --git a/fsfw b/fsfw index ab2d7ca9..dafcaa60 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit ab2d7ca98fbfbb862e129ea57b65b712e3dec589 +Subproject commit dafcaa60079ba8e57753d389e6a569ee3eb0b7cb diff --git a/linux/devices/ploc/PlocMPSoCHandler.h b/linux/devices/ploc/PlocMPSoCHandler.h index a4044d3e..da71dd47 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.h +++ b/linux/devices/ploc/PlocMPSoCHandler.h @@ -108,7 +108,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { MessageQueueIF* eventQueue = nullptr; MessageQueueIF* commandActionHelperQueue = nullptr; - SourceSequenceCounter sequenceCount = 0; + SourceSequenceCounter sequenceCount; uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE]; diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index dae00d36..fd3462ec 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -333,7 +333,7 @@ void RwHandler::handleResetStatusReply(const uint8_t* packet) { PoolReadGuard rg(&lastResetStatusSet); uint8_t offset = 2; uint8_t resetStatus = packet[offset]; - if (resetStatus != RwDefinitions::CLEARED) { + if (resetStatus != 0) { internalState = InternalState::CLEAR_RESET_STATUS; lastResetStatusSet.lastNonClearedResetStatus = resetStatus; triggerEvent(RwDefinitions::RESET_OCCURED, resetStatus, 0); diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 9fcb6454..d6a43622 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -14,7 +14,7 @@ static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; //! [EXPORT] : [COMMENT] Reaction wheel signals an error state static constexpr Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); -static constexpr Event RESET_OCCURED = event::makeEvent(SUBSYSTEM_ID, 2, severity::HIGH); +static constexpr Event RESET_OCCURED = event::makeEvent(SUBSYSTEM_ID, 2, severity::LOW); static const uint32_t SPI_REPLY_DELAY = 70000; // us @@ -55,14 +55,13 @@ enum PoolIds : lp_id_t { enum States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING }; -enum LastResetStatus : uint8_t { - CLEARED = 0, - PIN_RESET = 1, - POR_PDR_BOR_RESET = 2, - SOFTWARE_RESET = 4, - INDEPENDENT_WATCHDOG_RESET = 8, - WINDOW_WATCHDOG_RESET = 16, - LOW_POWER_RESET = 32 +enum LastResetStatusBitPos : uint8_t { + PIN_RESET = 0, + POR_PDR_BOR_RESET = 1, + SOFTWARE_RESET = 2, + INDEPENDENT_WATCHDOG_RESET = 3, + WINDOW_WATCHDOG_RESET = 4, + LOW_POWER_RESET = 5 }; static const DeviceCommandId_t RESET_MCU = 1; diff --git a/tmtc b/tmtc index a648b7f7..bc02c9d6 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a648b7f76f59838c73ce5286570b2130af426f96 +Subproject commit bc02c9d6076dc3f6e0b37a67be04a445245fdd1e