Hi,
several years ago I wrote a piece of code that reads data from a serial device. Code and application worked fine until today.
When I start up the application, it gets some data but then stops reading.
I have a "reconnect" button that closes and opens the port again. After reconnecting, still there is no data. But now when you move the mouse, data is read. As long as the mouse is moved, data comes in. Stop mouse moving, stops data reading.
Strange.

My system is Ubuntu 14.04,
QT Version is (QT-Creator says this): Based on Qt 5.5.1 (GCC 4.9.1 20140922 (Red Hat 4.9.1-10), 64 bit)

Here is how I read the data, the function is called by a timer every 20ms:
Qt Code:
  1. void serial_service::serial_receive(uint8_t channel)
  2. {
  3. if (channel < NUM_OF_CHANNELS)
  4. {
  5. QByteArray data = service_data[channel].serial.readAll();
  6.  
  7. // we throw away data, if data.count() > SERIAL_BUFFER_SIZE
  8. foreach (const char rec_char, data)
  9. {
  10. // use ringbuffer for code compatibility with the microcontroller-application
  11. ringBufferWrite(&service_data[channel].receive_buffer, (uint8_t) rec_char);
  12. }
  13. }
  14. }
To copy to clipboard, switch view to plain text mode 


Here are my serial settings:
Qt Code:
  1. void open_serial_port(uint8_t channel, QString serial_device_name)
  2. {
  3. service_data[channel].receive_buffer.readIndex = 0; // todo: put ringbuffer into a class
  4. service_data[channel].receive_buffer.writeIndex = 0;
  5.  
  6. if (serial_device_name.isEmpty())
  7. return;
  8.  
  9. if (channel < NUM_OF_CHANNELS)
  10. {
  11. if (service_data[channel].serial.isOpen())
  12. service_data[channel].serial.close();
  13.  
  14. service_data[channel].serial.setPortName(serial_device_name);
  15. service_data[channel].serial.open(QIODevice::ReadWrite);
  16.  
  17. service_data[channel].serial.setBaudRate(QSerialPort::Baud9600);
  18.  
  19. service_data[channel].serial.setDataErrorPolicy(QSerialPort::SkipPolicy);
  20.  
  21. service_data[channel].serial.setFlowControl(QSerialPort::NoFlowControl);
  22.  
  23. service_data[channel].serial.setDataBits(QSerialPort::Data8);
  24. service_data[channel].serial.setParity(QSerialPort::NoParity);
  25.  
  26. service_data[channel].serial.setStopBits(QSerialPort::OneStop);
  27.  
  28. //qDebug() << "serial_service::open_port: " << serial_device_name;
  29. }
  30. }
To copy to clipboard, switch view to plain text mode 

The problem is really urgent. It's a database application that reads lap-times from a stopwatch (arduino inside). We use it for Kart-Racing and next week we have a race...
Thank you for any help!

by the way: Code and schematics are open source and can be found at www.typsiland.de