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

This commit is contained in:
Robin Müller 2023-02-16 19:51:30 +01:00
parent fb3359b44f
commit 9d59f960a4
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 43 additions and 31 deletions

View File

@ -74,16 +74,23 @@ int obsw::obsw() {
scheduling::initMission();
#if OBSW_COMMAND_SAFE_MODE_AT_STARTUP == 1
// Command the EIVE system to safe mode
auto sysQueueId = satsystem::EIVE_SYSTEM.getCommandQueue();
CommandMessage msg;
#if OBSW_COMMAND_SAFE_MODE_AT_STARTUP == 1
ModeMessage::setCmdModeMessage(msg, acs::AcsMode::SAFE, 0);
ReturnValue_t result =
MessageQueueSenderIF::sendMessage(sysQueueId, &msg, MessageQueueIF::NO_QUEUE, false);
if (result != returnvalue::OK) {
sif::error << "Sending safe mode command to EIVE system failed" << std::endl;
}
#else
ModeMessage::setModeAnnounceMessage(msg, true);
ReturnValue_t result =
MessageQueueSenderIF::sendMessage(sysQueueId, &msg, MessageQueueIF::NO_QUEUE, false);
if (result != returnvalue::OK) {
sif::error << "Sending safe mode command to EIVE system failed" << std::endl;
}
#endif
for (;;) {

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);

View File

@ -62,7 +62,7 @@ static constexpr Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH);
static constexpr Event RESET_OCCURED = event::makeEvent(SUBSYSTEM_ID, 2, severity::LOW);
//! Minimal delay as specified by the datasheet.
static const uint32_t SPI_REPLY_DELAY = 20000; // us
static const uint32_t SPI_REPLY_DELAY = 70000; // us
enum PoolIds : lp_id_t {
TEMPERATURE_C,

View File

@ -167,7 +167,7 @@ bool RwAssembly::isUseable(object_id_t object, Mode_t mode) {
return false;
}
ReturnValue_t RwAssembly::initialize() { return SubsystemBase::initialize(); }
ReturnValue_t RwAssembly::initialize() { return AssemblyBase::initialize(); }
void RwAssembly::handleModeTransitionFailed(ReturnValue_t result) {
if (targetMode == MODE_OFF) {