GCC Code Coverage Report


Directory: ./
File: Svc/Version/Version.cpp
Date: 2026-09-23 21:11:01
Exec Total Coverage
Lines: 154 160 96.2%
Functions: 13 13 100.0%
Branches: 125 140 89.3%

Line Branch Exec Source
1 // ======================================================================
2 // \title Version.cpp
3 // \author sreddy
4 // \brief cpp file for Version component implementation class
5 // ======================================================================
6
7 #include "Svc/Version/Version.hpp"
8 #include "Fw/FPrimeBasicTypes.hpp"
9
10 #include "versions/version.hpp" //autogenerated file containing hardcoded project and framework versions
11
12 namespace Svc {
13
14 // ----------------------------------------------------------------------
15 // Component construction and destruction
16 // ----------------------------------------------------------------------
17
18 5 Version ::Version(const char* const compName)
19
3/9
✓ Branch 9 taken 50 times.
✓ Branch 12 taken 50 times.
✓ Branch 13 taken 5 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
55 : VersionComponentBase(compName), m_enable(false), m_num_custom_elements(0) {
20
1/1
✓ Branch 2 taken 5 times.
5 Fw::String version_string = "no_ver";
21 // initialize all custom entries
22
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 5 times.
55 for (FwIndexType id = 0; id < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS; id++) {
23 // setVersion_enum is by default set to the first enum value, so not setting it here
24
1/1
✓ Branch 7 taken 50 times.
50 this->verId_db[id].set_version_value(version_string);
25
1/1
✓ Branch 7 taken 50 times.
50 this->verId_db[id].set_version_status(VersionStatus::FAILURE);
26 }
27 10 }
28
29
3/4
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 11 taken 50 times.
✓ Branch 12 taken 5 times.
110 Version ::~Version() {}
30
31 1 void Version::config(bool enable) {
32 // Set Verbosity for custom versions
33 1 this->m_enable = enable;
34 1 }
35
36 1 void Version::start() {
37 // Send startup TLM and EVENTS
38 1 this->fwVersion_tlm();
39 1 this->projectVersion_tlm();
40 1 this->libraryVersion_tlm();
41 1 }
42 // ----------------------------------------------------------------------
43 // Handler implementations for user-defined typed input ports
44 // ----------------------------------------------------------------------
45
46 6 void Version ::getVersion_handler(FwIndexType portNum,
47 const Svc::VersionCfg::VersionEnum& version_id,
48 Fw::StringBase& version_string,
49 Svc::VersionStatus& status) {
50 6 FW_ASSERT(version_id.isValid(), version_id.e);
51 6 FW_ASSERT(static_cast<Svc::VersionCfg::VersionEnum::SerialType>(version_id.e) <
52 Svc::VersionCfg::VersionEnum::NUM_CONSTANTS,
53 version_id.e);
54
1/2
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
6 U8 version_slot = VersionSlot(version_id.e);
55 6 version_string = static_cast<const Fw::StringBase&>(this->verId_db[version_slot].get_version_value());
56 6 status = this->verId_db[version_slot].get_version_status();
57 6 }
58
59 342 void Version ::setVersion_handler(FwIndexType portNum,
60 const Svc::VersionCfg::VersionEnum& version_id,
61 Fw::StringBase& version_string,
62 Svc::VersionStatus& status) {
63 342 FW_ASSERT(version_id.isValid(), version_id.e);
64 342 FW_ASSERT(static_cast<Svc::VersionCfg::VersionEnum::SerialType>(version_id.e) <
65 Svc::VersionCfg::VersionEnum::NUM_CONSTANTS,
66 version_id.e);
67
1/2
✗ Branch 3 not taken.
✓ Branch 4 taken 342 times.
342 auto ver_slot = VersionSlot(version_id.e);
68 // Count each slot once: rewrites of a populated slot must not grow the count
69
4/4
✓ Branch 12 taken 23 times.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 23 times.
✓ Branch 15 taken 319 times.
365 if ((this->verId_db[ver_slot].get_version_value() == "no_ver") &&
70
1/2
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 (this->m_num_custom_elements < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS)) {
71 23 this->m_num_custom_elements++;
72 }
73 342 this->verId_db[ver_slot].set_version_enum(version_id);
74 342 this->verId_db[ver_slot].set_version_value(version_string);
75 342 this->verId_db[ver_slot].set_version_status(status);
76 342 this->customVersion_tlm(ver_slot);
77 342 }
78
79 // ----------------------------------------------------------------------
80 // Handler implementations for commands
81 // ----------------------------------------------------------------------
82
83 6 void Version ::ENABLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Svc::VersionEnabled& enable) {
84 6 this->m_enable = (enable == VersionEnabled::ENABLED);
85
86
2/2
✓ Branch 6 taken 6 times.
✓ Branch 9 taken 6 times.
6 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
87 6 }
88
89 // Command handler to event versions
90 9 void Version ::VERSION_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Svc::VersionType& version_type) {
91 9 FW_ASSERT(version_type.isValid(), version_type.e);
92
93
5/6
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
9 switch (version_type) {
94 1 case (Svc::VersionType::PROJECT):
95 1 this->projectVersion_tlm();
96 1 break;
97
98 1 case (Svc::VersionType::FRAMEWORK):
99 1 this->fwVersion_tlm();
100 1 break;
101
102 1 case (Svc::VersionType::LIBRARY):
103 1 this->libraryVersion_tlm();
104 1 break;
105
106 4 case (Svc::VersionType::CUSTOM):
107 4 this->customVersion_tlm_all();
108 4 break;
109
110 2 case (Svc::VersionType::ALL):
111 2 this->projectVersion_tlm();
112 2 this->fwVersion_tlm();
113 2 this->libraryVersion_tlm();
114 2 this->customVersion_tlm_all();
115 2 break;
116 ✗ default:
117 ✗ FW_ASSERT(false, version_type);
118 ✗ break;
119 }
120
121
2/2
✓ Branch 6 taken 9 times.
✓ Branch 9 taken 9 times.
9 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
122 9 }
123 // ----------------------------------------------------------------------
124 // implementations for internal functions
125 // ----------------------------------------------------------------------
126 // Send both events and tlm for framework version
127 4 void Version ::fwVersion_tlm() {
128
1/1
✓ Branch 2 taken 4 times.
4 Fw::LogStringArg fw_event = (Project::Version::FRAMEWORK_VERSION);
129
1/1
✓ Branch 5 taken 4 times.
4 this->log_ACTIVITY_LO_FrameworkVersion(fw_event);
130
1/1
✓ Branch 2 taken 4 times.
4 Fw::TlmString fw_tlm = (Project::Version::FRAMEWORK_VERSION);
131
2/2
✓ Branch 6 taken 4 times.
✓ Branch 9 taken 4 times.
4 this->tlmWrite_FrameworkVersion(fw_tlm);
132 8 }
133
134 // Send both events and tlm for project version
135 4 void Version ::projectVersion_tlm() {
136
1/1
✓ Branch 2 taken 4 times.
4 Fw::LogStringArg proj_event = Project::Version::PROJECT_VERSION;
137
1/1
✓ Branch 5 taken 4 times.
4 this->log_ACTIVITY_LO_ProjectVersion(proj_event);
138
1/1
✓ Branch 2 taken 4 times.
4 Fw::TlmString proj_tlm = Project::Version::PROJECT_VERSION;
139
2/2
✓ Branch 6 taken 4 times.
✓ Branch 9 taken 4 times.
4 this->tlmWrite_ProjectVersion(proj_tlm);
140 8 }
141
142 // Send both events and tlm for library versions
143 4 void Version ::libraryVersion_tlm() {
144 // Process libraries array
145
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4 times.
52 for (U8 i = 0; i < Project::Version::LIBRARY_VERSIONS_COUNT; i++) {
146 48 FW_ASSERT(Project::Version::LIBRARY_VERSIONS[i] != nullptr, static_cast<FwAssertArgType>(i));
147 // Emit Event/TLM on library versions
148
2/2
✓ Branch 7 taken 48 times.
✓ Branch 11 taken 48 times.
48 this->log_ACTIVITY_LO_LibraryVersions(Fw::LogStringArg(Project::Version::LIBRARY_VERSIONS[i]));
149 // Write to the telemetry channel for this library slot
150
11/11
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 8 times.
48 switch (i) {
151 4 case VER_SLOT_00:
152
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion01(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
153 4 break;
154 4 case VER_SLOT_01:
155
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion02(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
156 4 break;
157 4 case VER_SLOT_02:
158
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion03(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
159 4 break;
160 4 case VER_SLOT_03:
161
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion04(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
162 4 break;
163 4 case VER_SLOT_04:
164
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion05(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
165 4 break;
166 4 case VER_SLOT_05:
167
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion06(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
168 4 break;
169 4 case VER_SLOT_06:
170
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion07(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
171 4 break;
172 4 case VER_SLOT_07:
173
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion08(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
174 4 break;
175 4 case VER_SLOT_08:
176
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion09(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
177 4 break;
178 4 case VER_SLOT_09:
179
3/3
✓ Branch 6 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 15 taken 4 times.
4 this->tlmWrite_LibraryVersion10(Fw::TlmString(Project::Version::LIBRARY_VERSIONS[i]));
180 4 break;
181 8 default:
182 // It is possible to have more than 10 library versions; however design agreed to only
183 // provide 10 TLM channels for it
184 8 break;
185 }
186 }
187 4 }
188
189 // Send all events and tlm (if verbosity is enabled) for custom versions
190 6 void Version ::customVersion_tlm_all() {
191
3/4
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 6 times.
66 for (U8 i = 0; (m_num_custom_elements != 0) && (i < Svc::VersionCfg::VersionEnum::NUM_CONSTANTS); i++) {
192 60 Version::customVersion_tlm(VersionSlot(i));
193 }
194 6 }
195
196 // Send events and tlm (if verbosity is enabled) for custom versions
197 402 void Version ::customVersion_tlm(VersionSlot custom_slot) {
198 // Process custom version TLM only if verbosity is enabled and there are any valid writes to it;
199 // it doesn't necessarily have to be consecutive
200
4/4
✓ Branch 12 taken 369 times.
✓ Branch 13 taken 33 times.
✓ Branch 14 taken 369 times.
✓ Branch 15 taken 33 times.
771 if ((this->verId_db[custom_slot].get_version_value() != "no_ver") &&
201
1/2
✓ Branch 4 taken 369 times.
✗ Branch 5 not taken.
369 (this->m_num_custom_elements > 0)) { // Write TLM for valid writes
202
203 // Emit Events/TLM on custom versions
204
2/2
✓ Branch 15 taken 369 times.
✓ Branch 19 taken 369 times.
738 this->log_ACTIVITY_LO_CustomVersions(this->verId_db[custom_slot].get_version_enum(),
205 369 this->verId_db[custom_slot].get_version_value());
206
207
3/4
✗ Branch 3 not taken.
✓ Branch 4 taken 369 times.
✓ Branch 5 taken 353 times.
✓ Branch 6 taken 16 times.
369 if (m_enable == true) { // Send TLM only if verbosity is enabled
208 // Write to TLM
209
10/11
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 306 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
353 switch (custom_slot) {
210 6 case VER_SLOT_00:
211
2/2
✓ Branch 6 taken 6 times.
✓ Branch 13 taken 6 times.
6 this->tlmWrite_CustomVersion01(verId_db[custom_slot]);
212 6 break;
213 5 case VER_SLOT_01:
214
2/2
✓ Branch 6 taken 5 times.
✓ Branch 13 taken 5 times.
5 this->tlmWrite_CustomVersion02(verId_db[custom_slot]);
215 5 break;
216 5 case VER_SLOT_02:
217
2/2
✓ Branch 6 taken 5 times.
✓ Branch 13 taken 5 times.
5 this->tlmWrite_CustomVersion03(verId_db[custom_slot]);
218 5 break;
219 306 case VER_SLOT_03:
220
2/2
✓ Branch 6 taken 306 times.
✓ Branch 13 taken 306 times.
306 this->tlmWrite_CustomVersion04(verId_db[custom_slot]);
221 306 break;
222 5 case VER_SLOT_04:
223
2/2
✓ Branch 6 taken 5 times.
✓ Branch 13 taken 5 times.
5 this->tlmWrite_CustomVersion05(verId_db[custom_slot]);
224 5 break;
225 6 case VER_SLOT_05:
226
2/2
✓ Branch 6 taken 6 times.
✓ Branch 13 taken 6 times.
6 this->tlmWrite_CustomVersion06(verId_db[custom_slot]);
227 6 break;
228 5 case VER_SLOT_06:
229
2/2
✓ Branch 6 taken 5 times.
✓ Branch 13 taken 5 times.
5 this->tlmWrite_CustomVersion07(verId_db[custom_slot]);
230 5 break;
231 5 case VER_SLOT_07:
232
2/2
✓ Branch 6 taken 5 times.
✓ Branch 13 taken 5 times.
5 this->tlmWrite_CustomVersion08(verId_db[custom_slot]);
233 5 break;
234 5 case VER_SLOT_08:
235
2/2
✓ Branch 6 taken 5 times.
✓ Branch 13 taken 5 times.
5 this->tlmWrite_CustomVersion09(verId_db[custom_slot]);
236 5 break;
237 5 case VER_SLOT_09:
238
2/2
✓ Branch 6 taken 5 times.
✓ Branch 13 taken 5 times.
5 this->tlmWrite_CustomVersion10(verId_db[custom_slot]);
239 5 break;
240 ✗ default:
241 // There are only 10 custom slots available
242 ✗ FW_ASSERT(false, custom_slot);
243 ✗ break;
244 }
245 }
246 }
247 402 }
248
249 } // namespace Svc
250