Skip to content

Commit d671a93

Browse files
Topologies
1 parent 6162dc3 commit d671a93

File tree

3 files changed

+2
-84
lines changed

3 files changed

+2
-84
lines changed

FprimeZephyrReference/Components/PayloadHandler/PayloadHandler.cpp

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -25,88 +25,7 @@ void PayloadHandler ::in_port_handler(FwIndexType portNum, Fw::Buffer& buffer, c
2525

2626
this->log_ACTIVITY_LO_UartReceived();
2727

28-
const U8* data = buffer.getData();
29-
FwSizeType size = buffer.getSize();
30-
31-
for (FwSizeType i = 0; i < size; i++) {
32-
// Process each byte of data as needed
33-
U8 byte = data[i];
34-
35-
36-
if (!m_receiving){
37-
// We are not currently receiving a file
38-
39-
// Append byte to line buffer: This is how we check the header to determine data type
40-
if (m_lineIndex < sizeof(m_lineBuffer) - 1) {
41-
m_lineBuffer[m_lineIndex++] = byte;
42-
}
43-
this->log_ACTIVITY_LO_ByteReceived(byte);
44-
// Have we reached the end of the line? If so that means we have a header
45-
// Check to see what the header is.
46-
if (byte == '\n' || byte == '\r') {
47-
m_lineBuffer[m_lineIndex] = 0; // Null-terminate
48-
m_lineIndex = 0;
49-
50-
// Check the header.
51-
// Right now I'm just checking for an image start tag, but we can expand this to other types later
52-
if (strstr((const char*)m_lineBuffer, "<IMG_START>")) {
53-
this->log_ACTIVITY_LO_ImageHeaderReceived();
54-
m_receiving = true;
55-
m_bytes_received = 0;
56-
m_expected_size = 0;
57-
continue;
58-
}
59-
60-
// If in receiving mode and expected size not set, this line is the size
61-
if (m_receiving && m_expected_size == 0) {
62-
63-
// First we set the expected size
64-
m_expected_size = atoi((const char*)m_lineBuffer);
65-
66-
67-
// Then we open the file to write to, which we will be writing to over a lot of iterations
68-
if (m_data_file_count >= 9) {
69-
m_data_file_count = 0;
70-
}
71-
72-
char filenameBuffer[20];
73-
snprintf(filenameBuffer, sizeof(filenameBuffer), "payload_%d.jpg", m_data_file_count);
74-
m_currentFilename = filenameBuffer;
75-
76-
// Open the file and prepare to write in the next iteration
77-
Os::File::Status fileStatus = m_file.open(m_currentFilename.c_str(), Os::File::OPEN_CREATE, Os::File::OVERWRITE);
78-
if (fileStatus != Os::File::OP_OK) {
79-
m_receiving = false;
80-
continue;
81-
}
82-
continue;
83-
}
84-
}
85-
86-
87-
} else if (m_bytes_received < m_expected_size){
88-
// We are currently receiving a file
89-
90-
// Cast byte to a buffer
91-
// Write a byte to the file
92-
FwSizeType oneByte = 1;
93-
m_file.write(&byte, oneByte);
94-
this->log_ACTIVITY_LO_ByteReceived(byte);
95-
m_bytes_received++;
96-
97-
// Check to see if we are done receiving
98-
if (m_bytes_received >= m_expected_size){
99-
m_file.flush();
100-
m_file.close();
101-
m_receiving = false;
102-
m_data_file_count++;
103-
104-
// Log data received event
105-
Fw::LogStringArg logPath(m_currentFilename.c_str());
106-
this->log_ACTIVITY_HI_DataReceived(m_bytes_received, logPath);
107-
}
108-
}
109-
}
28+
11029
}
11130

11231
// ----------------------------------------------------------------------

FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,4 @@ module ReferenceDeployment {
9494

9595
instance peripheralUartDriver: Zephyr.ZephyrUartDriver base id 0x10032000
9696

97-
9897
}

FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ module ReferenceDeployment {
126126
rateGroup10Hz.RateGroupMemberOut[0] -> comDriver.schedIn
127127
rateGroup10Hz.RateGroupMemberOut[1] -> ComCcsdsUart.aggregator.timeout
128128
rateGroup10Hz.RateGroupMemberOut[2] -> ComCcsds.aggregator.timeout
129-
#rateGroup10Hz.RateGroupMemberOut[3] -> peripheralUartDriver.schedIn
129+
rateGroup10Hz.RateGroupMemberOut[3] -> peripheralUartDriver.schedIn
130130

131131
# Slow rate (1Hz) rate group
132132
rateGroupDriver.CycleOut[Ports_RateGroups.rateGroup1Hz] -> rateGroup1Hz.CycleIn

0 commit comments

Comments
 (0)