@@ -61,12 +61,6 @@ Fw::Success FpySequencer::validate() {
6161 return Fw::Success::FAILURE;
6262 }
6363
64- // Read and parse arg_specs
65- readStatus = this ->readArgSpecs (sequenceFile);
66- if (readStatus != Fw::Success::SUCCESS) {
67- return Fw::Success::FAILURE;
68- }
69-
7064 readStatus =
7165 readBytes (sequenceFile, this ->m_sequenceObj .get_header ().get_bodySize (), FpySequencer_FileReadStage::BODY);
7266
@@ -111,12 +105,6 @@ Fw::Success FpySequencer::validate() {
111105 return Fw::Success::FAILURE;
112106 }
113107
114- if (this ->m_sequenceArgs .get_size () != this ->m_expectedArgSize ) {
115- this ->log_WARNING_HI_ArgSizeMismatch (this ->m_expectedArgSize , this ->m_sequenceArgs .get_size (),
116- this ->m_sequenceFilePath );
117- return Fw::Success::FAILURE;
118- }
119-
120108 return Fw::Success::SUCCESS;
121109}
122110
@@ -153,89 +141,56 @@ Fw::Success FpySequencer::readHeader() {
153141 return Fw::Success::SUCCESS;
154142}
155143
156- // Helper function to read and deserialize a variable-length string field
157- // Reads length byte, then the string data into the provided buffer
158- Fw::Success FpySequencer::deserializeStringField (Os::File& file, U8* buffer, U8& outLength) {
159- // Read length byte
160- Fw::Success readStatus = this ->readBytes (file, sizeof (U8), FpySequencer_FileReadStage::BODY);
161- if (readStatus != Fw::Success::SUCCESS) {
162- return Fw::Success::FAILURE;
163- }
164-
165- Fw::SerializeStatus deserStatus = this ->m_sequenceBuffer .deserializeTo (outLength);
166- if (deserStatus != Fw::SerializeStatus::FW_SERIALIZE_OK) {
167- this ->log_WARNING_HI_FileReadDeserializeError (
168- FpySequencer_FileReadStage::BODY, this ->m_sequenceFilePath , static_cast <I32>(deserStatus),
169- this ->m_sequenceBuffer .getDeserializeSizeLeft (), this ->m_sequenceBuffer .getSize ());
170- return Fw::Success::FAILURE;
171- }
172-
173- // Validate length is non-zero (reject empty strings)
174- if (outLength == 0 ) {
175- this ->log_WARNING_HI_InvalidArgSpec (this ->m_sequenceFilePath );
176- return Fw::Success::FAILURE;
177- }
178-
179- // Validate length doesn't exceed buffer capacity
180- if (outLength > Fpy::MAX_ARG_SPEC_NAME_LEN) {
181- this ->log_WARNING_HI_ArgSpecStringLengthExceedsMax (outLength, Fpy::MAX_ARG_SPEC_NAME_LEN, this ->m_sequenceFilePath );
182- return Fw::Success::FAILURE;
183- }
184-
185- // Read string bytes
186- readStatus = this ->readBytes (file, outLength, FpySequencer_FileReadStage::BODY);
187- if (readStatus != Fw::Success::SUCCESS) {
188- return Fw::Success::FAILURE;
189- }
190-
191- FwSizeType actualLen = static_cast <FwSizeType>(outLength);
192- deserStatus = this ->m_sequenceBuffer .deserializeTo (buffer, actualLen, Fw::Serialization::OMIT_LENGTH);
193- if (deserStatus != Fw::SerializeStatus::FW_SERIALIZE_OK) {
194- this ->log_WARNING_HI_FileReadDeserializeError (
195- FpySequencer_FileReadStage::BODY, this ->m_sequenceFilePath , static_cast <I32>(deserStatus),
196- this ->m_sequenceBuffer .getDeserializeSizeLeft (), this ->m_sequenceBuffer .getSize ());
197- return Fw::Success::FAILURE;
198- }
199-
200- return Fw::Success::SUCCESS;
201- }
202-
203- // reads and validates arg_specs from the m_sequenceBuffer
204- // stores them in the Sequence.args array and calculates the total expected argument size
205- // return SUCCESS if successful, FAILURE otherwise
206- Fw::Success FpySequencer::readArgSpecs (Os::File& file) {
207- FW_ASSERT (file.isOpen ());
208-
144+ // reads and validates the body from the m_sequenceBuffer
145+ // return SUCCESS if sequence is valid, FAILURE otherwise
146+ Fw::Success FpySequencer::readBody () {
147+ Fw::SerializeStatus deserStatus;
148+
209149 const U8 argumentCount = this ->m_sequenceObj .get_header ().get_argumentCount ();
210150 Fpy::StackSizeType totalExpectedSize = 0 ;
211- Fw::SerializeStatus deserStatus;
212- Fw::Success readStatus;
213-
214- // Read and deserialize each arg_spec incrementally since they're variable-length
151+
152+ // deser arguments
153+ // Read and deserialize each arg_spec incrementally since they're variable-length
215154 for (U8 i = 0 ; i < argumentCount; i++) {
216155 Fpy::ArgSpec& argSpec = this ->m_sequenceObj .get_args ()[i];
217-
156+ Fw::String myString{};
218157 // Read arg_name (length + string)
219- U8 argNameLen = 0 ;
220- readStatus = this ->deserializeStringField (file, argSpec.get_argName (), argNameLen);
221- if (readStatus != Fw::Success::SUCCESS) {
158+ deserStatus = this ->m_sequenceBuffer .deserializeTo (myString);
159+ if (deserStatus != Fw::SerializeStatus::FW_SERIALIZE_OK) {
160+ this ->log_WARNING_HI_FileReadDeserializeError (
161+ FpySequencer_FileReadStage::BODY,
162+ this ->m_sequenceFilePath ,
163+ static_cast <I32>(deserStatus),
164+ this ->m_sequenceBuffer .getDeserializeSizeLeft (),
165+ this ->m_sequenceBuffer .getSize ()
166+ );
222167 return Fw::Success::FAILURE;
223168 }
224- argSpec.set_argNameLen (argNameLen);
169+ if (myString.length () == 0 ) {
170+ this ->log_WARNING_HI_InvalidArgSpec (this ->m_sequenceFilePath );
171+ return Fw::Success::FAILURE;
172+ }
173+ argSpec.set_argName (myString);
225174
226175 // Read type_name (length + string)
227- U8 typeNameLen = 0 ;
228- readStatus = this ->deserializeStringField (file, argSpec.get_typeName (), typeNameLen);
229- if (readStatus != Fw::Success::SUCCESS) {
176+ deserStatus = this ->m_sequenceBuffer .deserializeTo (myString);
177+ if (deserStatus != Fw::SerializeStatus::FW_SERIALIZE_OK) {
178+ this ->log_WARNING_HI_FileReadDeserializeError (
179+ FpySequencer_FileReadStage::BODY,
180+ this ->m_sequenceFilePath ,
181+ static_cast <I32>(deserStatus),
182+ this ->m_sequenceBuffer .getDeserializeSizeLeft (),
183+ this ->m_sequenceBuffer .getSize ()
184+ );
230185 return Fw::Success::FAILURE;
231186 }
232- argSpec.set_typeNameLen (typeNameLen);
233-
234- // Read and deserialize size field
235- readStatus = this ->readBytes (file, sizeof (Fpy::StackSizeType), FpySequencer_FileReadStage::BODY);
236- if (readStatus != Fw::Success::SUCCESS) {
187+ if (myString.length () == 0 ) {
188+ this ->log_WARNING_HI_InvalidArgSpec (this ->m_sequenceFilePath );
237189 return Fw::Success::FAILURE;
238190 }
191+ argSpec.set_typeName (myString);
192+
193+ // Read and deserialize size field
239194 Fpy::StackSizeType argSize = 0 ;
240195 deserStatus = this ->m_sequenceBuffer .deserializeTo (argSize);
241196 if (deserStatus != Fw::SerializeStatus::FW_SERIALIZE_OK) {
@@ -254,15 +209,7 @@ Fw::Success FpySequencer::readArgSpecs(Os::File& file) {
254209 argSpec.set_argSize (argSize);
255210 totalExpectedSize += argSize;
256211 }
257-
258- this ->m_expectedArgSize = totalExpectedSize;
259- return Fw::Success::SUCCESS;
260- }
261-
262- // reads and validates the body from the m_sequenceBuffer
263- // return SUCCESS if sequence is valid, FAILURE otherwise
264- Fw::Success FpySequencer::readBody () {
265- Fw::SerializeStatus deserStatus;
212+
266213 // deser statements
267214 for (U16 statementIdx = 0 ; statementIdx < this ->m_sequenceObj .get_header ().get_statementCount (); statementIdx++) {
268215 // deser statement
0 commit comments