void QespTest::receiveMsg()
{
char buff[20];
int numBytes;
numBytes = port->bytesAvailable();
if(numBytes > 20)
numBytes = 20;
int i = port->read(buff, numBytes);
if (i != -1)
buff = '\0';
else
buff[0] = '\0';
QString msg=buff ;
received_msg->setText(msg); //QTextEdit
received_msg->ensureCursorVisible();
}
1:上面的程序可以接收 ASCII 字符 但显示不了16进进制,如何把接收到的一组数据,AA FF 34 A4 E5 23 C2 存储到一个数组中
2: char buff[20] 代表的是20个字节吗? 接受缓冲区的大小应该设置为多大
3: 接收数据如何实现同步,能用中断方式实现吗? 还是只能用查询方式。