Results 1 to 3 of 3

Thread: QSerialPort device not open display

  1. #1
    Join Date
    Sep 2013
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSerialPort device not open display

    Hello,

    I use QSerialPort and I don't manage to display the information "QIODevice::write (QSerialPort): device not open" when I try to send some data if the serial port is not yet open. I can see the message in the output application of Qt Creator, but the SIGNAL(errorOccurred(QSerialPort::SerialPortError) is not emit; I guess it's because the serial port is not yet open?

    I've got this source code (everything else is working well when I open the serial port):


    Qt Code:
    1. connect(uart, SIGNAL(errorOccurred(QSerialPort::SerialPortError)), this, SLOT(handleError(QSerialPort::SerialPortError)));
    2.  
    3. ...
    4.  
    5. void UART::handleError(QSerialPort::SerialPortError error)
    6. {
    7. if (error == QSerialPort::ResourceError)
    8. {
    9. emit errorDetected(uart->errorString()); //emit error string to the GUI
    10. if(uart->isOpen())
    11. {
    12. uart->close();
    13. }
    14.  
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    Do you have a clue?
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSerialPort device not open display

    Writing to an unopened device is likely not considered an internal error that needs to be notified but an error of usage.

    But just to be sure check the result of the connect() call.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2013
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSerialPort device not open display

    Yes I wanted to display this error of usage as a "reminder" for me..

    I checked the result of the connect() call and it's ok

Similar Threads

  1. Replies: 0
    Last Post: 5th July 2018, 11:06
  2. Replies: 2
    Last Post: 3rd July 2018, 11:43
  3. Replies: 1
    Last Post: 29th June 2018, 11:24
  4. QSerialPort open flips RTS and DTR despite I don't want it
    By LaminateFloor in forum Qt Programming
    Replies: 10
    Last Post: 17th April 2016, 20:39
  5. Replies: 5
    Last Post: 17th April 2015, 08:09

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.