Skip to content

Incorrect handling multiline VAL_ #35

Description

@WojciechJasko-BB

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', ' ');

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions