important bugfixes
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-05-11 15:45:38 +02:00
parent c5bccb661e
commit 625abcfd5b
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
6 changed files with 25 additions and 25 deletions

View File

@ -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 gpioIF Pointer to gpio interface to drive the chip select
* @param mutex The spi mutex * @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 } // namespace
ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, 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<ssize_t>(writeSize)) { if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) {
sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl;
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
return RwHandler::SPI_WRITE_FAILURE; 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<ssize_t>(writeSize)) { if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) {
sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl;
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
return RwHandler::SPI_WRITE_FAILURE; return RwHandler::SPI_WRITE_FAILURE;
} }
idx++; idx++;
@ -111,14 +111,14 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) { if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) {
sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl;
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
return RwHandler::SPI_WRITE_FAILURE; return RwHandler::SPI_WRITE_FAILURE;
} }
uint8_t* rxBuf = nullptr; uint8_t* rxBuf = nullptr;
result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
return result; 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. // 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. // 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); usleep(RwDefinitions::SPI_REPLY_DELAY);
result = openSpi(dev, O_RDWR, gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor); result = openSpi(dev, O_RDWR, gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor);
if (result != HasReturnvaluesIF::RETURN_OK) { 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++) { for (int idx = 0; idx < 10; idx++) {
if (read(fileDescriptor, &byteRead, 1) != 1) { if (read(fileDescriptor, &byteRead, 1) != 1) {
sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl;
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
return RwHandler::SPI_READ_FAILURE; return RwHandler::SPI_READ_FAILURE;
} }
if (idx == 0) { if (idx == 0) {
if (byteRead != FLAG_BYTE) { if (byteRead != FLAG_BYTE) {
sif::error << "Invalid data, expected start marker" << std::endl; sif::error << "Invalid data, expected start marker" << std::endl;
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
return RwHandler::NO_START_MARKER; return RwHandler::NO_START_MARKER;
} }
} }
@ -158,7 +158,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
if (idx == 9) { if (idx == 9) {
sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl;
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
return RwHandler::NO_REPLY; return RwHandler::NO_REPLY;
} }
} }
@ -198,7 +198,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
continue; continue;
} else { } else {
sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl;
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
result = RwHandler::INVALID_SUBSTITUTE; result = RwHandler::INVALID_SUBSTITUTE;
break; break;
} }
@ -232,7 +232,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
cookie->setTransferSize(decodedFrameLen); cookie->setTransferSize(decodedFrameLen);
closeSpi(gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, gpioIF, mutex);
return result; return result;
} }
@ -264,7 +264,8 @@ ReturnValue_t openSpi(const std::string& devname, int flags, GpioIF* gpioIF, gpi
} }
return HasReturnvaluesIF::RETURN_OK; 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 (gpioId != gpio::NO_GPIO) {
if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) {
sif::error << "closeSpi: Failed to pull chip select high" << std::endl; sif::error << "closeSpi: Failed to pull chip select high" << std::endl;

2
fsfw

@ -1 +1 @@
Subproject commit ab2d7ca98fbfbb862e129ea57b65b712e3dec589 Subproject commit dafcaa60079ba8e57753d389e6a569ee3eb0b7cb

View File

@ -108,7 +108,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
MessageQueueIF* eventQueue = nullptr; MessageQueueIF* eventQueue = nullptr;
MessageQueueIF* commandActionHelperQueue = nullptr; MessageQueueIF* commandActionHelperQueue = nullptr;
SourceSequenceCounter sequenceCount = 0; SourceSequenceCounter sequenceCount;
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE]; uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];

View File

@ -333,7 +333,7 @@ void RwHandler::handleResetStatusReply(const uint8_t* packet) {
PoolReadGuard rg(&lastResetStatusSet); PoolReadGuard rg(&lastResetStatusSet);
uint8_t offset = 2; uint8_t offset = 2;
uint8_t resetStatus = packet[offset]; uint8_t resetStatus = packet[offset];
if (resetStatus != RwDefinitions::CLEARED) { if (resetStatus != 0) {
internalState = InternalState::CLEAR_RESET_STATUS; internalState = InternalState::CLEAR_RESET_STATUS;
lastResetStatusSet.lastNonClearedResetStatus = resetStatus; lastResetStatusSet.lastNonClearedResetStatus = resetStatus;
triggerEvent(RwDefinitions::RESET_OCCURED, resetStatus, 0); triggerEvent(RwDefinitions::RESET_OCCURED, resetStatus, 0);

View File

@ -14,7 +14,7 @@ static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER;
//! [EXPORT] : [COMMENT] Reaction wheel signals an error state //! [EXPORT] : [COMMENT] Reaction wheel signals an error state
static constexpr Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); 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 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 States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING };
enum LastResetStatus : uint8_t { enum LastResetStatusBitPos : uint8_t {
CLEARED = 0, PIN_RESET = 0,
PIN_RESET = 1, POR_PDR_BOR_RESET = 1,
POR_PDR_BOR_RESET = 2, SOFTWARE_RESET = 2,
SOFTWARE_RESET = 4, INDEPENDENT_WATCHDOG_RESET = 3,
INDEPENDENT_WATCHDOG_RESET = 8, WINDOW_WATCHDOG_RESET = 4,
WINDOW_WATCHDOG_RESET = 16, LOW_POWER_RESET = 5
LOW_POWER_RESET = 32
}; };
static const DeviceCommandId_t RESET_MCU = 1; static const DeviceCommandId_t RESET_MCU = 1;

2
tmtc

@ -1 +1 @@
Subproject commit a648b7f76f59838c73ce5286570b2130af426f96 Subproject commit bc02c9d6076dc3f6e0b37a67be04a445245fdd1e