Results 1 to 8 of 8

Thread: QExtSerialport reads junk char's through UART first time after booting PC

  1. #1
    Join Date
    Sep 2009
    Posts
    54
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QExtSerialport reads junk char's through UART first time after booting PC

    Hi all,

    I'm having trouble in reading data through serialport using QExtSerialPort. Now i'm working for microcontroller - PC communication through serial port.

    The case is, if i booted my PC (WinXp) when i tried to read data through serial port using QExtSerialPort it reads junk char's repeatedly, but if i tried to read the same in Hyperterminal (or) SIOW software it reads properly.

    After using Hyperterminal or SIOW to read data one time, my program (using same QExtSerialPort code)also reads the data properly (same program).

    settings are all same on both ends.

    Qt Code:
    1. bool ACR_UARTCOMM::serialPortInit(QString portname)
    2. {
    3. if(Pc_ACR_Commn.isOpen())
    4. {
    5. return true;
    6. }
    7. else
    8. {
    9. Pc_ACR_Commn.setPortName(portname);
    10. Pc_ACR_Commn.setBaudRate(BAUD9600);
    11. Pc_ACR_Commn.setDataBits(DATA_8);
    12. Pc_ACR_Commn.setParity(PAR_NONE);
    13. Pc_ACR_Commn.setStopBits(STOP_1);
    14. Pc_ACR_Commn.setFlowControl(FLOW_OFF);
    15.  
    16. if(Pc_ACR_Commn.open(QIODevice::ReadWrite))
    17. {
    18. return true;
    19. }
    20. else
    21. {
    22. QMessageBox::critical(0, "Error", "Error while opening port " + portname);
    23. return false;
    24. }
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

    Friends help me sort out this problem where im doing wrong.

  2. #2
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QExtSerialport reads junk char's through UART first time after booting PC


  3. #3
    Join Date
    Sep 2009
    Posts
    54
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QExtSerialport reads junk char's through UART first time after booting PC

    Sorry i forgot to mention.. I have tried QSerialPort (QSerialDevice) also... result is same...

    Also i tried to debug the data transaction between both ends using serialport monitor software, that software also reads same junk char's if i tried to transmit or receive data through Qt.

    but the same software reads correct data if i tried to send/receive data through hyperterminal/SIOW software.

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QExtSerialport reads junk char's through UART first time after booting PC

    Most likely some control signals (CTS,RTS,DTR,DSR) have incorrect state.

  5. #5
    Join Date
    Sep 2009
    Posts
    54
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QExtSerialport reads junk char's through UART first time after booting PC

    yes .. checked that ... i have disabled both DTR & RTS

    Still same problem..

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QExtSerialport reads junk char's through UART first time after booting PC

    After opening the port (line 18) read potential garbage. You do not know what are the parameters of the port (speed, parity etc.) before programming. If the second side send something on your side will be garbage. The port is still active and supported by the operating system and driver.
    I think that Hyperterminal do this for You. This is normal.

  7. #7
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QExtSerialport reads junk char's through UART first time after booting PC

    Sorry i forgot to mention.. I have tried QSerialPort (QSerialDevice) also... result is same...
    You are wrong using QtSerialPort! First, need open device, and second - configure it!
    Please read documentation.

  8. #8
    Join Date
    Oct 2014
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Red face Re: QExtSerialport reads junk char's through UART first time after booting PC

    Thanks Very Much
    I was configuring it first then opening it.
    But it was Vice Verca.

Similar Threads

  1. Replies: 2
    Last Post: 3rd July 2012, 16:42
  2. Replies: 5
    Last Post: 11th August 2011, 14:16
  3. Replies: 3
    Last Post: 19th February 2009, 19:01
  4. QGraphicsItem leaves junk on screen
    By Gopala Krishna in forum Qt Programming
    Replies: 18
    Last Post: 12th December 2007, 06:23
  5. QSqlQuery always return junk value while for varchar oracle.
    By ranjit2709 in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2007, 05:19

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.