c++ - Unable to communicate with arduino using QSerialPort if the arduino-ide has not opened the connection before -


I am using the following code to open a serial port to communicate with arduino.

  Const qint32 baud = global :: getInstance () GetSettings (). Value ("Hardware / Bondરેટ", 115200) .toInt (); Const QString portName = global :: getInstance (). GetSettings (). Value ("Hardware / Port", "COM3") ToString (); Port.setPortName (PORTNAME); If (! Port.open (QIODevice :: ReadWrite)) {qFatal ("Unable to open serial port"); Exit (1); } If! (port.SetialPort :: NoParity) ||! port.setStopBits (QSerialPort :: OneStop) ||! port.setDataBits (QSerialPort :: Data8) ||! port.setFlowControl (QSerialPort :: NoFlowControl) | | port .custometrate (baud)) {qFatal ("unable to configure serial port"); Exit (1); } If (Port. Terror (!) = QSerialPort :: NoError) {qFatal ("Something Happened!"); Exit (1); }   

Later, I try to read from the connection using the following code:

  bool light :: waitForReady () {char data [1 ]; Data [0] = -1; If (port.waitForReadyRead (10000)) {const int numRead = port.read (& amp; data [0], 1); If (numRead == 1) {Return Data [0] == (Four) RDY; } Other {qWarning ("Read error,% d bytes read", numRead); }} And {qWarning ("read the time"); return false; } return false; }   

read no works, it happens repeatedly after waiting for 10 seconds, even though when I run my QT code before arduino- Inside the serial monitor and close the serial monitor, it works. My guess is that the Ardunio-id does something for the port which I am missing, but as far as I can tell that Aridono-Id's To open the serial port I would like to I am using the settings.

This is the code that is running on arduino:

  zero setup () {Serial.begin (115200); Serial.write (RDY); }   

The man has a similar problem and he compared the portial settings of the Putty and the Curieleport. They found that the settings are fDtrControl , fOutX and fIutX . I tried to change fDtrControl but it did not have any effect. I do not know about using fOutX and fIutX QT.

Any thoughts that might cause this bug?

Edit: Solution: Port.Set DataTerminal Read (true) was unavailable

Michael Elkan