-1

Code:

QByteArray receive=serialport.readAll();
qDebug()<<"receive="<<receive;

qDebug output:

receive= "\x02\x03*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9D)"

What does the * and ) mean?

phuclv
  • 37,963
  • 15
  • 156
  • 475
Jackoo
  • 117
  • 1
  • 1
  • 12

2 Answers2

0

'*' is \x2a and ')' is \x29.

I guess the qDebug()<<QByteArray prints a byte as a ASCII symbol if it's printable, and prints its value if not.

phuclv
  • 37,963
  • 15
  • 156
  • 475
Jackoo
  • 117
  • 1
  • 1
  • 12
0

From the documentation:

Writes the byte array, t, to the stream and returns a reference to the stream. Normally, QDebug prints the array inside quotes and transforms control or non-US-ASCII characters to their C escape sequences (\xAB). This way, the output is always 7-bit clean and the string can be copied from the output and pasted back into C++ sources, if necessary.

To print non-printable characters without transformation, enable the noquote() functionality. Note that some QDebug backends might not be 8-bit clean.

QDebug Class - QDebug &QDebug::operator<<(const QByteArray &t)

So printable ASCII characters will be printed as characters, other byte values will be escaped

phuclv
  • 37,963
  • 15
  • 156
  • 475