Packet Loss when using QtSerialPort



  • 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!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.