Skip to content

Commit 42845fd

Browse files
nathancheekLeStarch
andcommitted
Backport FileDownlink timeout removal (#5287)
* Backport #4555 to v3.6.x * Ignore returned buffers when in COOLDOWN mode, matching IDLE mode behavior * Spelling fix --------- Co-authored-by: M Starch <LeStarch@googlemail.com>
1 parent 65e828d commit 42845fd

7 files changed

Lines changed: 14 additions & 103 deletions

File tree

Svc/FileDownlink/Events.fppi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ event DownlinkCanceled(
3333
id 0x03 \
3434
format "Canceled downlink of file {} to file {}"
3535

36-
@ The File Downlink component has detected a timeout. Downlink has been canceled.
37-
event DownlinkTimeout(
38-
sourceFileName: string size 100 @< The source filename
39-
destFileName: string size 100 @< The destination file name
40-
) \
41-
severity warning high \
42-
id 0x04 \
43-
format "Timeout occurred during downlink of file {} to file {}. Downlink has been canceled."
44-
4536
@ The File Downlink component has detected a timeout. Downlink has been canceled.
4637
event DownlinkPartialWarning(
4738
startOffset: U32 @< Starting file offset in bytes

Svc/FileDownlink/FileDownlink.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ namespace Svc {
4545

4646
void FileDownlink ::
4747
configure(
48-
U32 timeout,
4948
U32 cooldown,
5049
U32 cycleTime,
5150
U32 fileQueueDepth
5251
)
5352
{
54-
this->m_timeout = timeout;
5553
this->m_cooldown = cooldown;
5654
this->m_cycleTime = cycleTime;
5755
this->m_configured = true;
@@ -121,15 +119,7 @@ namespace Svc {
121119
break;
122120
}
123121
case Mode::WAIT: {
124-
//If current timeout is too-high and we are waiting for a packet, issue a timeout
125-
if (this->m_curTimer >= this->m_timeout) {
126-
this->m_curTimer = 0;
127-
this->log_WARNING_HI_DownlinkTimeout(this->m_file.getSourceName(), this->m_file.getDestName());
128-
this->enterCooldown();
129-
this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR);
130-
} else { //Otherwise update the current counter
131-
this->m_curTimer += m_cycleTime;
132-
}
122+
this->m_curTimer += m_cycleTime;
133123
break;
134124
}
135125
default:
@@ -184,16 +174,17 @@ namespace Svc {
184174
Fw::Buffer &fwBuffer
185175
)
186176
{
187-
//If this is a stale buffer (old, timed-out, or both), then ignore its return.
188-
//File downlink actions only respond to the return of the most-recently-sent buffer.
189-
if (this->m_lastBufferId != fwBuffer.getContext() + 1 ||
190-
this->m_mode.get() == Mode::IDLE) {
191-
return;
192-
}
193-
//Non-ignored buffers cannot be returned in "DOWNLINK" and "IDLE" state. Only in "WAIT", "CANCEL" state.
194-
FW_ASSERT(this->m_mode.get() == Mode::WAIT || this->m_mode.get() == Mode::CANCEL, this->m_mode.get());
177+
//If this is a stale buffer (old, timed-out, or both), then ignore its return.
178+
//File downlink actions only respond to the return of the most-recently-sent buffer.
179+
if (this->m_lastBufferId != fwBuffer.getContext() + 1 ||
180+
this->m_mode.get() == Mode::IDLE ||
181+
this->m_mode.get() == Mode::COOLDOWN) {
182+
return;
183+
}
184+
//Non-ignored buffers cannot be returned in "DOWNLINK", "IDLE", or "COOLDOWN" state. Only in "WAIT", "CANCEL" state.
185+
FW_ASSERT(this->m_mode.get() == Mode::WAIT || this->m_mode.get() == Mode::CANCEL, this->m_mode.get());
195186
//If the last packet has been sent (and is returning now) then finish the file
196-
if (this->m_lastCompletedType == Fw::FilePacket::T_END ||
187+
if (this->m_lastCompletedType == Fw::FilePacket::T_END ||
197188
this->m_lastCompletedType == Fw::FilePacket::T_CANCEL) {
198189
finishHelper(this->m_lastCompletedType == Fw::FilePacket::T_CANCEL);
199190
return;
@@ -501,7 +492,7 @@ namespace Svc {
501492
this->sendCancelPacket();
502493
this->m_lastCompletedType = Fw::FilePacket::T_CANCEL;
503494
}
504-
//If in downlink mode and currently downlinking data then continue with the next packer
495+
//If in downlink mode and currently downlinking data then continue with the next packet
505496
else if (this->m_mode.get() == Mode::DOWNLINK && this->m_lastCompletedType == Fw::FilePacket::T_START) {
506497
//Send the next packet, or fail doing so
507498
const Os::File::Status status = this->sendDataPacket(this->m_byteOffset);

Svc/FileDownlink/FileDownlink.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ namespace Svc {
272272
//! Configure FileDownlink component
273273
//!
274274
void configure(
275-
U32 timeout, //!< Timeout threshold (milliseconds) while in WAIT state
276275
U32 cooldown, //!< Cooldown (in ms) between finishing a downlink and starting the next file.
277276
U32 cycleTime, //!< Rate at which we are running
278277
U32 fileQueueDepth //!< Max number of items in file downlink queue

Svc/FileDownlink/docs/sdd.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ Name | Type | Kind | Purpose
6565
at component instantiation time:
6666

6767
* *downlinkPacketSize*: The size of the packets to use on downlink.
68-
* *timeout*: Max amount of time in ms to wait for a buffer return before aborting downlink
6968
* *cooldown*: The amount of time in ms to wait in a cooldown state before starting next downlink.
70-
* *cycle time*: Frequency in ms of clock pulses sent to `Run` port, used for timing timeouts and
71-
cooldown.
69+
* *cycle time*: Frequency in ms of clock pulses sent to `Run` port, used for cooldown.
7270
* *file queue depth*: The maximum number of files that can be held in the internal file downlink
7371
queue. Attempting to dispatch a SendFile command or port call while the queue is full will result
7472
in a busy error response.
@@ -123,7 +121,3 @@ Checklist |
123121
[Design](Checklist/design.xlsx) |
124122
[Code](Checklist/code.xlsx) |
125123
[Unit Test](Checklist/unit_test.xls) |
126-
127-
## 6 Unit Testing
128-
129-
TODO

Svc/FileDownlink/test/ut/FileDownlinkMain.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ TEST(FileDownlink, DownlinkPartial) {
2929
tester.downlinkPartial();
3030
}
3131

32-
TEST(FileDownlink, DownlinkTimeout) {
33-
Svc::FileDownlinkTester tester;
34-
tester.timeout();
35-
}
36-
3732
TEST(FileDownlink, SendFilePort) {
3833
Svc::FileDownlinkTester tester;
3934
tester.sendFilePort();

Svc/FileDownlink/test/ut/FileDownlinkTester.cpp

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#define CMD_SEQ 0
1919
#define QUEUE_DEPTH 10
2020

21-
#define TIMEOUT_MS 1000
2221
#define COOLDOWN_MS 500
2322
#define CYCLE_MS 100
2423
#define MAX_ALLOCATED 100
@@ -34,7 +33,7 @@ namespace Svc {
3433
component("FileDownlink"),
3534
buffers_index(0)
3635
{
37-
this->component.configure(TIMEOUT_MS, COOLDOWN_MS, CYCLE_MS, 10);
36+
this->component.configure(COOLDOWN_MS, CYCLE_MS, 10);
3837
this->connectPorts();
3938
this->initComponents();
4039
}
@@ -270,60 +269,6 @@ namespace Svc {
270269

271270
}
272271

273-
void FileDownlinkTester ::
274-
timeout()
275-
{
276-
// Assert idle mode
277-
ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.m_mode.get());
278-
279-
// Create a file
280-
const char *const sourceFileName = "source.bin";
281-
const char *const destFileName = "dest.bin";
282-
U8 data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
283-
FileBuffer fileBufferOut(data, sizeof(data));
284-
fileBufferOut.write(sourceFileName);
285-
286-
Fw::CmdStringArg sourceCmdStringArg(sourceFileName);
287-
Fw::CmdStringArg destCmdStringArg(destFileName);
288-
this->sendCmd_SendFile(
289-
INSTANCE,
290-
CMD_SEQ,
291-
sourceCmdStringArg,
292-
destCmdStringArg
293-
);
294-
this->component.doDispatch(); // Dispatch sendfile command
295-
this->component.Run_handler(0,0); // Pull file from queue
296-
297-
// Continue running the component without dispatching the responses
298-
for (U32 i = 0; i < TIMEOUT_MS/CYCLE_MS; i++) {
299-
this->component.Run_handler(0,0);
300-
ASSERT_CMD_RESPONSE_SIZE(0);
301-
}
302-
303-
this->component.Run_handler(0,0);
304-
ASSERT_CMD_RESPONSE_SIZE(1);
305-
Fw::CmdResponse expResp = FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? Fw::CmdResponse::OK : Fw::CmdResponse::EXECUTION_ERROR;
306-
ASSERT_CMD_RESPONSE(0, FileDownlink::OPCODE_SENDFILE, CMD_SEQ, expResp);
307-
308-
// Assert telemetry
309-
ASSERT_TLM_SIZE(1);
310-
ASSERT_TLM_PacketsSent_SIZE(1);
311-
312-
// Assert events
313-
ASSERT_EVENTS_SIZE(2);
314-
ASSERT_EVENTS_DownlinkTimeout_SIZE(1);
315-
ASSERT_EVENTS_SendStarted_SIZE(1);
316-
// printTextLogHistory(stdout);
317-
ASSERT_EVENTS_SendStarted(0, 10, sourceFileName, destFileName);
318-
ASSERT_EVENTS_DownlinkTimeout(0, sourceFileName, destFileName);
319-
320-
// Assert idle mode
321-
ASSERT_EQ(FileDownlink::Mode::COOLDOWN, this->component.m_mode.get());
322-
323-
// Remove the outgoing file
324-
this->removeFile(sourceFileName);
325-
}
326-
327272
void FileDownlinkTester ::
328273
sendFilePort()
329274
{

Svc/FileDownlink/test/ut/FileDownlinkTester.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ namespace Svc {
126126
//!
127127
void downlinkPartial();
128128

129-
//! Timeout
130-
//!
131-
void timeout();
132-
133129
//! sendFilePort
134130
//! Test downlinking a file via a port
135131
//!

0 commit comments

Comments
 (0)