Hi,

I have created a Thread class:
Qt Code:
  1. #ifndef SERIALTHREAD_H
  2. #define SERIALTHREAD_H
  3.  
  4. #include <QThread>
  5. #include <qDebug>
  6. #include "qextserialport.h"
  7. class SerialThread : public QThread
  8. {
  9. Q_OBJECT
  10. public:
  11. SerialThread(QString name) {
  12. portName=name;
  13. }
  14.  
  15. void run();
  16.  
  17.  
  18. private:
  19. QString portName;
  20. QextSerialPort *port;
  21.  
  22. private slots:
  23. void onReadyRead();
  24.  
  25. };
  26.  
  27. #endif // SERIALTHREAD_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "SerialThread.h"
  2.  
  3. void SerialThread::run() {
  4. port = new QextSerialPort(portName, QextSerialPort::EventDriven);
  5. connect(port, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
  6. port->setBaudRate(BAUD9600);
  7. port->setFlowControl(FLOW_OFF);
  8. port->setParity(PAR_NONE);
  9. port->setDataBits(DATA_8);
  10. port->setStopBits(STOP_1);
  11. port->open(QIODevice::ReadWrite);
  12. exec();
  13. }
  14.  
  15. void SerialThread::onReadyRead()
  16. {
  17. QByteArray bytes;
  18. int a = port->bytesAvailable();
  19. bytes.resize(a);
  20. port->read(bytes.data(), bytes.size());
  21. qDebug() << "bytes read:" << bytes.size();
  22. qDebug() << "bytes:" << bytes;
  23. }
To copy to clipboard, switch view to plain text mode 

In the MainWindow I call this Thread:
Qt Code:
  1. MainWindow::MainWindow() {
  2. setupUi(this);
  3. t1 = new SerialThread("/dev/cu.usbserial-ftDIHUS6");
  4. t1->start();
  5. }
To copy to clipboard, switch view to plain text mode 

it seems to be a problem with the signals. When I send:
u I get:
Qt Code:
  1. bytes read: 1
  2. bytes: "u"
  3. bytes read: 0
  4. bytes: ""
  5. bytes read: 0
  6. bytes: ""
  7. bytes read: 0
  8. bytes: ""
  9. bytes read: 0
  10. bytes: ""
  11. bytes read: 0
  12. bytes: ""
  13. bytes read: 0
  14. bytes: ""
  15. bytes read: 0
  16. bytes: ""
  17. bytes read: 0
  18. bytes: ""
  19. bytes read: 0
  20. bytes: ""
  21. bytes read: 0
  22. bytes: ""
To copy to clipboard, switch view to plain text mode 


Without Threads it works so what's the problem?