more simplfications
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2023-03-21 20:59:59 +01:00
parent fabb643026
commit 9e719d455a
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 28 additions and 45 deletions

View File

@ -39,6 +39,7 @@ ReturnValue_t ArcsecDatalinkLayer::checkRingBufForFrame(const uint8_t** decodedF
return returnvalue::FAILED;
}
}
decodeRingBuf.deleteData(currentLen);
return DEC_IN_PROGRESS;
}

View File

@ -488,10 +488,10 @@ ReturnValue_t StrComHandler::performFlashRead() {
return returnvalue::OK;
}
ReturnValue_t StrComHandler::sendAndRead(size_t size,
uint32_t failParameter, const uint8_t** replyFrame,
size_t& replyLen) {
ReturnValue_t StrComHandler::sendAndRead(size_t size, uint32_t failParameter,
const uint8_t** replyFrame, size_t& replyLen) {
ReturnValue_t result = returnvalue::OK;
uint8_t nextDelayMs = 1;
ReturnValue_t decResult = returnvalue::OK;
const uint8_t* sendData;
@ -503,40 +503,21 @@ ReturnValue_t StrComHandler::sendAndRead(size_t size,
triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, failParameter);
return returnvalue::FAILED;
}
replyTimeout.resetTimer();
while (true) {
handleSerialReception();
// TODO: Read periodically into ring buffer, analyse ring buffer for reply frames periodically.
// result = uartComIF->requestReceiveMessage(comCookie, startracker::MAX_FRAME_SIZE * 2 + 2);
// if (result != returnvalue::OK) {
// sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl;
// triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter);
// return returnvalue::FAILED;
// }
// result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen);
// if (result != returnvalue::OK) {
// sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl;
// triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter);
// return returnvalue::FAILED;
// }
// if (receivedDataLen == 0 && missedReplies < MAX_POLLS) {
// missedReplies++;
// continue;
// } else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) {
// triggerEvent(STR_HELPER_NO_REPLY, failParameter);
// return returnvalue::FAILED;
// } else {
// missedReplies = 0;
// }
// TODO: Use frame detector function here instead.
result = datalinkLayer.checkRingBufForFrame(replyFrame, replyLen);
//if(result == )
// decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft);
// if (bytesLeft != 0) {
// // This should never happen
// sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl;
// triggerEvent(STR_HELPER_COM_ERROR, result, failParameter);
// return returnvalue::FAILED;
// }
if (result == returnvalue::OK) {
return returnvalue::OK;
}
if (replyTimeout.hasTimedOut()) {
triggerEvent(STR_HELPER_REPLY_TIMEOUT, failParameter, replyTimeout.getTimeoutMs());
return returnvalue::FAILED;
}
TaskFactory::delayTask(nextDelayMs);
if (nextDelayMs < 32) {
nextDelayMs *= 2;
}
}
if (decResult != returnvalue::OK) {
triggerEvent(STR_HELPER_DEC_ERROR, decResult, failParameter);

View File

@ -75,29 +75,29 @@ class StrComHandler : public SystemObject, public DeviceCommunicationIF, public
//! P1: Return code of failed communication interface read call
//! P1: Upload/download position for which the read call failed
static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(10, severity::LOW);
//! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off)
//! P1: Position of upload or download packet for which no reply was sent
static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(11, severity::LOW);
//! [EXPORT] : [COMMENT] Star tracker did not send a valid reply for a certain timeout.
//! P1: Position of upload or download packet for which the packet wa sent. P2: Timeout
static const Event STR_HELPER_REPLY_TIMEOUT = MAKE_EVENT(11, severity::LOW);
//! [EXPORT] : [COMMENT] Error during decoding of received reply occurred
// P1: Return value of decoding function
// P2: Position of upload/download packet, or address of flash write/read request
static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(12, severity::LOW);
//! P1: Return value of decoding function
//! P2: Position of upload/download packet, or address of flash write/read request
static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(13, severity::LOW);
//! [EXPORT] : [COMMENT] Position mismatch
//! P1: The expected position and thus the position for which the image upload/download failed
static const Event POSITION_MISMATCH = MAKE_EVENT(13, severity::LOW);
static const Event POSITION_MISMATCH = MAKE_EVENT(14, severity::LOW);
//! [EXPORT] : [COMMENT] Specified file does not exist
//! P1: Internal state of str helper
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(14, severity::LOW);
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(15, severity::LOW);
//! [EXPORT] : [COMMENT] Sending packet to star tracker failed
//! P1: Return code of communication interface sendMessage function
//! P2: Position of upload/download packet, or address of flash write/read request for which
//! sending failed
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(15, severity::LOW);
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(16, severity::LOW);
//! [EXPORT] : [COMMENT] Communication interface requesting reply failed
//! P1: Return code of failed request
//! P1: Upload/download position, or address of flash write/read request for which transmission
//! failed
static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(16, severity::LOW);
static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(17, severity::LOW);
StrComHandler(object_id_t objectId);
virtual ~StrComHandler();
@ -311,7 +311,8 @@ class StrComHandler : public SystemObject, public DeviceCommunicationIF, public
*
* @return returnvalue::OK if successful, otherwise returnvalue::FAILED
*/
ReturnValue_t sendAndRead(size_t size, uint32_t parameter,const uint8_t **replyFrame, size_t&replyLen);
ReturnValue_t sendAndRead(size_t size, uint32_t parameter, const uint8_t **replyFrame,
size_t &replyLen);
/**
* @brief Checks the header (type id and status fields) of the action reply