PDA

View Full Version : Serial data interrupt when minimizing a display window.



nagabathula
13th June 2011, 08:15
Hello every one,
i have a small problem. I am acquiring data from a serial port every 200 milli seconds and saving it into a database. I show this saved data in another display window. Every thing runs fine but when i minimize or double click on the top QDialogBox bar to minimize or maximize the dialogbox i get a interrupt in the data acquiring i miss acquiring some data from the serial port when i try to minimize or maximize the QDialogBox. I am retrieving the data in the main program and i display it in another QDialogBox i get some missing data when i minimize or maximize this QDialogBox in which i display the data in QTableView format. I checked the incoming data from the serial port with QDebug i see some data missing when i do the minimize or maximize operation on the window. What could be the problem..?? Pls help me out. !!

Thank you

nagabathula
13th June 2011, 11:16
hello friends is there any way serial data acquiring can get interrupted when i minimize or maximize a dialog window.. I am sure it is happening only when i try to min or max a dialog window. I see in qDebug some missing data when i do the min max operations.
this is what i have put to maximize and minimize the windows. ..

: QMainWindow(parent,Qt::WindowMinMaxButtonsHint)
: QDialog(parent,Qt::WindowMinMaxButtonsHint)
some one pls help me, what might the problem be.
thank you

squidge
13th June 2011, 13:04
What is your serial buffer size?

How are you collecting the data?

nagabathula
13th June 2011, 13:33
Hello thank you for the reply.
The serial buffer size is char buff[16384]; i am acquiring data when i click the acquire button i call this function every 200 mili sec's. I save the data in the QByteArray to a data base and then display it in another QDialogbox. The acquiring of the serial data happens in QMainWindow.cpp . The data acquiring is continuous only when i double click or try to minimize the QDialogbox in which i display the data from the db, there is some data missing. I checked that with qDebug().


if(port->bytesAvailable())
{
numBytes = port->bytesAvailable();
if(numBytes > sizeof(buff))
numBytes = sizeof(buff);
ist = port->read(buff,numBytes);
newdata.append(QByteArray::fromRawData(buff,numByt es));
qDebug()<<newdata;
// And some processing before i save the data in the db
}

thank you

squidge
13th June 2011, 22:18
char buff[16384]; is your buffer, not the buffer of the serial port. What is the buffer of the serial port?

schnitzel
14th June 2011, 01:25
You are using QextSerialPort - right?
Have you considered using eventdriven mode because it looks like you are more or less polling. Using events could work a lot better for you.
Take a look at QextSeriaPort event example.

nagabathula
14th June 2011, 05:00
Hello thank you for the time. :)

i din understand what you meant by serial port buffer.? and eventdriven mode does not work on my system it tells


'EventDriven' : is not a member of 'QextSerialPort'
This is what i am doing right now to set the portsettings


port = new QextSerialPort(port_name);
port->setBaudRate(BAUD115200); //(BAUD115200);
port->setFlowControl(FLOW_OFF); // (FLOW_OFF);
port->setParity(PAR_NONE); //(PAR_NONE);
port->setDataBits(DATA_8); //(DATA_8);
port->setStopBits(STOP_1);

i changed it to this but it gives a error that eventDriven is not a member of QextSerialPort i have a 2 year old version of qextserialport i think i need to update the patch.

port = new QextSerialPort( port_name, QextSerialPort::EventDriven);
if (port->open(QIODevice::ReadWrite | QIODevice::Unbuffered) == true)
{
port = new QextSerialPort(port_name);
port->setBaudRate(BAUD115200); //(BAUD115200);
port->setFlowControl(FLOW_OFF); // (FLOW_OFF);
port->setParity(PAR_NONE); //(PAR_NONE);
port->setDataBits(DATA_8); //(DATA_8);
port->setStopBits(STOP_1);
}


thank you.

squidge
14th June 2011, 07:37
Why are you passing Unbuffered to QextSerialPort?

schnitzel
14th June 2011, 09:03
Hello thank you for the time. :)



i changed it to this but it gives a error that eventDriven is not a member of QextSerialPort i have a 2 year old version of qextserialport i think i need to update the patch.



not much point in fighting obsolete code... please update to the latest and take a look at the event driven example.

good luck