Qt 调试错误:“解析目标库列表时:格式不正确(无效令牌)”
我正在使用 QtCreator 调试在 Qt/C++ 中开发的应用程序。我的应用程序使用 QextSerialPort 从串行端口读取数据,其中串行端口连接到 Rhino Mark IV 控制器。
int bytesRead;
char buffer[BUFFER_SIZE];
if (_serialPort->bytesAvailable() > 0
&& (bytesRead = _serialPort->read(buffer, BUFFER_SIZE)) > 0)
{
_comBuffer.append(buffer, bytesRead);
buffer[bytesRead+1] = 0; // for debugging purposes
qDebug(buffer); // for debugging purposes
}
我在这方面遇到了麻烦,因为我尝试读取一些 ASCII 数据,但是我进入缓冲区的是一些奇怪的字符。例如,数字零 ('0') 的 ASCII 代码被调试器显示的另一个代码替换,并由 qDebug
打印为 '°'。
此外,我在“应用程序输出”选项卡中收到以下消息:解析目标库列表时:格式不正确(无效令牌)
。
我想知道为什么我没有通过 QextSerialPort 获得适当的 ASCII 代码。是QextSerialPort的问题还是Rhino Mark IV控制器的问题? 我在两台显示器上通过串口查看流量,并且ASCII字符在显示器上正确显示。因此,我得出的结论是,这不是控制器或通信通道的问题。
消息解析目标库列表时:格式不正确(无效令牌)
是什么意思以及为什么会导致?
I am debugging an application developed in Qt/C++ using QtCreator. My application reads from the serial port using QextSerialPort, where the serial port is connected to a Rhino Mark IV controller.
int bytesRead;
char buffer[BUFFER_SIZE];
if (_serialPort->bytesAvailable() > 0
&& (bytesRead = _serialPort->read(buffer, BUFFER_SIZE)) > 0)
{
_comBuffer.append(buffer, bytesRead);
buffer[bytesRead+1] = 0; // for debugging purposes
qDebug(buffer); // for debugging purposes
}
I am having trouble with this, because I try to read some ASCII data, but what I get into the buffer are some strange characters. For example, the ASCII code for number zero ('0') is replaced by another code that is shown by the debugger and printed by qDebug
as '°'.
In addition, I get following message in the Application Output tab: while parsing target library list: not well-formed (invalid token)
.
I wonder why I do not get the appropriate ASCII code with QextSerialPort. Is it a problem of QextSerialPort or of the Rhino Mark IV controller? I am viewing the traffic through the serial port on two monitors, and the ASCII characters are displayed correctly on the monitors. Thus, I have concluded that it is not a problema of the controller or the communication channel.
What does the message while parsing target library list: not well-formed (invalid token)
mean and why is it caused?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在应用程序中正确配置了串行端口(即波特率、停止位等)?
另外,当缓冲区以零终止时,不应将 1 添加到
bytesRead
中,因为这会导致字符串末尾出现单个不需要的字节。该错误消息由 gdb,而不是 Qt。这可能与使用具有非 latin1 编码名称的文件/文件夹有关。
Did you configure the serial port correctly in your application (i.e. baudrate, stop bits, etc.)?
Also, you should not add 1 to
bytesRead
when zero terminating the buffer as that allows a single unwanted byte at the end of the string.That error message is generated by gdb, not Qt. It may be related to using files/folders with non-latin1 encoded names.