如何在Qt中进行多串口接收数据编程

weixin_38049686 2019-09-19 01:10:50
大家好, 如何在QT中进行多个RS485口读数据,
...全文
530 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
南七技校 2021-04-07
  • 打赏
  • 举报
回复
面向对象编程,搞多个对象不就行了呗
weixin_38115664 2019-09-19
  • 打赏
  • 举报
回复
楼主有搞定没有?
weixin_38088446 2019-09-19
  • 打赏
  • 举报
回复
RS485不就是串口吗多个串口就可以了
weixin_38094055 2019-09-19
  • 打赏
  • 举报
回复
一个485口对应一个QSerialPort对象最好用多线程方式读写
weixin_38104241 2019-09-19
  • 打赏
  • 举报
回复
图片:Screenshot.png#include "serialThread.h"#include <QDebug>#include "ui_serial.h"#include "serial.h"#include <QMessageBox>int sendcount1=1;QString GetHex="";SerialThread::SerialThread(QString portName,BaudRateType baud, DataBitsType databits, ParityType parity, StopBitsType stopbits, FlowType flow, long timeout){    struct PortSettings ttySetting; // s3c2440--{BAUD115200,DATA_8,PAR_NONE,STOP_1,FLOW_OFF,500};    myCom = new Posix_QextSerialPort(portName,ttySetting,QextSerialBase::Polling);    myCom->open(QIODevice::ReadWrite);    //以可读写方式打开串口    myCom->setBaudRate(baud);    myCom->setDataBits(databits);    myCom->setParity(parity);    myCom->setStopBits(stopbits);    myCom->setFlowControl(flow);    myCom->setTimeout(timeout);}    //qDeb
weixin_38109579 2019-09-19
  • 打赏
  • 举报
回复
如果直接建立多一个线程来创建多一个QSerialPort对象,进行操作eg:SerialThread::SerialThread1(QString portName,BaudRateType baud, DataBitsType databits, ParityType parity, StopBitsType stopbits, FlowType flow, long timeout){  struct PortSettings ttySetting; // s3c2440--{BAUD115200,DATA_8,PAR_NONE,STOP_1,FLOW_OFF,500};    myCom1 = new Posix_QextSerialPort(portName,ttySetting,QextSerialBase::Polling);    myCom1->open(QIODevice::ReadWrite);    //以可读写方式打开串口    myCom1->setBaudRate(baud);    myCom1->setDataBits(databits);    myCom1->setParity(parity);    myCom1->setStopBits(stopbits);    myCom1->setFlowControl(flow);    myCom1->setTimeout(timeout);} 就可以了吧
weixin_38114375 2019-09-19
  • 打赏
  • 举报
回复
还是搞不定多串口接收数据编程,希望大家给点思路

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧