Skip to content

Commit ba88964

Browse files
committed
Fixed comment style. CYC value bug.
1 parent 950ed79 commit ba88964

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

src/codegen/c-main-generator.cpp

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,8 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs, const Fs
146146
// write message typedef s and additional expressions
147147
MessageDescriptor_t& m = sigprt->sigs_expr[num]->msg;
148148

149-
fwriter->AppendLine(
150-
PrintF("uint32_t Unpack_%s_%s(%s_t* _m, const uint8_t* _d, uint8_t dlc_);",
151-
m.Name.c_str(), fsd.DrvName_orig.c_str(), m.Name.c_str()));
149+
fwriter->AppendLine(PrintF("uint32_t Unpack_%s_%s(%s_t* _m, const uint8_t* _d, uint8_t dlc_);",
150+
m.Name.c_str(), fsd.DrvName_orig.c_str(), m.Name.c_str()));
152151

153152
fwriter->AppendLine(PrintF("#ifdef %s", fsd.usesruct_def.c_str()));
154153

@@ -269,19 +268,35 @@ void CiMainGenerator::WriteSigStructField(const SignalDescriptor_t& sig, bool bi
269268

270269
fwriter->AppendText(PrintF(" Bits=%2d", sig.LengthBit));
271270

272-
if (sig.Unit.size() > 0)
271+
if (sig.IsDoubleSig)
273272
{
274-
fwriter->AppendText(PrintF(" Unit:'%-13s'", sig.Unit.c_str()));
275-
}
273+
if (sig.Offset != 0)
274+
{
275+
fwriter->AppendText(PrintF(" Offset= %-18f", sig.Offset));
276+
}
276277

277-
if (sig.Offset != 0)
278+
if (sig.Factor != 1)
279+
{
280+
fwriter->AppendText(PrintF(" Factor= %-15f", sig.Factor));
281+
}
282+
}
283+
else if (sig.IsSimpleSig == false)
278284
{
279-
fwriter->AppendText(PrintF(" Offset= %-18f", sig.Offset));
285+
// 2 type of signal
286+
if (sig.Offset != 0)
287+
{
288+
fwriter->AppendText(PrintF(" Offset= %-18d", sig.Offset));
289+
}
290+
291+
if (sig.Factor != 1)
292+
{
293+
fwriter->AppendText(PrintF(" Factor= %-15d", sig.Factor));
294+
}
280295
}
281296

282-
if (sig.Factor != 1)
297+
if (sig.Unit.size() > 0)
283298
{
284-
fwriter->AppendText(PrintF(" Factor= %-15d", sig.LengthBit));
299+
fwriter->AppendText(PrintF(" Unit:'%s'", sig.Unit.c_str()));
285300
}
286301

287302
fwriter->AppendLine("", 2);

src/parser/dbcscanner.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ void DbcScanner::ParseMessageInfo(istream& readstrm)
7676
// create instance for the detected message
7777
pMsg = new MessageDescriptor_t;
7878

79+
SetDefualtMessage(pMsg);
80+
7981
if (!lparser.ParseMessageLine(pMsg, sline))
8082
{
8183
// the message has invalid format so drop it and wait next one
@@ -199,10 +201,10 @@ void DbcScanner::AddMessage(MessageDescriptor_t* message)
199201
{
200202
// sort signals by start bit
201203
std::sort(message->Signals.begin(), message->Signals.end(),
202-
[](const SignalDescriptor_t& a, const SignalDescriptor_t& b) -> bool
203-
{
204-
return a.StartBit < b.StartBit;
205-
});
204+
[](const SignalDescriptor_t& a, const SignalDescriptor_t& b) -> bool
205+
{
206+
return a.StartBit < b.StartBit;
207+
});
206208

207209
for (size_t i = 0; i < message->Signals.size(); i++)
208210
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy