Home > other >  How to a serial port receives more data in the Qt programming
How to a serial port receives more data in the Qt programming

Time:04-08

Everybody is good, how to carry on the multiple RS485 mouth read data in QT,

CodePudding user response:

Were not RS485 serial port more than one serial port

CodePudding user response:

A 485 corresponds to a QSerialPort object it is better to read and write multithreaded way

CodePudding user response:

 images: Screenshot. Png# include" serialThread. H "# include & lt; QDebug> # include "ui_serial. H" # include "serial. H # include" & lt; 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 - & gt; Open (QIODevice: : ReadWrite);//serial port opened for both reading and writing myCom - & gt; SetBaudRate (baud); MyCom - & gt; SetDataBits (databits); MyCom - & gt; SetParity (parity); MyCom - & gt; SetStopBits (stopbits); MyCom - & gt; SetFlowControl (flow); MyCom - & gt; SetTimeout (timeout); }//qDeb

CodePudding user response:

If directly set up more than one thread to create a more QSerialPort object, operate 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 - & gt; Open (QIODevice: : ReadWrite);//serial myCom1 opened for both reading and writing - & gt; SetBaudRate (baud); MyCom1 - & gt; SetDataBits (databits); MyCom1 - & gt; SetParity (parity); MyCom1 - & gt; SetStopBits (stopbits); MyCom1 - & gt; SetFlowControl (flow); MyCom1 - & gt; SetTimeout (timeout); It is ok to}

CodePudding user response:

Or make uncertain a serial port receives more data programming, we hope you give some ideas

CodePudding user response:

The building Lord have done yet?

CodePudding user response:

Object-oriented programming, make multiple objects don't have to do is bai
  • Related