Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Packet Loss when using QtSerialPort

    General and Desktop
    1
    1
    510
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      SolarSunrise last edited by

      I'm making a program that reads a stream of data coming from a serial RN42 bluetooth connection at 250 samples per second (115200 baud) and saving it to a file. When running the code, I've noticed that some of the data were being dropped not and read, thus getting out of sync.

      @SerialMonitor::SerialMonitor(QObject *parent) :
      QObject(parent)
      {

      // Initialization here
      
       DAQ = new QSerialPort(this);
       DAQ->setPortName("/dev/tty.BIOEXG-SPP");
       DAQ->setBaudRate(QSerialPort::Baud115200);
       DAQ->setDataBits(QSerialPort::Data8);
       DAQ->setParity(QSerialPort::NoParity);
       DAQ->setStopBits(QSerialPort::OneStop);
       DAQ->setFlowControl(QSerialPort::NoFlowControl);
      
       if (DAQ->open(QIODevice::ReadOnly)) printf("Success!\n");
       else printf("FAILED...\n");
      
       connect(DAQ, SIGNAL(readyRead()), this, SLOT(WriteToText()));
      

      }

      void SerialMonitor::WriteToText()
      {
      while (DAQ->canReadLine()) {
      QString IncomingData = DAQ->readLine();

          // More processing here
      
      }
      

      }
      }@

      Is there a problem with my code? If not, is there a way around this problem? This is an EEG device thus every single data point is crucial.

      Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • First post
        Last post