来自csdn:http://bbs.csdn.net/topics/360242425
这个好办,你用的是qextserialbase这个第三方库么,要是的话我写过这样的程序
向串口发16进制:比如说你要向串口发0xaa,你可以这样写:
QString str;
str.append(QChar(0XAA);
write(str.toAssic());
接收就不用说了吧:收到的看16进制直接就是了,要是你想取出来 的话可以这样:
int data;
QByteArray temp;
temp=readAll();
比如你要取出第一个16进制你可以样:
data=temp.at(0)&0x000000ff;
这样data就是你想要的16进制了
虽然我这方法可能不是最好的,不过确实能用,我就是这么用的希望对你有用。
我QQ:445159738欢迎交流。
来自:http://blog.const.net.cn/a/10047.htm
unsigned char buf[1024];
memset(buf,0,sizeof(buf));
int len=0;
buf[len++] = 0x02;
buf[len++] = 0xe3;
buf[len++] = 0xa2;
buf[len++] = 0xf5;
buf[len++] = 0xd6;->write(buf, len);
port
文章的脚注信息由WordPress的wp-posturl插件自动生成
微信扫一扫,打赏作者吧~![[整理][转载]win下网卡抓包发包库Npcap使用](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2023/08/demo_1-1024x711.jpg&w=280&h=210&zc=1)
![[转载]基础数据char,int,double,string是线程安全的吗?](http://www.jyguagua.com/wp-content/themes/begin/img/random/17.jpg)
![[整理]how to run flask with pyqt5](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2021/03/pyqt_flask.png&w=280&h=210&zc=1)
![[整理]用c++编写的RDTSC性能计时器](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2020/12/rdtsc-assembly-example.jpg&w=280&h=210&zc=1)