Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix to devel #997

Merged
merged 6 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 40 additions & 41 deletions Svc/FileDownlink/FileDownlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace Svc {
this->curTimer = 0;
this->log_WARNING_HI_DownlinkTimeout(this->file.sourceName, this->file.destName);
this->enterCooldown();
this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::OK : SendFileStatus::ERROR);
this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR);
} else { //Otherwise update the current counter
this->curTimer += cycleTime;
}
Expand All @@ -160,16 +160,15 @@ namespace Svc {
U32 length
)
{
struct FileEntry entry = {
.srcFilename = {0},
.destFilename = {0},
.offset = offset,
.length = length,
.source = FileDownlink::PORT,
.opCode = 0,
.cmdSeq = 0,
.context = cntxId++
};
struct FileEntry entry;
entry.srcFilename[0] = 0;
entry.destFilename[0] = 0;
entry.offset = offset;
entry.length = length;
entry.source = FileDownlink::PORT;
entry.opCode = 0;
entry.cmdSeq = 0;
entry.context = cntxId++;

FW_ASSERT(sourceFilename.length() < sizeof(entry.srcFilename));
FW_ASSERT(destFilename.length() < sizeof(entry.destFilename));
Expand All @@ -179,9 +178,9 @@ namespace Svc {
Os::Queue::QueueStatus status = fileQueue.send((U8 *) &entry, sizeof(entry), 0, Os::Queue::QUEUE_NONBLOCKING);

if(status != Os::Queue::QUEUE_OK) {
return SendFileResponse(SendFileStatus::ERROR, U32_MAX);
return SendFileResponse(SendFileStatus::STATUS_ERROR, U32_MAX);
}
return SendFileResponse(SendFileStatus::OK, entry.context);
return SendFileResponse(SendFileStatus::STATUS_OK, entry.context);
}

void FileDownlink ::
Expand Down Expand Up @@ -233,16 +232,16 @@ namespace Svc {
const Fw::CmdStringArg& destFilename
)
{
struct FileEntry entry = {
.srcFilename = {0},
.destFilename = {0},
.offset = 0,
.length = 0,
.source = FileDownlink::COMMAND,
.opCode = opCode,
.cmdSeq = cmdSeq,
.context = U32_MAX
};
struct FileEntry entry;
entry.srcFilename[0] = 0;
entry.destFilename[0] = 0;
entry.offset = 0;
entry.length = 0;
entry.source = FileDownlink::COMMAND;
entry.opCode = opCode;
entry.cmdSeq = cmdSeq;
entry.context = U32_MAX;


FW_ASSERT(sourceFilename.length() < sizeof(entry.srcFilename));
FW_ASSERT(destFilename.length() < sizeof(entry.destFilename));
Expand All @@ -266,16 +265,16 @@ namespace Svc {
U32 length
)
{
struct FileEntry entry = {
.srcFilename = {0},
.destFilename = {0},
.offset = startOffset,
.length = length,
.source = FileDownlink::COMMAND,
.opCode = opCode,
.cmdSeq = cmdSeq,
.context = U32_MAX
};
struct FileEntry entry;
entry.srcFilename[0] = 0;
entry.destFilename[0] = 0;
entry.offset = startOffset;
entry.length = length;
entry.source = FileDownlink::COMMAND;
entry.opCode = opCode;
entry.cmdSeq = cmdSeq;
entry.context = U32_MAX;


FW_ASSERT(sourceFilename.length() < sizeof(entry.srcFilename));
FW_ASSERT(destFilename.length() < sizeof(entry.destFilename));
Expand Down Expand Up @@ -310,13 +309,13 @@ namespace Svc {
statusToCmdResp(SendFileStatus status)
{
switch(status.e) {
case SendFileStatus::OK:
case SendFileStatus::STATUS_OK:
return Fw::COMMAND_OK;
case SendFileStatus::ERROR:
case SendFileStatus::STATUS_ERROR:
return Fw::COMMAND_EXECUTION_ERROR;
case SendFileStatus::INVALID:
case SendFileStatus::STATUS_INVALID:
return Fw::COMMAND_VALIDATION_ERROR;
case SendFileStatus::BUSY:
case SendFileStatus::STATUS_BUSY:
return Fw::COMMAND_BUSY;
default:
// Trigger assertion if given unknown status
Expand Down Expand Up @@ -359,15 +358,15 @@ namespace Svc {
if (status != Os::File::OP_OK) {
this->mode.set(Mode::IDLE);
this->warnings.fileOpenError();
sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::OK : SendFileStatus::ERROR);
sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR);
return;
}


if (startOffset >= this->file.size) {
this->enterCooldown();
this->log_WARNING_HI_DownlinkPartialFail(this->file.sourceName, this->file.destName, startOffset, this->file.size);
sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::OK : SendFileStatus::INVALID);
sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_INVALID);
return;
} else if (startOffset + length > this->file.size) {
// If the amount to downlink is greater than the file size, emit a Warning and then allow
Expand Down Expand Up @@ -526,7 +525,7 @@ namespace Svc {
if (status != Os::File::OP_OK) {
this->log_WARNING_HI_SendDataFail(this->file.sourceName, this->byteOffset);
this->enterCooldown();
this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::OK : SendFileStatus::ERROR);
this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR);
//Don't go to wait state
return;
}
Expand All @@ -551,7 +550,7 @@ namespace Svc {
this->log_ACTIVITY_HI_DownlinkCanceled(this->file.sourceName, this->file.destName);
}
this->enterCooldown();
sendResponse(SendFileStatus::OK);
sendResponse(SendFileStatus::STATUS_OK);
}

void FileDownlink ::
Expand Down
8 changes: 4 additions & 4 deletions Svc/FileDownlink/SendFileStatusEnumAi.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<enum namespace = "Svc" name="SendFileStatus">
<comment>Status of file transfer.</comment>
<item name="OK" value="0"/>
<item name="ERROR" value="1"/>
<item name="INVALID" value="2"/>
<item name="BUSY" value="3"/>
<item name="STATUS_OK" value="0"/>
<item name="STATUS_ERROR" value="1"/>
<item name="STATUS_INVALID" value="2"/>
<item name="STATUS_BUSY" value="3"/>
</enum>
4 changes: 2 additions & 2 deletions Svc/FileDownlink/test/ut/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ namespace Svc {
destFileNameString destFileArg(destFileName);
Svc::SendFileResponse resp = this->invoke_to_SendFile(0, srcFileArg, destFileArg, 0, 0);

ASSERT_EQ(resp.getstatus(), SendFileStatus::OK);
ASSERT_EQ(resp.getstatus(), SendFileStatus::STATUS_OK);
ASSERT_EQ(resp.getcontext(), 0);

this->component.Run_handler(0,0); // Dequeue file downlink request
Expand All @@ -350,7 +350,7 @@ namespace Svc {
}

ASSERT_from_FileComplete_SIZE(1);
ASSERT_from_FileComplete(0, Svc::SendFileResponse(SendFileStatus(SendFileStatus::OK), 0));
ASSERT_from_FileComplete(0, Svc::SendFileResponse(SendFileStatus(SendFileStatus::STATUS_OK), 0));

// Assert telemetry
ASSERT_TLM_SIZE(4);
Expand Down