Skip to content

Commit 268e168

Browse files
authored
Restructure core subtopologies and add Svc_Subtopologies target (#3904)
* Modify Com/Ccsds/Fprime ComDriverConfig & TopologyDefs for easier ComDriver config * Fix BaseID collision * Removed restrict platform, UART/TCP driver configs different files, CMake switch depending on FPRIME_HAS_SOCKETS * Add Exclude_FROM_ALL to all subtopology cmake modules * remove exclude from ComCcsds (needed for Ref) * Remove exclude from all for testing * Exclude_from_all only on comLoggerTee, comFprime (not used in Ref) * Added Svc_Subtopologies target * Use add_custom_target, spelling fix * Add Configs to Svc_Subtopologies target * Removed comDriver as instance within subtopologies, now within project topology * Take out cmdSeq from ComSubtopologies, put in FileHandling * Added Subtopology States for all, common pattern users can follow * Fix Extra newline * Moved Phased comDriver code into RefTopology.cpp * Update metadata check-spelling run (pull_request_target) for subtopology-config-phasing-updates Signed-off-by: check-spelling-bot <[email protected]> on-behalf-of: @check-spelling <[email protected]> * Fixed call to default stack size * Moved cmdSeq from FileHandling subtopology to Ref Root Topology * Fix integration test * Remove unneeded Os includes in RefTopology.cpp * Fix BaseIds * Add comment for BaseIDs, comDriver configuration order fix * Restructure of enums within Com Subtopologies * Correct include for ComCcsds enum headers * Using namespace syntax change * Fix BaseIds * Update metadata check-spelling run (pull_request_target) for subtopology-config-phasing-updates Signed-off-by: check-spelling-bot <[email protected]> on-behalf-of: @check-spelling <[email protected]> * Remove unneeded Dependency * Add enum at the top * Fix RefTopology.cpp * Update Comment --------- Signed-off-by: check-spelling-bot <[email protected]> Co-authored-by: Moises Mata <[email protected]>
1 parent 1fe6a7c commit 268e168

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+239
-250
lines changed

.github/actions/spelling/expect.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ ANamespace
1414
apid
1515
APIDOCS
1616
APPENDFILE
17-
aps
1817
arduino
1918
ARef
2019
argcomplete
@@ -65,6 +64,7 @@ ccsds
6564
ccsparc
6665
cdh
6766
CDHCORE
67+
CDHCORESUBTOPOLOGY
6868
cerrno
6969
CFDP
7070
cff
@@ -122,7 +122,6 @@ crckermit
122122
CRCs
123123
crcstat
124124
CREATEDIRECTORY
125-
Crosscompiling
126125
crsmith
127126
crt
128127
CRTSCTS
@@ -132,6 +131,7 @@ ctest
132131
ctu
133132
culates
134133
cuz
134+
Cxxx
135135
CYCLEOUT
136136
DATAPRODUCTS
137137
DATAPRODUCTSSUBTOPOLOGY
@@ -178,6 +178,7 @@ DRAINBUFFERS
178178
drv
179179
drvtcpserversocket
180180
dspal
181+
DSSC
181182
Dstate
182183
DVI
183184
DWN
@@ -256,8 +257,6 @@ gcgandhi
256257
gcov
257258
gdiplus
258259
GENHUB
259-
getfooter
260-
getstatements
261260
gettime
262261
getty
263262
ghprb
@@ -400,7 +399,6 @@ mman
400399
MMAPALLOCATOR
401400
MML
402401
modbus
403-
MOSI
404402
MOVEFILE
405403
msc
406404
mscfile
@@ -496,7 +494,6 @@ PRMDBIMPL
496494
PRMDBIMPLTESTERCFG
497495
PRMDBLIMPLCFG
498496
PRMDBTESTER
499-
PRMLEDINITSTATE
500497
PROCBUFFERSENDOUT
501498
PRODUCTGETIN
502499
PRODUCTREQUESTIN
@@ -551,10 +548,7 @@ RHH
551548
Rizvi
552549
ROOTDIR
553550
rpi
554-
RPIDEMO
555-
RPIDEMOCOMPONENTIMPLCFG
556551
rptr
557-
RXD
558552
SAlias
559553
sanitizers
560554
sats
@@ -586,7 +580,6 @@ SHAREDSTATEDIR
586580
SHELLCOMMAND
587581
showinitializer
588582
sideeffect
589-
sighandler
590583
Signedness
591584
Silveira
592585
sitofp
@@ -682,7 +675,6 @@ tparam
682675
TPP
683676
trinomials
684677
tts
685-
TXD
686678
typedef'ed
687679
typedef
688680
uart

.github/workflows/cppcheck-scan.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
run: |
4848
fprime-util generate -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
4949
fprime-util build --all --jobs "$(nproc || printf '%s\n' 1)"
50+
51+
# Since our subtopologies have EXCLUDE_FROM_ALL, we need to explicitly build them
52+
fprime-util build --target Svc_Subtopologies --jobs "$(nproc || printf '%s\n' 1)"
5053
echo CPPCHECK_OPTS=--project="$GITHUB_WORKSPACE/build-fprime-automatic-native/compile_commands.json" >> $GITHUB_ENV
5154
5255
- name: Run cppcheck

Ref/Main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ int main(int argc, char* argv[]) {
8282
}
8383
// Object for communicating state to the reference topology
8484
Ref::TopologyState inputs;
85-
inputs.comCcsds.hostname = hostname;
86-
inputs.comCcsds.port = port_number;
85+
inputs.hostname = hostname;
86+
inputs.port = port_number;
8787

8888
// Setup program shutdown via Ctrl-C
8989
signal(SIGINT, signalHandler);

Ref/Top/RefPackets.fppi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ telemetry packets RefPackets {
99
FileHandling.fileDownlink.PacketsSent
1010
FileHandling.fileManager.CommandsExecuted
1111

12-
ComCcsds.cmdSeq.CS_LoadCommands
13-
ComCcsds.cmdSeq.CS_CancelCommands
14-
ComCcsds.cmdSeq.CS_CommandsExecuted
15-
ComCcsds.cmdSeq.CS_SequencesCompleted
12+
Ref.cmdSeq.CS_LoadCommands
13+
Ref.cmdSeq.CS_CancelCommands
14+
Ref.cmdSeq.CS_CommandsExecuted
15+
Ref.cmdSeq.CS_SequencesCompleted
1616
ComCcsds.comQueue.comQueueDepth
1717
ComCcsds.comQueue.buffQueueDepth
1818
ComCcsds.commsBufferManager.TotalBuffs
@@ -32,7 +32,7 @@ telemetry packets RefPackets {
3232
FileHandling.fileDownlink.Warnings
3333
FileHandling.fileManager.Errors
3434

35-
ComCcsds.cmdSeq.CS_Errors
35+
Ref.cmdSeq.CS_Errors
3636
ComCcsds.commsBufferManager.NoBuffs
3737
ComCcsds.commsBufferManager.EmptyBuffs
3838

Ref/Top/RefTopology.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88
// ALL RIGHTS RESERVED. United States Government Sponsorship
99
// acknowledged.
1010
// ======================================================================
11+
1112
// Provides access to autocoded functions
1213
#include <Ref/Top/RefTopologyAc.hpp>
1314

1415
// Necessary project-specified types
15-
#include <Os/Console.hpp>
16+
#include <Fw/Types/MallocAllocator.hpp>
1617

17-
// Used for 1Hz synthetic cycling
18-
#include <Os/Mutex.hpp>
1918

2019
// Allows easy reference to objects in FPP/autocoder required namespaces
2120
using namespace Ref;
2221

23-
// Instantiate a system logger that will handle Fw::Logger::log calls
24-
Os::Console logger;
22+
// Instantiate a malloc allocator for cmdSeq buffer allocation
23+
Fw::MallocAllocator mallocator;
2524

2625
// The reference topology divides the incoming clock signal (1Hz) into sub-signals: 1Hz, 1/2Hz, and 1/4Hz and
2726
// zero offset for all the dividers
@@ -33,6 +32,10 @@ U32 rateGroup1Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {};
3332
U32 rateGroup2Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {};
3433
U32 rateGroup3Context[Svc::ActiveRateGroup::CONNECTION_COUNT_MAX] = {};
3534

35+
enum TopologyConstants {
36+
COMM_PRIORITY = 100,
37+
};
38+
3639
/**
3740
* \brief configure/setup components in project-specific way
3841
*
@@ -48,6 +51,9 @@ void configureTopology() {
4851
rateGroup1Comp.configure(rateGroup1Context, FW_NUM_ARRAY_ELEMENTS(rateGroup1Context));
4952
rateGroup2Comp.configure(rateGroup2Context, FW_NUM_ARRAY_ELEMENTS(rateGroup2Context));
5053
rateGroup3Comp.configure(rateGroup3Context, FW_NUM_ARRAY_ELEMENTS(rateGroup3Context));
54+
55+
// Command sequencer needs to allocate memory to hold contents of command sequences
56+
cmdSeq.allocateBuffer(0, mallocator, 5 * 1024);
5157
}
5258

5359
// Public functions for use in main program are namespaced with deployment name Ref
@@ -63,12 +69,20 @@ void setupTopology(const TopologyState& state) {
6369
regCommands();
6470
// Autocoded configuration. Function provided by autocoder.
6571
configComponents(state);
72+
if (state.hostname != nullptr && state.port != 0) {
73+
comDriver.configure(state.hostname, state.port);
74+
}
6675
// Project-specific component configuration. Function provided above. May be inlined, if desired.
6776
configureTopology();
6877
// Autocoded parameter loading. Function provided by autocoder.
6978
loadParameters();
7079
// Autocoded task kick-off (active components). Function provided by autocoder.
7180
startTasks(state);
81+
//Initialize socket client communication if and only if there is a valid specification
82+
if (state.hostname != nullptr && state.port != 0) {
83+
Os::TaskString name("ReceiveTask");
84+
comDriver.start(name, COMM_PRIORITY, Default::STACK_SIZE);
85+
}
7286
}
7387

7488
void startRateGroups(Fw::TimeInterval interval) {
@@ -88,5 +102,12 @@ void teardownTopology(const TopologyState& state) {
88102
stopTasks(state);
89103
freeThreads(state);
90104
tearDownComponents(state);
105+
106+
//Stop the comDriver component, free thread
107+
comDriver.stop();
108+
(void)comDriver.join();
109+
110+
// Resource deallocation
111+
cmdSeq.deallocateBuffer(mallocator);
91112
}
92113
} // namespace Ref

Ref/Top/RefTopologyDefs.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121
#include "Svc/Subtopologies/FileHandling/PingEntries.hpp"
2222

2323
// SubtopologyTopologyDefs includes
24+
#include "Svc/Subtopologies/CdhCore/SubtopologyTopologyDefs.hpp"
2425
#include "Svc/Subtopologies/ComCcsds/SubtopologyTopologyDefs.hpp"
2526
#include "Svc/Subtopologies/DataProducts/SubtopologyTopologyDefs.hpp"
2627
#include "Svc/Subtopologies/FileHandling/SubtopologyTopologyDefs.hpp"
2728

29+
//ComCcsds Enum Includes
30+
#include "Svc/Subtopologies/ComCcsds/Ports_ComPacketQueueEnumAc.hpp"
31+
#include "Svc/Subtopologies/ComCcsds/Ports_ComBufferQueueEnumAc.hpp"
32+
2833
/**
2934
* \brief required ping constants
3035
*
@@ -50,6 +55,7 @@ namespace PingEntries {
5055
namespace Ref_rateGroup1Comp {enum { WARN = 3, FATAL = 5 };}
5156
namespace Ref_rateGroup2Comp {enum { WARN = 3, FATAL = 5 };}
5257
namespace Ref_rateGroup3Comp {enum { WARN = 3, FATAL = 5 };}
58+
namespace Ref_cmdSeq {enum { WARN = 3, FATAL = 5 };}
5359
} // namespace PingEntries
5460

5561
// Definitions are placed within a namespace named after the deployment
@@ -64,7 +70,12 @@ namespace Ref {
6470
* fields, which are derived by command line inputs.
6571
*/
6672
struct TopologyState {
67-
ComCcsds::SubtopologyState comCcsds; //!< Subtopology state for ComCcsds
73+
const char* hostname; //!< Hostname for TCP communication
74+
U16 port; //!< Port for TCP communication
75+
CdhCore::SubtopologyState cdhCore; //!< Subtopology state for CdhCore
76+
ComCcsds::SubtopologyState comCcsds; //!< Subtopology state for ComCcsds
77+
DataProducts::SubtopologyState dataProducts; //!< Subtopology state for DataProducts
78+
FileHandling::SubtopologyState fileHandling; //!< Subtopology state for FileHandling
6879
};
6980

7081
namespace PingEntries = ::PingEntries;

Ref/Top/instances.fpp

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
module Ref {
22

3+
# ----------------------------------------------------------------------
4+
# Base ID Convention
5+
# ----------------------------------------------------------------------
6+
#
7+
# All Base IDs follow the 8-digit hex format: 0xDSSCCxxx
8+
#
9+
# Where:
10+
# D = Deployment digit (1-F)
11+
# SS = Subtopology digits (00 for main topology, 01-FF)
12+
# CC = Component digits (00-FF)
13+
# xxx = Reserved for internal component items (events, commands, telemetry)
14+
#
15+
316
# ----------------------------------------------------------------------
417
# Defaults
518
# ----------------------------------------------------------------------
@@ -13,67 +26,74 @@ module Ref {
1326
# Active component instances
1427
# ----------------------------------------------------------------------
1528

16-
instance blockDrv: Ref.BlockDriver base id 0x01000000 \
29+
instance blockDrv: Ref.BlockDriver base id 0x10000000 \
1730
queue size Default.QUEUE_SIZE \
1831
stack size Default.STACK_SIZE \
1932
priority 140
2033

21-
instance rateGroup1Comp: Svc.ActiveRateGroup base id 0x01010000 \
34+
instance rateGroup1Comp: Svc.ActiveRateGroup base id 0x10001000 \
2235
queue size Default.QUEUE_SIZE \
2336
stack size Default.STACK_SIZE \
2437
priority 120
2538

26-
instance rateGroup2Comp: Svc.ActiveRateGroup base id 0x01020000 \
39+
instance rateGroup2Comp: Svc.ActiveRateGroup base id 0x10002000 \
2740
queue size Default.QUEUE_SIZE \
2841
stack size Default.STACK_SIZE \
2942
priority 119
3043

31-
instance rateGroup3Comp: Svc.ActiveRateGroup base id 0x01030000 \
44+
instance rateGroup3Comp: Svc.ActiveRateGroup base id 0x10003000 \
3245
queue size Default.QUEUE_SIZE \
3346
stack size Default.STACK_SIZE \
3447
priority 118
3548

36-
instance pingRcvr: Ref.PingReceiver base id 0x01040000 \
49+
instance pingRcvr: Ref.PingReceiver base id 0x10004000 \
3750
queue size Default.QUEUE_SIZE \
3851
stack size Default.STACK_SIZE \
3952
priority 100
4053

41-
instance typeDemo: Ref.TypeDemo base id 0x01050000
54+
instance typeDemo: Ref.TypeDemo base id 0x10005000
55+
56+
instance cmdSeq: Svc.CmdSequencer base id 0x10006000 \
57+
queue size Default.QUEUE_SIZE \
58+
stack size Default.STACK_SIZE \
59+
priority 97
4260

4361
# ----------------------------------------------------------------------
4462
# Queued component instances
4563
# ----------------------------------------------------------------------
4664

47-
instance sendBuffComp: Ref.SendBuff base id 0x01060000 \
65+
instance sendBuffComp: Ref.SendBuff base id 0x10010000 \
4866
queue size Default.QUEUE_SIZE
4967

50-
instance SG1: Ref.SignalGen base id 0x01070000 \
68+
instance SG1: Ref.SignalGen base id 0x10011000 \
5169
queue size Default.QUEUE_SIZE
5270

53-
instance SG2: Ref.SignalGen base id 0x01080000 \
71+
instance SG2: Ref.SignalGen base id 0x10012000 \
5472
queue size Default.QUEUE_SIZE
5573

56-
instance SG3: Ref.SignalGen base id 0x01090000 \
74+
instance SG3: Ref.SignalGen base id 0x10013000 \
5775
queue size Default.QUEUE_SIZE
5876

59-
instance SG4: Ref.SignalGen base id 0x010A0000 \
77+
instance SG4: Ref.SignalGen base id 0x10014000 \
6078
queue size Default.QUEUE_SIZE
6179

62-
instance SG5: Ref.SignalGen base id 0x010B0000 \
80+
instance SG5: Ref.SignalGen base id 0x10015000 \
6381
queue size Default.QUEUE_SIZE
6482

6583
# ----------------------------------------------------------------------
6684
# Passive component instances
6785
# ----------------------------------------------------------------------
6886

69-
instance posixTime: Svc.PosixTime base id 0x010C0000
87+
instance posixTime: Svc.PosixTime base id 0x10020000
88+
89+
instance rateGroupDriverComp: Svc.RateGroupDriver base id 0x10021000
7090

71-
instance rateGroupDriverComp: Svc.RateGroupDriver base id 0x010D0000
91+
instance recvBuffComp: Ref.RecvBuff base id 0x10022000
7292

73-
instance recvBuffComp: Ref.RecvBuff base id 0x010E0000
93+
instance systemResources: Svc.SystemResources base id 0x10023000
7494

75-
instance systemResources: Svc.SystemResources base id 0x010F0000
95+
instance linuxTimer: Svc.LinuxTimer base id 0x10024000
7696

77-
instance linuxTimer: Svc.LinuxTimer base id 0x01100000
97+
instance comDriver: Drv.TcpClient base id 0x10025000
7898

7999
}

0 commit comments

Comments
 (0)