fixed mutex bug
This commit is contained in:
parent
425cfd2aba
commit
49da48dc0d
@ -5,7 +5,6 @@
|
|||||||
#include <FSFWConfig.h>
|
#include <FSFWConfig.h>
|
||||||
|
|
||||||
#include <fsfw/ipc/MutexFactory.h>
|
#include <fsfw/ipc/MutexFactory.h>
|
||||||
#include <fsfw/ipc/MutexGuard.h>
|
|
||||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||||
|
|
||||||
#include <linux/spi/spidev.h>
|
#include <linux/spi/spidev.h>
|
||||||
@ -180,8 +179,11 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s
|
|||||||
|
|
||||||
/* Pull SPI CS low. For now, no support for active high given */
|
/* Pull SPI CS low. For now, no support for active high given */
|
||||||
if(gpioId != gpio::NO_GPIO) {
|
if(gpioId != gpio::NO_GPIO) {
|
||||||
/* GPIO access is mutex protected */
|
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||||
MutexGuard(spiMutex, timeoutType, timeoutMs);
|
if (result != RETURN_OK) {
|
||||||
|
sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
gpioComIF->pullLow(gpioId);
|
gpioComIF->pullLow(gpioId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +228,11 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s
|
|||||||
|
|
||||||
if(gpioId != gpio::NO_GPIO) {
|
if(gpioId != gpio::NO_GPIO) {
|
||||||
gpioComIF->pullHigh(gpioId);
|
gpioComIF->pullHigh(gpioId);
|
||||||
|
result = spiMutex->unlockMutex();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
sif::error << "SpiComIF::sendMessage: Failed to unlock mutex" << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -263,7 +270,11 @@ ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLe
|
|||||||
|
|
||||||
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
||||||
if(gpioId != gpio::NO_GPIO) {
|
if(gpioId != gpio::NO_GPIO) {
|
||||||
MutexGuard(spiMutex, timeoutType, timeoutMs);
|
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
sif::error << "SpiComIF::getSendSuccess: Failed to lock mutex" << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
gpioComIF->pullLow(gpioId);
|
gpioComIF->pullLow(gpioId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,6 +291,11 @@ ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLe
|
|||||||
|
|
||||||
if(gpioId != gpio::NO_GPIO) {
|
if(gpioId != gpio::NO_GPIO) {
|
||||||
gpioComIF->pullHigh(gpioId);
|
gpioComIF->pullHigh(gpioId);
|
||||||
|
result = spiMutex->unlockMutex();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
sif::error << "SpiComIF::getSendSuccess: Failed to unlock mutex" << std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user