-
Notifications
You must be signed in to change notification settings - Fork 202
/
cfe_tbl_task_cmds.c
1492 lines (1322 loc) · 67.6 KB
/
cfe_tbl_task_cmds.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** GSC-18128-1, "Core Flight Executive Version 6.7"
**
** Copyright (c) 2006-2019 United States Government as represented by
** the Administrator of the National Aeronautics and Space Administration.
** All Rights Reserved.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
/*
** File: cfe_tbl_task_cmds.c
**
** Subsystem: cFE TBL Task Command Processing Functions
**
** Author: David Kobe (the Hammers Company, Inc.)
**
** Notes:
**
*/
/*
** Required header files
*/
#include "cfe_tbl_module_all.h"
#include "cfe_version.h"
#include <string.h>
/*----------------------------------------------------------------
*
* Function: CFE_TBL_HousekeepingCmd
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_TBL_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data)
{
int32 Status;
int32 OsStatus;
uint32 i;
CFE_TBL_DumpControl_t *DumpCtrlPtr;
CFE_TIME_SysTime_t DumpTime;
osal_id_t FileDescriptor;
/*
** Collect housekeeping data from Table Services
*/
CFE_TBL_GetHkData();
/*
** Send housekeeping telemetry packet
*/
CFE_SB_TimeStampMsg(&CFE_TBL_Global.HkPacket.TlmHeader.Msg);
Status = CFE_SB_TransmitMsg(&CFE_TBL_Global.HkPacket.TlmHeader.Msg, true);
if (Status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CFE_TBL_FAIL_HK_SEND_ERR_EID, CFE_EVS_EventType_ERROR,
"Unable to send Hk Packet (Status=0x%08X)", (unsigned int)Status);
}
/* If a table's registry entry has been requested for telemetry, then pack it and send it */
if (CFE_TBL_Global.HkTlmTblRegIndex != CFE_TBL_NOT_FOUND)
{
CFE_TBL_GetTblRegData();
/*
** Send Table Registry Info Packet
*/
CFE_SB_TimeStampMsg(&CFE_TBL_Global.TblRegPacket.TlmHeader.Msg);
CFE_SB_TransmitMsg(&CFE_TBL_Global.TblRegPacket.TlmHeader.Msg, true);
/* Once the data has been sent, clear the index so that we don't send it again and again */
CFE_TBL_Global.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND;
}
/* Check to see if there are any dump-only table dumps pending */
for (i = 0; i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; i++)
{
if (CFE_TBL_Global.DumpControlBlocks[i].State == CFE_TBL_DUMP_PERFORMED)
{
DumpCtrlPtr = &CFE_TBL_Global.DumpControlBlocks[i];
Status = CFE_TBL_DumpToFile(DumpCtrlPtr->DumpBufferPtr->DataSource, DumpCtrlPtr->TableName,
DumpCtrlPtr->DumpBufferPtr->BufferPtr, DumpCtrlPtr->Size);
/* If dump file was successfully written, update the file header so that the timestamp */
/* is the time of the actual capturing of the data, NOT the time when it was written to the file */
if (Status == CFE_TBL_INC_CMD_CTR)
{
DumpTime.Seconds = DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSecs;
DumpTime.Subseconds = DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSubSecs;
OsStatus = OS_OpenCreate(&FileDescriptor, DumpCtrlPtr->DumpBufferPtr->DataSource, OS_FILE_FLAG_NONE,
OS_READ_WRITE);
if (OsStatus == OS_SUCCESS)
{
Status = CFE_FS_SetTimestamp(FileDescriptor, DumpTime);
if (Status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("%s: Unable to update timestamp in dump file '%s'\n", __func__,
DumpCtrlPtr->DumpBufferPtr->DataSource);
}
OS_close(FileDescriptor);
}
else
{
CFE_ES_WriteToSysLog("%s: Unable to open dump file '%s' to update timestamp\n", __func__,
DumpCtrlPtr->DumpBufferPtr->DataSource);
}
}
/* Free the shared working buffer */
CFE_TBL_Global.LoadBuffs[DumpCtrlPtr->RegRecPtr->LoadInProgress].Taken = false;
DumpCtrlPtr->RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS;
/* Free the Dump Control Block for later use */
DumpCtrlPtr->State = CFE_TBL_DUMP_FREE;
}
}
return CFE_TBL_DONT_INC_CTR;
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_GetHkData
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_TBL_GetHkData(void)
{
uint32 i;
uint16 Count;
CFE_TBL_ValidationResult_t *ValPtr = NULL;
/* Copy command counter data */
CFE_TBL_Global.HkPacket.Payload.CommandCounter = CFE_TBL_Global.CommandCounter;
CFE_TBL_Global.HkPacket.Payload.CommandErrorCounter = CFE_TBL_Global.CommandErrorCounter;
CFE_TBL_Global.HkPacket.Payload.FailedValCounter = CFE_TBL_Global.FailedValCounter;
CFE_TBL_Global.HkPacket.Payload.NumLoadPending = 0;
CFE_TBL_Global.HkPacket.Payload.MemPoolHandle = CFE_TBL_Global.Buf.PoolHdl;
/* Determine the number of tables currently registered and Number of Load Pending Tables */
Count = 0;
for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_TABLES; i++)
{
if (!CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED))
{
Count++;
if (CFE_TBL_Global.Registry[i].LoadPending)
{
CFE_TBL_Global.HkPacket.Payload.NumLoadPending++;
}
}
}
CFE_TBL_Global.HkPacket.Payload.NumTables = Count;
/* Determine the number of free shared buffers */
CFE_TBL_Global.HkPacket.Payload.NumFreeSharedBufs = CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS;
for (i = 0; i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; i++)
{
if (CFE_TBL_Global.LoadBuffs[i].Taken)
{
CFE_TBL_Global.HkPacket.Payload.NumFreeSharedBufs--;
}
}
/* Locate a completed, but unreported, validation request */
i = 0;
while ((i < CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS) && (ValPtr == NULL))
{
if (CFE_TBL_Global.ValidationResults[i].State == CFE_TBL_VALIDATION_PERFORMED)
{
ValPtr = &CFE_TBL_Global.ValidationResults[i];
}
else
{
i++;
}
}
if (ValPtr != NULL)
{
CFE_TBL_Global.HkPacket.Payload.LastValCrc = ValPtr->CrcOfTable;
CFE_TBL_Global.HkPacket.Payload.LastValStatus = ValPtr->Result;
CFE_TBL_Global.HkPacket.Payload.ActiveBuffer = ValPtr->ActiveBuffer;
/* Keep track of the number of failed and successful validations */
if (ValPtr->Result == CFE_SUCCESS)
{
CFE_TBL_Global.SuccessValCounter++;
}
else
{
CFE_TBL_Global.FailedValCounter++;
}
CFE_SB_MessageStringSet(CFE_TBL_Global.HkPacket.Payload.LastValTableName, ValPtr->TableName,
sizeof(CFE_TBL_Global.HkPacket.Payload.LastValTableName), sizeof(ValPtr->TableName));
CFE_TBL_Global.ValidationCounter++;
/* Free the Validation Response Block for next time */
ValPtr->Result = 0;
ValPtr->CrcOfTable = 0;
ValPtr->TableName[0] = '\0';
ValPtr->ActiveBuffer = false;
ValPtr->State = CFE_TBL_VALIDATION_FREE;
}
CFE_TBL_Global.HkPacket.Payload.ValidationCounter = CFE_TBL_Global.ValidationCounter;
CFE_TBL_Global.HkPacket.Payload.SuccessValCounter = CFE_TBL_Global.SuccessValCounter;
CFE_TBL_Global.HkPacket.Payload.FailedValCounter = CFE_TBL_Global.FailedValCounter;
CFE_TBL_Global.HkPacket.Payload.NumValRequests = CFE_TBL_Global.NumValRequests;
/* Validate the index of the last table updated before using it */
if ((CFE_TBL_Global.LastTblUpdated >= 0) && (CFE_TBL_Global.LastTblUpdated < CFE_PLATFORM_TBL_MAX_NUM_TABLES))
{
/* Check to make sure the Registry Entry is still valid */
if (!CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].OwnerAppId,
CFE_TBL_NOT_OWNED))
{
/* Get the time at the last table update */
CFE_TBL_Global.HkPacket.Payload.LastUpdateTime =
CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].TimeOfLastUpdate;
/* Get the table name used for the last table update */
CFE_SB_MessageStringSet(CFE_TBL_Global.HkPacket.Payload.LastUpdatedTable,
CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].Name,
sizeof(CFE_TBL_Global.HkPacket.Payload.LastUpdatedTable),
sizeof(CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].Name));
}
}
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_GetTblRegData
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_TBL_GetTblRegData(void)
{
CFE_TBL_RegistryRec_t *RegRecPtr;
RegRecPtr = &CFE_TBL_Global.Registry[CFE_TBL_Global.HkTlmTblRegIndex];
CFE_TBL_Global.TblRegPacket.Payload.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size);
CFE_TBL_Global.TblRegPacket.Payload.ActiveBufferAddr =
CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr);
if (RegRecPtr->DoubleBuffered)
{
/* For a double buffered table, the inactive is the other allocated buffer */
CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr =
CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].BufferPtr);
}
else
{
/* Check to see if an inactive buffer has currently been allocated to the single buffered table */
if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS)
{
CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr =
CFE_ES_MEMADDRESS_C(CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr);
}
else
{
CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0);
}
}
CFE_TBL_Global.TblRegPacket.Payload.ValidationFuncPtr = CFE_ES_MEMADDRESS_C(RegRecPtr->ValidationFuncPtr);
CFE_TBL_Global.TblRegPacket.Payload.TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate;
CFE_TBL_Global.TblRegPacket.Payload.TableLoadedOnce = RegRecPtr->TableLoadedOnce;
CFE_TBL_Global.TblRegPacket.Payload.LoadPending = RegRecPtr->LoadPending;
CFE_TBL_Global.TblRegPacket.Payload.DumpOnly = RegRecPtr->DumpOnly;
CFE_TBL_Global.TblRegPacket.Payload.DoubleBuffered = RegRecPtr->DoubleBuffered;
CFE_TBL_Global.TblRegPacket.Payload.FileCreateTimeSecs =
RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSecs;
CFE_TBL_Global.TblRegPacket.Payload.FileCreateTimeSubSecs =
RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSubSecs;
CFE_TBL_Global.TblRegPacket.Payload.Crc = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].Crc;
CFE_TBL_Global.TblRegPacket.Payload.Critical = RegRecPtr->CriticalTable;
CFE_SB_MessageStringSet(CFE_TBL_Global.TblRegPacket.Payload.Name, RegRecPtr->Name,
sizeof(CFE_TBL_Global.TblRegPacket.Payload.Name), sizeof(RegRecPtr->Name));
CFE_SB_MessageStringSet(CFE_TBL_Global.TblRegPacket.Payload.LastFileLoaded, RegRecPtr->LastFileLoaded,
sizeof(CFE_TBL_Global.TblRegPacket.Payload.LastFileLoaded),
sizeof(RegRecPtr->LastFileLoaded));
CFE_ES_GetAppName(CFE_TBL_Global.TblRegPacket.Payload.OwnerAppName, RegRecPtr->OwnerAppId,
sizeof(CFE_TBL_Global.TblRegPacket.Payload.OwnerAppName));
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_NoopCmd
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_TBL_NoopCmd(const CFE_TBL_NoopCmd_t *data)
{
/* Acknowledge receipt of NOOP with Event Message */
CFE_EVS_SendEvent(CFE_TBL_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op Cmd Rcvd: %s", CFE_VERSION_STRING);
return CFE_TBL_INC_CMD_CTR;
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_ResetCountersCmd
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_TBL_ResetCountersCmd(const CFE_TBL_ResetCountersCmd_t *data)
{
CFE_TBL_Global.CommandCounter = 0;
CFE_TBL_Global.CommandErrorCounter = 0;
CFE_TBL_Global.SuccessValCounter = 0;
CFE_TBL_Global.FailedValCounter = 0;
CFE_TBL_Global.NumValRequests = 0;
CFE_TBL_Global.ValidationCounter = 0;
CFE_EVS_SendEvent(CFE_TBL_RESET_INF_EID, CFE_EVS_EventType_DEBUG, "Reset Counters command");
return CFE_TBL_DONT_INC_CTR;
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_LoadCmd
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data)
{
CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */
const CFE_TBL_LoadCmd_Payload_t *CmdPtr = &data->Payload;
CFE_FS_Header_t StdFileHeader;
CFE_TBL_File_Hdr_t TblFileHeader;
osal_id_t FileDescriptor;
int32 Status;
int32 OsStatus;
int16 RegIndex;
CFE_TBL_RegistryRec_t * RegRecPtr;
CFE_TBL_LoadBuff_t * WorkingBufferPtr;
char LoadFilename[OS_MAX_PATH_LEN];
uint8 ExtraByte;
/* Make sure all strings are null terminated before attempting to process them */
CFE_SB_MessageStringGet(LoadFilename, (char *)CmdPtr->LoadFilename, NULL, sizeof(LoadFilename),
sizeof(CmdPtr->LoadFilename));
/* Try to open the specified table file */
OsStatus = OS_OpenCreate(&FileDescriptor, LoadFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY);
if (OsStatus == OS_SUCCESS)
{
Status = CFE_TBL_ReadHeaders(FileDescriptor, &StdFileHeader, &TblFileHeader, &LoadFilename[0]);
if (Status == CFE_SUCCESS)
{
/* Locate specified table in registry */
RegIndex = CFE_TBL_FindTableInRegistry(TblFileHeader.TableName);
if (RegIndex == CFE_TBL_NOT_FOUND)
{
CFE_EVS_SendEvent(CFE_TBL_NO_SUCH_TABLE_ERR_EID, CFE_EVS_EventType_ERROR,
"Unable to locate '%s' in Table Registry", TblFileHeader.TableName);
}
else
{
/* Translate the registry index into a record pointer */
RegRecPtr = &CFE_TBL_Global.Registry[RegIndex];
if (RegRecPtr->DumpOnly)
{
CFE_EVS_SendEvent(CFE_TBL_LOADING_A_DUMP_ONLY_ERR_EID, CFE_EVS_EventType_ERROR,
"Attempted to load DUMP-ONLY table '%s' from '%s'", TblFileHeader.TableName,
LoadFilename);
}
else if (RegRecPtr->LoadPending)
{
CFE_EVS_SendEvent(CFE_TBL_LOADING_PENDING_ERR_EID, CFE_EVS_EventType_ERROR,
"Attempted to load table '%s' while previous load is still pending",
TblFileHeader.TableName);
}
else
{
/* Make sure of the following: */
/* 1) If table has not been loaded previously, then make sure the current */
/* load starts with the first byte */
/* 2) The number of bytes to load is greater than zero */
/* 3) The offset plus the number of bytes does not exceed the table size */
if (((RegRecPtr->TableLoadedOnce) || (TblFileHeader.Offset == 0)) && (TblFileHeader.NumBytes > 0) &&
((TblFileHeader.NumBytes + TblFileHeader.Offset) <= RegRecPtr->Size))
{
/* Get a working buffer, either a free one or one allocated with previous load command */
Status = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false);
if (Status == CFE_SUCCESS)
{
/* Copy data from file into working buffer */
OsStatus =
OS_read(FileDescriptor, ((uint8 *)WorkingBufferPtr->BufferPtr) + TblFileHeader.Offset,
TblFileHeader.NumBytes);
/* Make sure the appropriate number of bytes were read */
if ((long)OsStatus == TblFileHeader.NumBytes)
{
/* Check to ensure the file does not have any extra data at the end */
OsStatus = OS_read(FileDescriptor, &ExtraByte, 1);
/* If another byte was successfully read, then file contains more data than header
* claims */
if ((long)OsStatus == 1)
{
CFE_EVS_SendEvent(CFE_TBL_FILE_TOO_BIG_ERR_EID, CFE_EVS_EventType_ERROR,
"File '%s' has more data than Tbl Hdr indicates (%d)",
LoadFilename, (int)TblFileHeader.NumBytes);
}
else /* If error reading file or zero bytes read, assume it was the perfect size */
{
CFE_EVS_SendEvent(CFE_TBL_FILE_LOADED_INF_EID, CFE_EVS_EventType_INFORMATION,
"Successful load of '%s' into '%s' working buffer", LoadFilename,
TblFileHeader.TableName);
/* Save file information statistics for later use in registry */
memcpy(WorkingBufferPtr->DataSource, LoadFilename, OS_MAX_PATH_LEN);
/* Save file creation time for later storage into Registry */
WorkingBufferPtr->FileCreateTimeSecs = StdFileHeader.TimeSeconds;
WorkingBufferPtr->FileCreateTimeSubSecs = StdFileHeader.TimeSubSeconds;
/* Compute the CRC on the specified table buffer */
WorkingBufferPtr->Crc = CFE_ES_CalculateCRC(
WorkingBufferPtr->BufferPtr, RegRecPtr->Size, 0, CFE_MISSION_ES_DEFAULT_CRC);
/* Initialize validation flag with true if no Validation Function is required to be
* called */
WorkingBufferPtr->Validated = (RegRecPtr->ValidationFuncPtr == NULL);
/* Save file information statistics for housekeeping telemetry */
strncpy(CFE_TBL_Global.HkPacket.Payload.LastFileLoaded, LoadFilename,
sizeof(CFE_TBL_Global.HkPacket.Payload.LastFileLoaded) - 1);
CFE_TBL_Global.HkPacket.Payload
.LastFileLoaded[sizeof(CFE_TBL_Global.HkPacket.Payload.LastFileLoaded) - 1] =
'\0';
strncpy(CFE_TBL_Global.HkPacket.Payload.LastTableLoaded, TblFileHeader.TableName,
sizeof(CFE_TBL_Global.HkPacket.Payload.LastTableLoaded) - 1);
CFE_TBL_Global.HkPacket.Payload
.LastTableLoaded[sizeof(CFE_TBL_Global.HkPacket.Payload.LastTableLoaded) - 1] =
'\0';
/* Increment successful command completion counter */
ReturnCode = CFE_TBL_INC_CMD_CTR;
}
}
else
{
/* A file whose header claims has 'x' amount of data but it only has 'y' */
/* is considered a fatal error during a load process */
CFE_EVS_SendEvent(CFE_TBL_FILE_INCOMPLETE_ERR_EID, CFE_EVS_EventType_ERROR,
"Incomplete load of '%s' into '%s' working buffer", LoadFilename,
TblFileHeader.TableName);
}
}
else if (Status == CFE_TBL_ERR_NO_BUFFER_AVAIL)
{
CFE_EVS_SendEvent(CFE_TBL_NO_WORK_BUFFERS_ERR_EID, CFE_EVS_EventType_ERROR,
"No working buffers available for table '%s'", TblFileHeader.TableName);
}
else
{
CFE_EVS_SendEvent(CFE_TBL_INTERNAL_ERROR_ERR_EID, CFE_EVS_EventType_ERROR,
"Internal Error (Status=0x%08X)", (unsigned int)Status);
}
}
else
{
if ((TblFileHeader.NumBytes + TblFileHeader.Offset) > RegRecPtr->Size)
{
CFE_EVS_SendEvent(CFE_TBL_LOAD_EXCEEDS_SIZE_ERR_EID, CFE_EVS_EventType_ERROR,
"Cannot load '%s' (%d) at offset %d in '%s' (%d)", LoadFilename,
(int)TblFileHeader.NumBytes, (int)TblFileHeader.Offset,
TblFileHeader.TableName, (int)RegRecPtr->Size);
}
else if (TblFileHeader.NumBytes == 0)
{
CFE_EVS_SendEvent(CFE_TBL_ZERO_LENGTH_LOAD_ERR_EID, CFE_EVS_EventType_ERROR,
"Table Hdr in '%s' indicates no data in file", LoadFilename);
}
else
{
CFE_EVS_SendEvent(CFE_TBL_PARTIAL_LOAD_ERR_EID, CFE_EVS_EventType_ERROR,
"'%s' has partial load for uninitialized table '%s'", LoadFilename,
TblFileHeader.TableName);
}
}
}
}
} /* No need to issue event messages in response to errors reading headers */
/* because the function that read the headers will generate messages */
/* Close the file now that the contents have been read */
OS_close(FileDescriptor);
}
else
{
/* Error opening specified file */
CFE_EVS_SendEvent(CFE_TBL_FILE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR,
"Unable to open file '%s' for table load, Status = %ld", LoadFilename, (long)OsStatus);
}
return ReturnCode;
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_DumpCmd
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_TBL_DumpCmd(const CFE_TBL_DumpCmd_t *data)
{
CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */
int16 RegIndex;
const CFE_TBL_DumpCmd_Payload_t *CmdPtr = &data->Payload;
char DumpFilename[OS_MAX_PATH_LEN];
char TableName[CFE_TBL_MAX_FULL_NAME_LEN];
CFE_TBL_RegistryRec_t * RegRecPtr;
void * DumpDataAddr = NULL;
CFE_TBL_LoadBuff_t * WorkingBufferPtr;
int32 DumpIndex;
int32 Status;
CFE_TBL_DumpControl_t * DumpCtrlPtr;
/* Make sure all strings are null terminated before attempting to process them */
CFE_SB_MessageStringGet(DumpFilename, (char *)CmdPtr->DumpFilename, NULL, sizeof(DumpFilename),
sizeof(CmdPtr->DumpFilename));
CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, sizeof(TableName), sizeof(CmdPtr->TableName));
/* Before doing anything, lets make sure the table that is to be dumped exists */
RegIndex = CFE_TBL_FindTableInRegistry(TableName);
if (RegIndex != CFE_TBL_NOT_FOUND)
{
/* Obtain a pointer to registry information about specified table */
RegRecPtr = &CFE_TBL_Global.Registry[RegIndex];
/* Determine what data is to be dumped */
if (CmdPtr->ActiveTableFlag == CFE_TBL_BufferSelect_ACTIVE)
{
DumpDataAddr = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr;
}
else if (CmdPtr->ActiveTableFlag == CFE_TBL_BufferSelect_INACTIVE) /* Dumping Inactive Buffer */
{
/* If this is a double buffered table, locating the inactive buffer is trivial */
if (RegRecPtr->DoubleBuffered)
{
DumpDataAddr = RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].BufferPtr;
}
else
{
/* For single buffered tables, the index to the inactive buffer is kept in 'LoadInProgress' */
/* Unless this is a table whose address was defined by the owning Application. */
if ((RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) && (!RegRecPtr->UserDefAddr))
{
DumpDataAddr = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr;
}
else
{
CFE_EVS_SendEvent(CFE_TBL_NO_INACTIVE_BUFFER_ERR_EID, CFE_EVS_EventType_ERROR,
"No Inactive Buffer for Table '%s' present", TableName);
}
}
}
else
{
CFE_EVS_SendEvent(CFE_TBL_ILLEGAL_BUFF_PARAM_ERR_EID, CFE_EVS_EventType_ERROR,
"Cmd for Table '%s' had illegal buffer parameter (0x%08X)", TableName,
(unsigned int)CmdPtr->ActiveTableFlag);
}
/* If we have located the data to be dumped, then proceed with creating the file and dumping the data */
if (DumpDataAddr != NULL)
{
/* If this is not a dump only table, then we can perform the dump immediately */
if (!RegRecPtr->DumpOnly)
{
ReturnCode = CFE_TBL_DumpToFile(DumpFilename, TableName, DumpDataAddr, RegRecPtr->Size);
}
else /* Dump Only tables need to synchronize their dumps with the owner's execution */
{
/* Make sure a dump is not already in progress */
if (RegRecPtr->DumpControlIndex == CFE_TBL_NO_DUMP_PENDING)
{
/* Find a free Dump Control Block */
DumpIndex = 0;
while ((DumpIndex < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS) &&
(CFE_TBL_Global.DumpControlBlocks[DumpIndex].State != CFE_TBL_DUMP_FREE))
{
DumpIndex++;
}
if (DumpIndex < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS)
{
/* Allocate a shared memory buffer for storing the data to be dumped */
Status = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false);
if (Status == CFE_SUCCESS)
{
DumpCtrlPtr = &CFE_TBL_Global.DumpControlBlocks[DumpIndex];
DumpCtrlPtr->State = CFE_TBL_DUMP_PENDING;
DumpCtrlPtr->RegRecPtr = RegRecPtr;
/* Save the name of the desired dump filename, table name and size for later */
DumpCtrlPtr->DumpBufferPtr = WorkingBufferPtr;
memcpy(DumpCtrlPtr->DumpBufferPtr->DataSource, DumpFilename, OS_MAX_PATH_LEN);
memcpy(DumpCtrlPtr->TableName, TableName, CFE_TBL_MAX_FULL_NAME_LEN);
DumpCtrlPtr->Size = RegRecPtr->Size;
/* Notify the owning application that a dump is pending */
RegRecPtr->DumpControlIndex = DumpIndex;
/* If application requested notification by message, then do so */
CFE_TBL_SendNotificationMsg(RegRecPtr);
/* Consider the command completed successfully */
ReturnCode = CFE_TBL_INC_CMD_CTR;
}
else
{
CFE_EVS_SendEvent(CFE_TBL_NO_WORK_BUFFERS_ERR_EID, CFE_EVS_EventType_ERROR,
"No working buffers available for table '%s'", TableName);
}
}
else
{
CFE_EVS_SendEvent(CFE_TBL_TOO_MANY_DUMPS_ERR_EID, CFE_EVS_EventType_ERROR,
"Too many Dump Only Table Dumps have been requested");
}
}
else
{
CFE_EVS_SendEvent(CFE_TBL_DUMP_PENDING_ERR_EID, CFE_EVS_EventType_ERROR,
"A dump for '%s' is already pending", TableName);
}
}
}
}
else /* Table could not be found in Registry */
{
CFE_EVS_SendEvent(CFE_TBL_NO_SUCH_TABLE_ERR_EID, CFE_EVS_EventType_ERROR,
"Unable to locate '%s' in Table Registry", TableName);
}
return ReturnCode;
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_DumpToFile
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *TableName, const void *DumpDataAddr,
size_t TblSizeInBytes)
{
CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */
bool FileExistedPrev = false;
CFE_FS_Header_t StdFileHeader;
CFE_TBL_File_Hdr_t TblFileHeader;
osal_id_t FileDescriptor;
int32 Status;
int32 OsStatus;
int32 EndianCheck = 0x01020304;
/* Clear Header of any garbage before copying content */
memset(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t));
/* Check to see if the dump file already exists */
OsStatus = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY);
if (OsStatus == OS_SUCCESS)
{
FileExistedPrev = true;
OS_close(FileDescriptor);
}
/* Create a new dump file, overwriting anything that may have existed previously */
OsStatus = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY);
if (OsStatus == OS_SUCCESS)
{
/* Initialize the standard cFE File Header for the Dump File */
CFE_FS_InitHeader(&StdFileHeader, "Table Dump Image", CFE_FS_SubType_TBL_IMG);
/* Output the Standard cFE File Header to the Dump File */
Status = CFE_FS_WriteHeader(FileDescriptor, &StdFileHeader);
if (Status == sizeof(CFE_FS_Header_t))
{
/* Initialize the Table Image Header for the Dump File */
strncpy(TblFileHeader.TableName, TableName, sizeof(TblFileHeader.TableName) - 1);
TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = 0;
TblFileHeader.Offset = CFE_ES_MEMOFFSET_C(0);
TblFileHeader.NumBytes = CFE_ES_MEMOFFSET_C(TblSizeInBytes);
TblFileHeader.Reserved = 0;
/* Determine if this is a little endian processor */
if ((*(char *)&EndianCheck) == 0x04)
{
/* If this is a little endian processor, then byte swap the header to a big endian format */
/* to maintain the cFE Header standards */
/* NOTE: FOR THE REMAINDER OF THIS FUNCTION, THE CONTENTS OF THE HEADER IS UNREADABLE BY */
/* THIS PROCESSOR! THE DATA WOULD NEED TO BE SWAPPED BACK BEFORE READING. */
CFE_TBL_ByteSwapTblHeader(&TblFileHeader);
}
/* Output the Table Image Header to the Dump File */
OsStatus = OS_write(FileDescriptor, &TblFileHeader, sizeof(CFE_TBL_File_Hdr_t));
/* Make sure the header was output completely */
if ((long)OsStatus == sizeof(CFE_TBL_File_Hdr_t))
{
/* Output the requested data to the dump file */
/* Output the active table image data to the dump file */
OsStatus = OS_write(FileDescriptor, DumpDataAddr, TblSizeInBytes);
if ((long)OsStatus == TblSizeInBytes)
{
if (FileExistedPrev)
{
CFE_EVS_SendEvent(CFE_TBL_OVERWRITE_DUMP_INF_EID, CFE_EVS_EventType_INFORMATION,
"Successfully overwrote '%s' with Table '%s'", DumpFilename, TableName);
}
else
{
CFE_EVS_SendEvent(CFE_TBL_WRITE_DUMP_INF_EID, CFE_EVS_EventType_INFORMATION,
"Successfully dumped Table '%s' to '%s'", TableName, DumpFilename);
}
/* Save file information statistics for housekeeping telemetry */
strncpy(CFE_TBL_Global.HkPacket.Payload.LastFileDumped, DumpFilename,
sizeof(CFE_TBL_Global.HkPacket.Payload.LastFileDumped) - 1);
CFE_TBL_Global.HkPacket.Payload
.LastFileDumped[sizeof(CFE_TBL_Global.HkPacket.Payload.LastFileDumped) - 1] = 0;
/* Increment Successful Command Counter */
ReturnCode = CFE_TBL_INC_CMD_CTR;
}
else
{
CFE_EVS_SendEvent(CFE_TBL_WRITE_TBL_IMG_ERR_EID, CFE_EVS_EventType_ERROR,
"Error writing Tbl image to '%s', Status=%ld", DumpFilename, (long)OsStatus);
}
}
else
{
CFE_EVS_SendEvent(CFE_TBL_WRITE_TBL_HDR_ERR_EID, CFE_EVS_EventType_ERROR,
"Error writing Tbl image File Header to '%s', Status=%ld", DumpFilename,
(long)OsStatus);
}
}
else
{
CFE_EVS_SendEvent(CFE_TBL_WRITE_CFE_HDR_ERR_EID, CFE_EVS_EventType_ERROR,
"Error writing cFE File Header to '%s', Status=0x%08X", DumpFilename,
(unsigned int)Status);
}
/* We are done outputting data to the dump file. Close it. */
OS_close(FileDescriptor);
}
else
{
CFE_EVS_SendEvent(CFE_TBL_CREATING_DUMP_FILE_ERR_EID, CFE_EVS_EventType_ERROR,
"Error creating dump file '%s', Status=%ld", DumpFilename, (long)OsStatus);
}
return ReturnCode;
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_ValidateCmd
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_TBL_ValidateCmd(const CFE_TBL_ValidateCmd_t *data)
{
CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */
int16 RegIndex;
const CFE_TBL_ValidateCmd_Payload_t *CmdPtr = &data->Payload;
CFE_TBL_RegistryRec_t * RegRecPtr;
void * ValidationDataPtr = NULL;
char TableName[CFE_TBL_MAX_FULL_NAME_LEN];
uint32 CrcOfTable;
int32 ValIndex;
/* Make sure all strings are null terminated before attempting to process them */
CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, sizeof(TableName), sizeof(CmdPtr->TableName));
/* Before doing anything, lets make sure the table that is to be dumped exists */
RegIndex = CFE_TBL_FindTableInRegistry(TableName);
if (RegIndex != CFE_TBL_NOT_FOUND)
{
/* Obtain a pointer to registry information about specified table */
RegRecPtr = &CFE_TBL_Global.Registry[RegIndex];
/* Determine what data is to be validated */
if (CmdPtr->ActiveTableFlag == CFE_TBL_BufferSelect_ACTIVE)
{
ValidationDataPtr = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr;
}
else if (CmdPtr->ActiveTableFlag == CFE_TBL_BufferSelect_INACTIVE) /* Validating Inactive Buffer */
{
/* If this is a double buffered table, locating the inactive buffer is trivial */
if (RegRecPtr->DoubleBuffered)
{
ValidationDataPtr = RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].BufferPtr;
}
else
{
/* For single buffered tables, the index to the inactive buffer is kept in 'LoadInProgress' */
if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS)
{
ValidationDataPtr = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr;
}
else
{
CFE_EVS_SendEvent(CFE_TBL_NO_INACTIVE_BUFFER_ERR_EID, CFE_EVS_EventType_ERROR,
"No Inactive Buffer for Table '%s' present", TableName);
}
}
}
else
{
CFE_EVS_SendEvent(CFE_TBL_ILLEGAL_BUFF_PARAM_ERR_EID, CFE_EVS_EventType_ERROR,
"Cmd for Table '%s' had illegal buffer parameter (0x%08X)", TableName,
(unsigned int)CmdPtr->ActiveTableFlag);
}
/* If we have located the data to be validated, then proceed with notifying the application, if */
/* necessary, and computing the CRC value for the block of memory */
if (ValidationDataPtr != NULL)
{
/* Find a free Validation Response Block */
ValIndex = 0;
while ((ValIndex < CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS) &&
(CFE_TBL_Global.ValidationResults[ValIndex].State != CFE_TBL_VALIDATION_FREE))
{
ValIndex++;
}
if (ValIndex < CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS)
{
/* Allocate this Validation Response Block */
CFE_TBL_Global.ValidationResults[ValIndex].State = CFE_TBL_VALIDATION_PENDING;
CFE_TBL_Global.ValidationResults[ValIndex].Result = 0;
memcpy(CFE_TBL_Global.ValidationResults[ValIndex].TableName, TableName, CFE_TBL_MAX_FULL_NAME_LEN);
/* Compute the CRC on the specified table buffer */
CrcOfTable = CFE_ES_CalculateCRC(ValidationDataPtr, RegRecPtr->Size, 0, CFE_MISSION_ES_DEFAULT_CRC);
CFE_TBL_Global.ValidationResults[ValIndex].CrcOfTable = CrcOfTable;
CFE_TBL_Global.ValidationResults[ValIndex].ActiveBuffer = (CmdPtr->ActiveTableFlag != 0);
/* If owner has a validation function, then notify the */
/* table owner that there is data to be validated */
if (RegRecPtr->ValidationFuncPtr != NULL)
{
if (CmdPtr->ActiveTableFlag)
{
RegRecPtr->ValidateActiveIndex = ValIndex;
}
else
{
RegRecPtr->ValidateInactiveIndex = ValIndex;
}
/* If application requested notification by message, then do so */
if (CFE_TBL_SendNotificationMsg(RegRecPtr) == CFE_SUCCESS)
{
/* Notify ground that validation request has been made */
CFE_EVS_SendEvent(CFE_TBL_VAL_REQ_MADE_INF_EID, CFE_EVS_EventType_DEBUG,
"Tbl Services issued validation request for '%s'", TableName);
}
/* Maintain statistic on number of validation requests given to applications */
CFE_TBL_Global.NumValRequests++;
}
else
{
/* If there isn't a validation function pointer, then the process is complete */
/* By setting this value, we are letting the Housekeeping process recognize it */
/* as data to be sent to the ground in telemetry. */
CFE_TBL_Global.ValidationResults[ValIndex].State = CFE_TBL_VALIDATION_PERFORMED;
CFE_EVS_SendEvent(CFE_TBL_ASSUMED_VALID_INF_EID, CFE_EVS_EventType_INFORMATION,
"Tbl Services assumes '%s' is valid. No Validation Function has been registered",
TableName);
}
/* Increment Successful Command Counter */
ReturnCode = CFE_TBL_INC_CMD_CTR;
}
else
{
CFE_EVS_SendEvent(CFE_TBL_TOO_MANY_VALIDATIONS_ERR_EID, CFE_EVS_EventType_ERROR,
"Too many Table Validations have been requested");
}
}
}
else /* Table could not be found in Registry */
{
CFE_EVS_SendEvent(CFE_TBL_NO_SUCH_TABLE_ERR_EID, CFE_EVS_EventType_ERROR,
"Unable to locate '%s' in Table Registry", TableName);
}
return ReturnCode;
}
/*----------------------------------------------------------------
*
* Function: CFE_TBL_ActivateCmd
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_TBL_ActivateCmd(const CFE_TBL_ActivateCmd_t *data)
{
CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */
int16 RegIndex;
const CFE_TBL_ActivateCmd_Payload_t *CmdPtr = &data->Payload;
char TableName[CFE_TBL_MAX_FULL_NAME_LEN];
CFE_TBL_RegistryRec_t * RegRecPtr;
bool ValidationStatus;
/* Make sure all strings are null terminated before attempting to process them */
CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, sizeof(TableName), sizeof(CmdPtr->TableName));
/* Before doing anything, lets make sure the table that is to be dumped exists */
RegIndex = CFE_TBL_FindTableInRegistry(TableName);
if (RegIndex != CFE_TBL_NOT_FOUND)
{
/* Obtain a pointer to registry information about specified table */
RegRecPtr = &CFE_TBL_Global.Registry[RegIndex];
if (RegRecPtr->DumpOnly)
{
CFE_EVS_SendEvent(CFE_TBL_ACTIVATE_DUMP_ONLY_ERR_EID, CFE_EVS_EventType_ERROR,
"Illegal attempt to activate dump-only table '%s'", TableName);
}
else if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS)
{
/* Determine if the inactive buffer has been successfully validated or not */
if (RegRecPtr->DoubleBuffered)
{
ValidationStatus = RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].Validated;
}
else
{
ValidationStatus = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Validated;
}