Update sagittactl to v10.7 #605
@ -1,6 +1,7 @@
|
||||
#include "ArcsecDatalinkLayer.h"
|
||||
|
||||
extern "C" {
|
||||
#include <wire/common/SLIP.h>
|
||||
#include <wire/common/misc.h>
|
||||
}
|
||||
|
||||
@ -15,35 +16,73 @@ ReturnValue_t ArcsecDatalinkLayer::checkRingBufForFrame(const uint8_t** decodedF
|
||||
return DEC_IN_PROGRESS;
|
||||
}
|
||||
decodeRingBuf.readData(rxAnalysisBuffer, currentLen);
|
||||
|
||||
bool startFound = false;
|
||||
size_t startIdx = 0;
|
||||
for (size_t idx = 0; idx < currentLen; idx++) {
|
||||
enum arc_dec_result decResult =
|
||||
arc_transport_decode_body(rxAnalysisBuffer[idx], &slipInfo, decodedRxFrame, &rxFrameSize);
|
||||
switch (decResult) {
|
||||
case ARC_DEC_INPROGRESS: {
|
||||
break;
|
||||
if (rxAnalysisBuffer[idx] != SLIP_START_AND_END) {
|
||||
continue;
|
||||
}
|
||||
case ARC_DEC_ERROR: {
|
||||
decodeRingBuf.deleteData(idx);
|
||||
return returnvalue::FAILED;
|
||||
if (not startFound) {
|
||||
startFound = true;
|
||||
startIdx = idx;
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
// Now we can try decoding the whole frame.
|
||||
size_t encodedDataSize = 0;
|
||||
// TODO: Find SLIP ID
|
||||
slip_error_t slipError = slip_decode_frame(
|
||||
decodedRxFrame, &rxFrameSize, rxAnalysisBuffer + startIdx,
|
||||
sizeof(rxAnalysisBuffer) - startIdx, &encodedDataSize, ARC_DEF_SAGITTA_SLIP_ID);
|
||||
decodeRingBuf.deleteData(idx + 1);
|
||||
switch (slipError) {
|
||||
case (SLIP_OK): {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
default:
|
||||
sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl;
|
||||
break;
|
||||
case (SLIP_BAD_CRC): {
|
||||
return CRC_FAILURE;
|
||||
}
|
||||
case (SLIP_OVERFLOW): {
|
||||
return SLIP_OVERFLOW_RETVAL;
|
||||
}
|
||||
// Should not happen, we searched for start and end marker..
|
||||
case (SLIP_NO_END): {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -57,17 +96,17 @@ ReturnValue_t ArcsecDatalinkLayer::feedData(const uint8_t* rawData, size_t rawDa
|
||||
}
|
||||
|
||||
void ArcsecDatalinkLayer::reset() {
|
||||
slipInit();
|
||||
// slipInit();
|
||||
decodeRingBuf.clear();
|
||||
}
|
||||
|
||||
void ArcsecDatalinkLayer::slipInit() {
|
||||
slip_decode_init(rxBufferArc, sizeof(rxBufferArc), &slipInfo);
|
||||
}
|
||||
// void ArcsecDatalinkLayer::slipInit() {
|
||||
// slip_decode_init(rxBufferArc, sizeof(rxBufferArc), &slipInfo);
|
||||
// }
|
||||
|
||||
void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, size_t length, const uint8_t** txFrame,
|
||||
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) {
|
||||
*txFrame = txEncoded;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ class ArcsecDatalinkLayer {
|
||||
static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1);
|
||||
//! [EXPORT] : [COMMENT] Detected CRC failure in received frame
|
||||
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;
|
||||
|
||||
@ -77,7 +79,7 @@ class ArcsecDatalinkLayer {
|
||||
// Decoded frame will be copied to this buffer
|
||||
uint8_t decodedRxFrame[startracker::MAX_FRAME_SIZE];
|
||||
// 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
|
||||
// reply
|
||||
@ -85,7 +87,7 @@ class ArcsecDatalinkLayer {
|
||||
// Size of encoded frame
|
||||
uint32_t txFrameSize = 0;
|
||||
|
||||
slip_decode_state slipInfo;
|
||||
// slip_decode_state slipInfo;
|
||||
|
||||
void slipInit();
|
||||
};
|
||||
|
@ -5,7 +5,11 @@
|
||||
#include <mission/acs/str/strJsonCommands.h>
|
||||
|
||||
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>
|
||||
|
2
thirdparty/sagittactl
vendored
2
thirdparty/sagittactl
vendored
@ -1 +1 @@
|
||||
Subproject commit 29e876671a72fcdb0b393e2f692303725f00724f
|
||||
Subproject commit 11829cdacf764f4e5f6bc6755be3096e92f146f1
|
Loading…
Reference in New Issue
Block a user