Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite56d43c

Browse files
committed
Added Checksum signal detection.
1 parenta7d6cf0 commite56d43c

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

‎src/codegen/fs-creator.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ bool FsCreator::PrepareDirectory(std::string drvname, std::string basepath, bool
120120
snprintf(_tmpb,kTmpLen,"%s_AUTO_ROLL", FS.DRVNAME.c_str());
121121
FS.useroll_def = _tmpb;
122122

123+
snprintf(_tmpb,kTmpLen,"%s_AUTO_CSM", FS.DRVNAME.c_str());
124+
FS.usecsm_def = _tmpb;
123125
}
124126

125127
return ret;

‎src/codegen/fs-creator.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef struct
2727
std::string usemon_def;
2828
std::string usesigfloat_def;
2929
std::string useroll_def;
30+
std::string usecsm_def;
3031

3132
} FsDescriptor_t;
3233

‎src/parser/dbcscanner.cpp‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ void DbcScanner::ParseOtherInfo(istream& readstrm)
144144
{
145145
if (cmmnt.SigName == msg->Signals[i].Name)
146146
{
147+
SignalDescriptor_t& sig = msg->Signals[i];
147148
// signal has been found, update commnet text
148149
msg->Signals[i].CommentText = cmmnt.Text;
149150

@@ -153,6 +154,38 @@ void DbcScanner::ParseOtherInfo(istream& readstrm)
153154
// set the RollSig to generate necessary code
154155
msg->RollSig = &msg->Signals[i];
155156
}
157+
158+
extern std::vector<std::string>resplit(const std::string & s,const std::string & rgx_str);
159+
160+
size_t openpos = cmmnt.Text.find('<');
161+
162+
if (openpos != std::string::npos)
163+
{
164+
size_t closepos = cmmnt.Text.find('>', openpos);
165+
166+
if ((closepos != std::string::npos) && (closepos > (openpos +1)))
167+
{
168+
auto substr = cmmnt.Text.substr(openpos +1, closepos -1);
169+
170+
auto meta =resplit(substr,"(\:)");
171+
172+
if (meta.size() ==3 && meta[0] =="Checksum")
173+
{
174+
// the signal can be CSM, but additional settings must be
175+
// checked: size, boundary, signal type
176+
bool boundary_ok = (sig.Order == BitLayout::kIntel) ?
177+
((sig.StartBit /8) == ((sig.StartBit + sig.LengthBit -1) /8)) :
178+
((sig.StartBit /8) == ((sig.StartBit - sig.LengthBit +1) /8));
179+
180+
if (sig.IsSimpleSig && boundary_ok && sig.Signed ==false)
181+
{
182+
msg->CsmSig = &sig;
183+
msg->CsmMethod = meta[1];
184+
msg->CsmOp =atoi(meta[2].c_str());
185+
}
186+
}
187+
}
188+
}
156189
}
157190
}
158191
}
@@ -252,4 +285,7 @@ void DbcScanner::SetDefualtMessage(MessageDescriptor_t* message)
252285
message->Transmitter ="";
253286
message->hasPhys =false;
254287
message->RollSig =nullptr;
288+
message->CsmSig =nullptr;
289+
message->CsmMethod ="";
290+
message->CsmOp =0;
255291
}

‎src/types/message.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ typedef struct
112112
// pointer to rolling counter signal
113113
SignalDescriptor_t* RollSig;
114114

115+
// pointer to checksum signal
116+
SignalDescriptor_t* CsmSig;
117+
118+
// keeps the method or crc algorythm (will be passed to CRC calc function)
119+
std::string CsmMethod;
120+
121+
// option value (will be passed to CRC calc function)
122+
uint32_t CsmOp;
123+
115124
// Message comment
116125
std::string CommentText;
117126

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp