Skip to content

Commit 6798987

Browse files
committed
Added CSM check in unpack function.
1 parent e56d43c commit 6798987

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/codegen/c-main-generator.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@ void CiMainGenerator::WriteUnpackBody(const CiExpr_t* sgs)
461461
fwriter->AppendLine(PrintF("#ifdef // %s", fdesc->useroll_def.c_str()), 2);
462462
}
463463

464+
if (sgs->msg.CsmSig != nullptr)
465+
{
466+
// Put checksum check function call here
467+
fwriter->AppendLine(PrintF("#ifdef %s", fdesc->usecsm_def.c_str()), 2);
468+
fwriter->AppendLine(PrintF(" _m->mon1.csm_error = ((uint8_t)GetFrameCRC(_d, %s_DLC, %s_CANID, %s, %d)) != (_m->%s))",
469+
sgs->msg.Name.c_str(), sgs->msg.Name.c_str(), sgs->msg.CsmMethod.c_str(),
470+
sgs->msg.CsmOp, sgs->msg.CsmSig->Name.c_str()), 2);
471+
fwriter->AppendLine(PrintF("#endif // %s", fdesc->usecsm_def.c_str()), 2);
472+
}
464473

465474
auto Fmon_func = "FMon_" + sgs->msg.Name + "_" + fdesc->drvname;
466475

0 commit comments

Comments
 (0)