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

Add space between payload and next argument #9

Open
ChrisRBe opened this issue Jan 8, 2021 · 3 comments
Open

Add space between payload and next argument #9

ChrisRBe opened this issue Jan 8, 2021 · 3 comments

Comments

@ChrisRBe
Copy link

ChrisRBe commented Jan 8, 2021

Hi @mbehr1
As per our discussion from yesterday evening: With the current version of the plugin, using DLT_LOG4 to print messages does not add a space between ARGS2 and ARGS3.

@mbehr1
Copy link
Owner

mbehr1 commented Jan 9, 2021

@ChrisRBe thx! I'd like to extend this to "full compliance". So the output should be 1:1 the same. Then we could directly offer to import filters from DLTViewer.

@mbehr1
Copy link
Owner

mbehr1 commented Jan 9, 2021

Some rules from DLT viewer: (see QDltMsg::toStringPayload())
for verbose messages, non control:

  • a space is added in front of all but the first argument.
  • each argument is printed without any additional spaces in front or end. Mainly relying on QString("%1") formatting rules
  • booleans as "true" or "false"
  • unknown types or unknown data (e.g. sint128) as "?"
  • type UInt has some special rules:
    • SCOD_BIN: 8bit: toAscii(data,2,1), 16bit: toAscii(data,2,2)
    • SCOD_HEX: toAscii(data, 0, 1|2|4|8);
    • others: QString("%1) based
  • rawd: toAscii(data, 0)

toAscii:
...

For non-verbose, non-control (and noars == 0):

text += QString("[%1] ").arg(getMessageId());
        data = payload.mid(4,(payload.size()>260)?256:(payload.size()-4));
        if(!data.isEmpty())
        {
            text += toAsciiTable(data,false,false,true,1024,1024,false);
            text += "|";
            text += toAscii(data, false);
  • QDlt::toAsciiTable(bytes, withLineNumber, withBinary, withAscii, blockSize=8, lineSize=16, toHtml=true)

    • after lineSize bytes except for last line: +"\n"
    • withAscii, per line:
      • text += " "
      • per char ch >= ' ' && <= '~' ? ch : '-'
  • QDlt::toAscii(bytes, type, size_bytes=0xff)

    • type 1: (ascii): QString::fromLatin1(...)
    • type 2: (binary):
      • size_bytes==1:
              uint8_t toEncode = bytes.data()[0];
              QString encoded = QString("0b%1").arg(toEncode, 8, 2, QChar('0'));
              return encoded.insert(6, ' '); // insert a space after 0bxxxx
    
    • size_bytes==2:
              uint16_t toEncode = (uint8_t)(bytes.data()[0]) | (((uint8_t)(bytes.data()[1])) << 8);
              QString encoded = QString("0b%1").arg(toEncode, 16, 2, QChar('0'));
              encoded.insert(14, ' '); // insert spaces
              encoded.insert(10, ' ');
              encoded.insert(6, ' ');
              return encoded;
    
  • type 0: (hex):

    • size_bytes 0xff (default): 2 chars per byte: 0-9 a-f, ' ' between two bytes
    • size_bytes 1,2,4,8: QString("0x%1").arg(data, 2|4|8|8,16, QChar('0')) + (for 8) QString("%1").arg(dataLo, 8,16,QChar('0))

@mbehr1
Copy link
Owner

mbehr1 commented Jan 9, 2021

so yes, rawd has a ' ' between two bytes (output as e.g. '01 23 45 67 89 ab cd ef')

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

2 participants