event buffer request wip
This commit is contained in:
@ -39,9 +39,26 @@ ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
|
||||
case InternalState::UPDATE: {
|
||||
result = performUpdate();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(SUPV_UPDATE_SUCCESSFUL);
|
||||
triggerEvent(SUPV_UPDATE_SUCCESSFUL, result);
|
||||
} else if (result == PROCESS_TERMINATED) {
|
||||
// Event already triggered
|
||||
break;
|
||||
} else {
|
||||
triggerEvent(SUPV_UPDATE_FAILED);
|
||||
triggerEvent(SUPV_UPDATE_FAILED, result);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
case InternalState::REQUEST_EVENT_BUFFER: {
|
||||
result = performEventBufferRequest();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL, result);
|
||||
} else if (result == PROCESS_TERMINATED) {
|
||||
// Event already triggered
|
||||
break;
|
||||
}
|
||||
else {
|
||||
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_FAILED, result);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
@ -101,6 +118,23 @@ ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId,
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::startEventbBufferRequest(std::string path) {
|
||||
#ifdef XIPHOS_Q7S
|
||||
ReturnValue_t result = FilesystemHelper::checkPath(path);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
if (not std::filesystem::exists(path)) {
|
||||
return PATH_NOT_EXISTS;
|
||||
}
|
||||
eventBufferReq.path = path;
|
||||
internalState = InternalState::REQUEST_EVENT_BUFFER;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore.release();
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocSupvHelper::stopProcess() { terminate = true; }
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performUpdate() {
|
||||
@ -159,6 +193,28 @@ ReturnValue_t PlocSupvHelper::performUpdate() {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
|
||||
using namespace supv;
|
||||
ReturnValuet_t result = RETURN_OK;
|
||||
RequestLoggingData packet(RequestLoggingData::Sa::REQUEST_EVENT_BUFFERS);
|
||||
result = sendCommand(packet);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleAck();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleEventBufferReception();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleExe();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::prepareUpdate() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
supv::ApidOnlyPacket packet(supv::APID_PREPARE_UPDATE);
|
||||
@ -379,3 +435,33 @@ uint32_t PlocSupvHelper::getFileSize(std::string filename) {
|
||||
file.seekg(0, file.end);
|
||||
return file.tellg();
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
|
||||
std::sring filename = Filenaming::generateAbsoluteFilename(eventBufferReq.pat,
|
||||
eventBufferReq.filename, timestamping);
|
||||
std::ofstream file(filename, std::ios_base::app | std::ios_base::out);
|
||||
uint32_t packetsRead = 0;
|
||||
supv::TmPacket tmPacket;
|
||||
for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS - 1; 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 (result != RETURN_OK) {
|
||||
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;
|
||||
}
|
||||
file.write(reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
|
||||
packetLen - 1);
|
||||
}
|
||||
|
||||
file.write(reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
|
||||
packetLen - 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user