bugfix for SPI
- Set transfer length to 0 for failed transfers
This commit is contained in:
parent
dac2d210b5
commit
f0b8457ba2
@ -179,12 +179,11 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
|||||||
uint32_t spiSpeed = 0;
|
uint32_t spiSpeed = 0;
|
||||||
spiCookie->getSpiParameters(spiMode, spiSpeed, nullptr);
|
spiCookie->getSpiParameters(spiMode, spiSpeed, nullptr);
|
||||||
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
||||||
spiCookie->assignWriteBuffer(sendData);
|
|
||||||
spiCookie->setTransferSize(sendLen);
|
|
||||||
|
|
||||||
bool fullDuplex = spiCookie->isFullDuplex();
|
bool fullDuplex = spiCookie->isFullDuplex();
|
||||||
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
||||||
bool csLockManual = spiCookie->getCsLockManual();
|
bool csLockManual = spiCookie->getCsLockManual();
|
||||||
|
spiCookie->setTransferSize(0);
|
||||||
|
|
||||||
MutexIF::TimeoutType csType;
|
MutexIF::TimeoutType csType;
|
||||||
dur_millis_t csTimeout = 0;
|
dur_millis_t csTimeout = 0;
|
||||||
@ -225,11 +224,15 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
|||||||
updateLinePolarity(fileDescriptor);
|
updateLinePolarity(fileDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spiCookie->assignWriteBuffer(sendData);
|
||||||
|
spiCookie->setTransferSize(sendLen);
|
||||||
|
|
||||||
/* Execute transfer */
|
/* Execute transfer */
|
||||||
if (fullDuplex) {
|
if (fullDuplex) {
|
||||||
/* Initiate a full duplex SPI transfer. */
|
/* Initiate a full duplex SPI transfer. */
|
||||||
retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), spiCookie->getTransferStructHandle());
|
retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), spiCookie->getTransferStructHandle());
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
|
spiCookie->setTransferSize(0);
|
||||||
utility::handleIoctlError("SpiComIF::sendMessage: ioctl error.");
|
utility::handleIoctlError("SpiComIF::sendMessage: ioctl error.");
|
||||||
result = FULL_DUPLEX_TRANSFER_FAILED;
|
result = FULL_DUPLEX_TRANSFER_FAILED;
|
||||||
}
|
}
|
||||||
@ -239,6 +242,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
|||||||
} else {
|
} else {
|
||||||
/* We write with a blocking half-duplex transfer here */
|
/* We write with a blocking half-duplex transfer here */
|
||||||
if (write(fileDescriptor, sendData, sendLen) != static_cast<ssize_t>(sendLen)) {
|
if (write(fileDescriptor, sendData, sendLen) != static_cast<ssize_t>(sendLen)) {
|
||||||
|
spiCookie->setTransferSize(0);
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "SpiComIF::sendMessage: Half-Duplex write operation failed!" << std::endl;
|
sif::warning << "SpiComIF::sendMessage: Half-Duplex write operation failed!" << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user