supervisor event buffer request
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
#include "bsp_q7s/memory/FilesystemHelper.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "mission/utility/Timestamp.h"
|
||||
#include "mission/utility/Filenaming.h"
|
||||
|
||||
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId) {}
|
||||
|
||||
@ -195,7 +196,7 @@ ReturnValue_t PlocSupvHelper::performUpdate() {
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
|
||||
using namespace supv;
|
||||
ReturnValuet_t result = RETURN_OK;
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
RequestLoggingData packet(RequestLoggingData::Sa::REQUEST_EVENT_BUFFERS);
|
||||
result = sendCommand(packet);
|
||||
if (result != RETURN_OK) {
|
||||
@ -213,6 +214,7 @@ ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::prepareUpdate() {
|
||||
@ -337,8 +339,8 @@ ReturnValue_t PlocSupvHelper::handleTmReception(supv::TmPacket* tmPacket, size_t
|
||||
}
|
||||
}
|
||||
if (remainingBytes != 0) {
|
||||
sif::warning << "PlocSupvHelper::handleTmReception: Failed to receive reply" << std::endl;
|
||||
triggerEvent(SUPV_MISSING_EXE, remainingBytes, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocSupvHelper::handleTmReception: Failed to read " << remainingBytes
|
||||
<< " bytes" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
result = tmPacket->checkCrc();
|
||||
@ -437,31 +439,40 @@ uint32_t PlocSupvHelper::getFileSize(std::string filename) {
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
|
||||
std::sring filename = Filenaming::generateAbsoluteFilename(eventBufferReq.pat,
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
std::string filename = Filenaming::generateAbsoluteFilename(eventBufferReq.path,
|
||||
eventBufferReq.filename, timestamping);
|
||||
std::ofstream file(filename, std::ios_base::app | std::ios_base::out);
|
||||
uint32_t packetsRead = 0;
|
||||
size_t requestLen = 0;
|
||||
supv::TmPacket tmPacket;
|
||||
for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS - 1; packetsRead++) {
|
||||
for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS; packetsRead++) {
|
||||
if (terminate) {
|
||||
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_TERMINATED, packetsRead - 1);
|
||||
file.close();
|
||||
return PROCESS_TERMINATED;
|
||||
}
|
||||
result = handleTmReception(&tmPacket, SIZE_EVENT_BUFFER_FULL_PACKET);
|
||||
if (packetsRead == NUM_EVENT_BUFFER_PACKETS - 1) {
|
||||
requestLen = SIZE_EVENT_BUFFER_LAST_PACKET;
|
||||
} else {
|
||||
requestLen = SIZE_EVENT_BUFFER_FULL_PACKET;
|
||||
}
|
||||
result = handleTmReception(&tmPacket, requestLen);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocSupvHelper::handleEventBufferReception: Failed while trying to read packet"
|
||||
<< " " << packetsRead + 1 << std::endl;
|
||||
file.close();
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = tmPacket.getAPID();
|
||||
if (apid != supv::APID_MRAM_DUMP_TM) {
|
||||
sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet "
|
||||
<< "with APID " << std::hex << std::endl;
|
||||
return EVENT_BUFFER_REQUEST_INVALID_APID;
|
||||
<< "with APID 0x" << std::hex << apid << std::endl;
|
||||
file.close();
|
||||
return EVENT_BUFFER_REPLY_INVALID_APID;
|
||||
}
|
||||
file.write(reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
|
||||
packetLen - 1);
|
||||
file.write(reinterpret_cast<const char*>(tmPacket.getPacketData()),
|
||||
tmPacket.getPayloadDataLength());
|
||||
}
|
||||
|
||||
file.write(reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
|
||||
packetLen - 1);
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user