adaptions for new sagittalib
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2023-04-15 15:15:06 +02:00
parent 22370e3e1e
commit ae9f43c707
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 77 additions and 32 deletions

View File

@ -1,6 +1,7 @@
#include "ArcsecDatalinkLayer.h" #include "ArcsecDatalinkLayer.h"
extern "C" { extern "C" {
#include <wire/common/SLIP.h>
#include <wire/common/misc.h> #include <wire/common/misc.h>
} }
@ -15,35 +16,73 @@ ReturnValue_t ArcsecDatalinkLayer::checkRingBufForFrame(const uint8_t** decodedF
return DEC_IN_PROGRESS; return DEC_IN_PROGRESS;
} }
decodeRingBuf.readData(rxAnalysisBuffer, currentLen); decodeRingBuf.readData(rxAnalysisBuffer, currentLen);
bool startFound = false;
size_t startIdx = 0;
for (size_t idx = 0; idx < currentLen; idx++) { for (size_t idx = 0; idx < currentLen; idx++) {
enum arc_dec_result decResult = if (rxAnalysisBuffer[idx] != SLIP_START_AND_END) {
arc_transport_decode_body(rxAnalysisBuffer[idx], &slipInfo, decodedRxFrame, &rxFrameSize); continue;
switch (decResult) { }
case ARC_DEC_INPROGRESS: { if (not startFound) {
break; startFound = true;
} startIdx = idx;
case ARC_DEC_ERROR: { continue;
decodeRingBuf.deleteData(idx); }
return returnvalue::FAILED; // Now we can try decoding the whole frame.
} size_t encodedDataSize = 0;
case ARC_DEC_ASYNC: // TODO: Find SLIP ID
case ARC_DEC_SYNC: { slip_error_t slipError = slip_decode_frame(
// Reset length of SLIP struct for next frame decodedRxFrame, &rxFrameSize, rxAnalysisBuffer + startIdx,
slipInfo.length = 0; sizeof(rxAnalysisBuffer) - startIdx, &encodedDataSize, ARC_DEF_SAGITTA_SLIP_ID);
if (decodedFrame != nullptr) { decodeRingBuf.deleteData(idx + 1);
*decodedFrame = decodedRxFrame; switch (slipError) {
} case (SLIP_OK): {
frameLen = rxFrameSize;
decodeRingBuf.deleteData(idx);
return returnvalue::OK; return returnvalue::OK;
} }
default: case (SLIP_BAD_CRC): {
sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; return CRC_FAILURE;
break; }
case (SLIP_OVERFLOW): {
return SLIP_OVERFLOW_RETVAL;
}
// Should not happen, we searched for start and end marker..
case (SLIP_NO_END): {
return returnvalue::FAILED; return returnvalue::FAILED;
}
case (SLIP_ID_MISMATCH): {
return SLIP_ID_MISSMATCH_RETVAL;
}
default: {
return returnvalue::FAILED;
}
} }
} }
decodeRingBuf.deleteData(currentLen); // switch (decResult) {
// case ARC_DEC_INPROGRESS: {
// break;
// }
// case ARC_DEC_ERROR: {
// decodeRingBuf.deleteData(idx);
// return returnvalue::FAILED;
// }
// case ARC_DEC_ASYNC:
// case ARC_DEC_SYNC: {
// // Reset length of SLIP struct for next frame
// slipInfo.length = 0;
// if (decodedFrame != nullptr) {
// *decodedFrame = decodedRxFrame;
// }
// frameLen = rxFrameSize;
// decodeRingBuf.deleteData(idx);
// return returnvalue::OK;
// }
// default:
// sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl;
// break;
// return returnvalue::FAILED;
// }
// }
// decodeRingBuf.deleteData(currentLen);
return DEC_IN_PROGRESS; return DEC_IN_PROGRESS;
} }
@ -57,17 +96,17 @@ ReturnValue_t ArcsecDatalinkLayer::feedData(const uint8_t* rawData, size_t rawDa
} }
void ArcsecDatalinkLayer::reset() { void ArcsecDatalinkLayer::reset() {
slipInit(); // slipInit();
decodeRingBuf.clear(); decodeRingBuf.clear();
} }
void ArcsecDatalinkLayer::slipInit() { // void ArcsecDatalinkLayer::slipInit() {
slip_decode_init(rxBufferArc, sizeof(rxBufferArc), &slipInfo); // slip_decode_init(rxBufferArc, sizeof(rxBufferArc), &slipInfo);
} // }
void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, size_t length, const uint8_t** txFrame, void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, size_t length, const uint8_t** txFrame,
size_t& size) { size_t& size) {
arc_transport_encode_body(data, length, txEncoded, &size); slip_encode_frame(data, length, txEncoded, &size, ARC_DEF_SAGITTA_SLIP_ID);
if (txFrame != nullptr) { if (txFrame != nullptr) {
*txFrame = txEncoded; *txFrame = txEncoded;
} }

View File

@ -25,6 +25,8 @@ class ArcsecDatalinkLayer {
static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Detected CRC failure in received frame //! [EXPORT] : [COMMENT] Detected CRC failure in received frame
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t SLIP_OVERFLOW_RETVAL = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t SLIP_ID_MISSMATCH_RETVAL = MAKE_RETURN_CODE(0xA4);
static const uint8_t STATUS_OK = 0; static const uint8_t STATUS_OK = 0;
@ -77,7 +79,7 @@ class ArcsecDatalinkLayer {
// Decoded frame will be copied to this buffer // Decoded frame will be copied to this buffer
uint8_t decodedRxFrame[startracker::MAX_FRAME_SIZE]; uint8_t decodedRxFrame[startracker::MAX_FRAME_SIZE];
// Size of decoded frame // Size of decoded frame
uint32_t rxFrameSize = 0; size_t rxFrameSize = 0;
// Buffer where encoded frames will be stored. First byte of encoded frame represents type of // Buffer where encoded frames will be stored. First byte of encoded frame represents type of
// reply // reply
@ -85,7 +87,7 @@ class ArcsecDatalinkLayer {
// Size of encoded frame // Size of encoded frame
uint32_t txFrameSize = 0; uint32_t txFrameSize = 0;
slip_decode_state slipInfo; // slip_decode_state slipInfo;
void slipInit(); void slipInit();
}; };

View File

@ -5,7 +5,11 @@
#include <mission/acs/str/strJsonCommands.h> #include <mission/acs/str/strJsonCommands.h>
extern "C" { extern "C" {
#include <sagitta/client/arc_client.h> #include <sagitta/client/actionreq.h>
#include <sagitta/client/client_tm_structs.h>
#include <sagitta/client/parameter.h>
#include <sagitta/client/telemetry.h>
#include <wire/common/genericstructs.h>
} }
#include <atomic> #include <atomic>

@ -1 +1 @@
Subproject commit 29e876671a72fcdb0b393e2f692303725f00724f Subproject commit 11829cdacf764f4e5f6bc6755be3096e92f146f1