Results 1 to 9 of 9

Thread: Serial data interrupt when minimizing a display window.

  1. #1
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Serial data interrupt when minimizing a display window.

    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

  2. #2
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Serial data interrupt when minimizing a display window.

    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
    Last edited by nagabathula; 13th June 2011 at 11:31.

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Serial data interrupt when minimizing a display window.

    What is your serial buffer size?

    How are you collecting the data?

  4. #4
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Serial data interrupt when minimizing a display window.

    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().

    Qt Code:
    1. if(port->bytesAvailable())
    2. {
    3. numBytes = port->bytesAvailable();
    4. if(numBytes > sizeof(buff))
    5. numBytes = sizeof(buff);
    6. ist = port->read(buff,numBytes);
    7. newdata.append(QByteArray::fromRawData(buff,numBytes));
    8. qDebug()<<newdata;
    9. // And some processing before i save the data in the db
    10. }
    To copy to clipboard, switch view to plain text mode 

    thank you

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Serial data interrupt when minimizing a display window.

    char buff[16384]; is your buffer, not the buffer of the serial port. What is the buffer of the serial port?

  6. #6
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Serial data interrupt when minimizing a display window.

    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.

  7. #7
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Serial data interrupt when minimizing a display window.

    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
    Qt Code:
    1. port = new QextSerialPort(port_name);
    2. port->setBaudRate(BAUD115200); //(BAUD115200);
    3. port->setFlowControl(FLOW_OFF); // (FLOW_OFF);
    4. port->setParity(PAR_NONE); //(PAR_NONE);
    5. port->setDataBits(DATA_8); //(DATA_8);
    6. port->setStopBits(STOP_1);
    To copy to clipboard, switch view to plain text mode 

    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.
    Qt Code:
    1. port = new QextSerialPort( port_name, QextSerialPort::EventDriven);
    2. if (port->open(QIODevice::ReadWrite | QIODevice::Unbuffered) == true)
    3. {
    4. port = new QextSerialPort(port_name);
    5. port->setBaudRate(BAUD115200); //(BAUD115200);
    6. port->setFlowControl(FLOW_OFF); // (FLOW_OFF);
    7. port->setParity(PAR_NONE); //(PAR_NONE);
    8. port->setDataBits(DATA_8); //(DATA_8);
    9. port->setStopBits(STOP_1);
    10. }
    To copy to clipboard, switch view to plain text mode 

    thank you.

  8. #8
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Serial data interrupt when minimizing a display window.

    Why are you passing Unbuffered to QextSerialPort?

  9. #9
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Serial data interrupt when minimizing a display window.

    Quote Originally Posted by nagabathula View Post
    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

Similar Threads

  1. Replies: 2
    Last Post: 7th June 2011, 08:24
  2. can't set serial port data bits
    By yyiu002 in forum Qt Programming
    Replies: 6
    Last Post: 23rd June 2010, 22:28
  3. data from serial port
    By bhe in forum Newbie
    Replies: 4
    Last Post: 3rd May 2009, 10:19
  4. minimizing main window
    By eric in forum Qt Programming
    Replies: 4
    Last Post: 28th November 2007, 16:54
  5. First attempt to display serial port data on GUI
    By ShaChris23 in forum Newbie
    Replies: 12
    Last Post: 4th May 2007, 09:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.