折腾了两天,我还是太菜了
声明:单片机向串口打印使用"printf("%c",send[i]);",打印后上位机这边就可以按十六进制接收了。
代码
void DealData
::dataToSeries(QByteArray bytes
)
{
qDebug()<<bytes
;
QByteArray macAddress
= bytes
.toHex(':');
QString str
[bytes
.length()];
int j
=0;
for(int i
=0; i
<bytes
.length(); i
++)
{
for(;j
<macAddress
.length();j
++)
{
if(macAddress
[j
] != ':')
{
str
[i
] += macAddress
[j
];
}
else
{
j
++;
break;
}
}
}
for(int l
=0;l
<bytes
.length();l
++)
{
qDebug()<<str
[l
];
}
}
如果觉得有用帮我点个赞,可好?