Skip to content

Commit c620841

Browse files
committed
Added mon1 field if defined setting.
1 parent 2a2ff62 commit c620841

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/codegen/c-main-generator.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
static const size_t kMaxDirNum = 1000;
1313

1414
static const size_t kWBUFF_len = 2048;
15+
1516
static char wbuff[kWBUFF_len] = {0};
1617

1718
static std::string __typeprint[] =
@@ -70,9 +71,25 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs,
7071
mhead.fpath = mhead.dir + "/" + mhead.fname;
7172

7273
// 1 step is to define final directory for source code bunch
73-
fwriter->AppendLine("#pragma once", 3);
74+
fwriter->AppendLine("#pragma once", 2);
7475
fwriter->AppendLine("#ifdef __cplusplus\nextern \"C\" {\n#endif", 2);
75-
fwriter->AppendLine("#include <stdint.h>");
76+
fwriter->AppendLine("#include <stdint.h>", 2);
77+
78+
snprintf(wbuff, kWBUFF_len, "#ifdef %s", usediag_str.c_str());
79+
fwriter->AppendLine(wbuff);
80+
81+
fwriter->AppendText(
82+
"// This file must define:\n"
83+
"// base monitor struct\n"
84+
"// function signature for CRC calculation\n"
85+
"// function signature for getting system tick value (100 us step)\n"
86+
"#include \"canmonitorutil.h\"\n"
87+
"\n"
88+
89+
);
90+
91+
snprintf(wbuff, kWBUFF_len, "#endif // %s", usediag_str.c_str());
92+
fwriter->AppendLine(wbuff, 3);
7693

7794
for (size_t num = 0; num < sigprt->sigs_expr.size(); num++)
7895
{
@@ -116,6 +133,9 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs,
116133
max_sig_name_len = s.Name.size();
117134
}
118135

136+
// empty line before struct definition
137+
fwriter->AppendLine("\n");
138+
119139
snprintf(wbuff, kWBUFF_len, "typedef struct");
120140
fwriter->AppendLine(wbuff);
121141

@@ -145,13 +165,17 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs,
145165
snprintf(wbuff, kWBUFF_len, "#endif // %s", usebits_str.c_str());
146166
fwriter->AppendLine(wbuff, 2);
147167

148-
//if (CodeSett.Code.UseMonitors == 1)
149-
// fwriter->AppendLine(" FrameMonitor_t mon1;");
168+
// start mon1 section
169+
snprintf(wbuff, kWBUFF_len, "#ifdef %s", usebits_str.c_str());
170+
fwriter->AppendLine(wbuff, 2);
171+
172+
fwriter->AppendLine(" FrameMonitor_t mon1;", 2);
173+
174+
snprintf(wbuff, kWBUFF_len, "#endif // %s", usebits_str.c_str());
175+
fwriter->AppendLine(wbuff, 2);
150176

151177
snprintf(wbuff, kWBUFF_len, "} %s_t;", m.Name.c_str());
152178
fwriter->AppendLine(wbuff, 2);
153-
//fwriter->AppendLine("} " + msg.MessageName + "_t;");
154-
//fwriter->AppendLine();
155179
}
156180

157181
fwriter->AppendLine("#ifdef __cplusplus\n}\n#endif");

0 commit comments

Comments
 (0)