continue testing
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
2023-02-16 19:51:30 +01:00
parent fb3359b44f
commit 9d59f960a4
5 changed files with 43 additions and 31 deletions

View File

@ -59,23 +59,23 @@ ReturnValue_t RwPollingTask::performOperation(uint8_t operationCode) {
if (readAllRws(rws::SET_SPEED) != returnvalue::OK) {
continue;
}
prepareSimpleCommand(rws::GET_LAST_RESET_STATUS);
if (writeAndReadAllRws(rws::GET_LAST_RESET_STATUS) != returnvalue::OK) {
continue;
}
prepareSimpleCommand(rws::GET_RW_STATUS);
if (writeAndReadAllRws(rws::GET_RW_STATUS) != returnvalue::OK) {
continue;
}
prepareSimpleCommand(rws::GET_TEMPERATURE);
if (writeAndReadAllRws(rws::GET_TEMPERATURE) != returnvalue::OK) {
continue;
}
prepareSimpleCommand(rws::CLEAR_LAST_RESET_STATUS);
if (writeAndReadAllRws(rws::CLEAR_LAST_RESET_STATUS) != returnvalue::OK) {
continue;
}
handleSpecialRequests();
// prepareSimpleCommand(rws::GET_LAST_RESET_STATUS);
// if (writeAndReadAllRws(rws::GET_LAST_RESET_STATUS) != returnvalue::OK) {
// continue;
// }
// prepareSimpleCommand(rws::GET_RW_STATUS);
// if (writeAndReadAllRws(rws::GET_RW_STATUS) != returnvalue::OK) {
// continue;
// }
// prepareSimpleCommand(rws::GET_TEMPERATURE);
// if (writeAndReadAllRws(rws::GET_TEMPERATURE) != returnvalue::OK) {
// continue;
// }
// prepareSimpleCommand(rws::CLEAR_LAST_RESET_STATUS);
// if (writeAndReadAllRws(rws::CLEAR_LAST_RESET_STATUS) != returnvalue::OK) {
// continue;
// }
// handleSpecialRequests();
}
return returnvalue::OK;
@ -208,19 +208,20 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf
int fd = 0;
gpioId_t gpioId = rwCookie.getChipSelectPin();
uint8_t byteRead = 0;
for (unsigned idx = 0; idx < MAX_RETRIES_REPLY; idx++) {
result = openSpi(O_RDWR, fd);
if (result != returnvalue::OK) {
return result;
}
pullCsLow(gpioId, spiLock, gpioIF);
bool exitOuter = false;
for (unsigned retryIdx = 0; retryIdx < MAX_RETRIES_REPLY; retryIdx++) {
/**
* The reaction wheel responds with empty frames while preparing the reply data.
* However, receiving more than 5 empty frames will be interpreted as an error.
*/
for (int idx = 0; idx < 5; idx++) {
result = openSpi(O_RDWR, fd);
if (result != returnvalue::OK) {
return result;
}
pullCsLow(gpioId, gpioIF);
if (read(fd, &byteRead, 1) != 1) {
sif::error << "RwPollingTask: Read failed" << std::endl;
sif::error << "RwPollingTask: Read failed. " << strerror(errno) << std::endl;
pullCsHigh(gpioId, gpioIF);
closeSpi(fd);
return rws::SPI_READ_FAILURE;
@ -235,6 +236,7 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf
}
if (byteRead != rws::FRAME_DELIMITER) {
exitOuter = true;
break;
}
@ -244,8 +246,11 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf
sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl;
return rws::NO_REPLY;
}
TaskFactory::delayTask(5);
}
if(exitOuter) {
break;
}
TaskFactory::delayTask(5);
}
#if FSFW_HAL_SPI_WIRETAPPING == 1
sif::info << "RW start marker detected" << std::endl;
@ -448,7 +453,7 @@ ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie) {
sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl;
return returnvalue::FAILED;
}
pullCsLow(gpioId, spiLock, gpioIF);
pullCsLow(gpioId, gpioIF);
// Add datalinklayer like specified in the datasheet.
size_t lenToSend = 0;
rws::encodeHdlc(writeBuffer.data(), writeLen, encodedBuffer.data(), lenToSend);
@ -461,7 +466,7 @@ ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie) {
return returnvalue::OK;
}
ReturnValue_t RwPollingTask::pullCsLow(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF) {
ReturnValue_t RwPollingTask::pullCsLow(gpioId_t gpioId, GpioIF& gpioIF) {
ReturnValue_t result = spiLock->lockMutex(TIMEOUT_TYPE, TIMEOUT_MS);
if (result != returnvalue::OK) {
sif::debug << "RwPollingTask::pullCsLow: Failed to lock mutex" << std::endl;

View File

@ -74,7 +74,7 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev
ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override;
ReturnValue_t openSpi(int flags, int& fd);
ReturnValue_t pullCsLow(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF);
ReturnValue_t pullCsLow(gpioId_t gpioId, GpioIF& gpioIF);
void prepareSimpleCommand(DeviceCommandId_t id);
ReturnValue_t prepareSetSpeedCmd(uint8_t rwIdx);