Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling multiline VAL_ #35

Open
WojciechJasko-BB opened this issue Aug 22, 2024 · 0 comments
Open

Incorrect handling multiline VAL_ #35

WojciechJasko-BB opened this issue Aug 22, 2024 · 0 comments

Comments

@WojciechJasko-BB
Copy link

When VAL_ in DBC is splited in multiple lines, then generated comment is invalid (it does not compile).

For example this line:

VAL_ 11111 Bat_Status 0 "Battery level above 2.1V
" 1 " Low Battery(below 2.1V)
" ;

will produce:

  uint8_t Bat_Status : 1;   //      Bits= 1

  //  0 : "Battery level above 2.1V
"
  //  1 : " Low Battery(below 2.1V)
"

To solve that I modified DbcLineParser::ParseValTableLine method to drop all new lines within valueline

bool DbcLineParser::ParseValTableLine(Comment_t* comm, const std::string& line, ValTable_t& vtab)
{
  bool ret = false;

  if (line.size() > 0)
  {
    if (line.find("VAL_ ") == 0)
    {
      valueline.clear();
      valueline = line;
    }
    else if (valueline.size() > 0)
    {
      valueline += line;
    }

    // check if the current line is last
    if (valueline.size() > 0 && line.back() == ';')
    {
      std::replace(valueline.begin(), valueline.end(), '\n', ' ');
      std::replace(valueline.begin(), valueline.end(), '\r', ' ');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant