GCC Code Coverage Report


Directory: ./
File: Svc/Version/Version.cpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 153 159 96.2%
Functions: 13 13 100.0%
Branches: 120 138 87.0%

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