title: qt 5.2 serial port write issues with windows 7
body: <p>We are using FTDI serial port CHIP in our hardware. Now we have working code in Linux and we moved to windows 7. We get some weird problems.</p>
  
  <p>The Problem:
  We can't write data to Serial Port without running other console application which do this:</p>
  
  <pre><code> serial.setPortName("COM3");
          if (serial.open(QIODevice::ReadWrite)) {
              bool success = serial.setBaudRate(QSerialPort::Baud9600) &amp;
              serial.setStopBits(QSerialPort::OneStop) &amp;
              serial.setDataBits(QSerialPort::Data8) &amp;
              serial.setParity(QSerialPort::NoParity) &amp;
              serial.setFlowControl(QSerialPort::NoFlowControl);
              qDebug() &lt;&lt; "Connected to usb device: " &lt;&lt; (success ? "OK" : "FAIL");
  
             while(true) {
                  if(serial.waitForReadyRead(-1)) {
                      QByteArray out = serial.readAll();
                      for(int i=0; i&lt; out.length(); i++) {
                          qDebug() &lt;&lt; (int) out[i];
                      }
                  }
              }
              serial.close();
  </code></pre>
  
  <p>So its just loop with read all. Hardware dosen't send anything, so read is just infinity loop. After closing and running our write program it runs correctly.</p>
  
  <pre><code>char* input;
  input = new char[size+3];
  QByteArray bytearr;
  
  for(int i=0;i&lt;size+2;i++) {
      input[i] = (char) package[i];
      bytearr.append((unsigned char) package[i]);
  }
  
  
  QString serialPortName = "COM3";
  QSerialPort serialPort;
  serialPort.setPortName(serialPortName);
  serialPort.open(QIODevice::ReadWrite);
  serialPort.write(bytearr);
  serialPort.flush();
  serialPort.close();
  </code></pre>
  
  <p>After running read everything works, but without read all, it wont work. What are we doing wrong?
  Thanks.</p>