Results 1 to 14 of 14

Thread: read and write in serial port

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2016
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    31

    Default Re: read and write in serial port

    Quote Originally Posted by anda_skoa View Post
    If I understand the information on serial break correctly, you are getting a sort of data timeout on the line.
    This is a hardware thing: http://ltxfaq.custhelp.com/app/answe...erial-break%3F

    Maybe the device you are connected to can't keep up or is using different settings?

    Cheers,
    _
    I read data with Hercules_3-2-6 Application (rs232 terminal software) http://www.qtcentre.org/threads/6510...nother-program

  2. #2
    Join Date
    Jan 2016
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    31

    Default Re: read and write in serial port

    My program worked today, and I have not any error.
    But I do not any change to program.

    When I run program,
    program connects to port successfully, but I receive just one data (space).

    But when I close this program and open Hercules_3-2-6 Application (rs232 terminal software), that application read data,
    and after close Hercules_3-2-6 application and open terminal example again, this program works and reads data until restarting computer.

    I repeat this process many times.

    But my project does not receive data after restarting system until port opens one time by Hercules_3-2-6 Application.

    Meanwhile I have virtual USB COM port and my hardware connected to computer with USB.
    Last edited by neda; 7th February 2016 at 07:19.

  3. #3
    Join Date
    Jan 2016
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    31

    Default Re: read and write in serial port

    I wrote a .net program.It worked very well likes to Hercules_3-2-6 Application and qt program worked after opening the program.
    Is it bug of Qt 5.5.1 ?

  4. #4
    Join Date
    Jan 2016
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    31

    Default Re: read and write in serial port

    I added this line for handle error port.

    voidMySerialPort::handleError(QSerialPort::SerialP ortErrorerror)
    {
    qDebug()<<"Error:"<<error;//I added this line
    if(error==QSerialPort::ResourceError)
    {
    showStatusMessage(serial->errorString());
    closeSerialPort();
    }
    }

    Result of run program:

    Error: 0
    "Connectedd"
    Error: 6
    "\x00"


    Just sometimes I have error 6.
    How do I fix break condition error?

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

    Default Re: read and write in serial port

    > How do I fix break condition error?

    Nohow. It is HW/driver issue.

    UPD: Future Qt 5.6.0 won't be process the Parity/Frame and BreakCondition errors anymore. So, you can try QtSeriaslPort from 5.6.0 branch.

  6. The following user says thank you to kuzulis for this useful post:

    neda (10th February 2016)

  7. #6
    Join Date
    Jan 2016
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    31

    Default Re: read and write in serial port

    Quote Originally Posted by kuzulis View Post
    > How do I fix break condition error?

    Nohow. It is HW/driver issue.

    UPD: Future Qt 5.6.0 won't be process the Parity/Frame and BreakCondition errors anymore. So, you can try QtSeriaslPort from 5.6.0 branch.
    Of course,My program is problem because other programs (C# .net , Hercules) work very well.
    My problem is bug of QSerialPort?
    Last edited by neda; 10th February 2016 at 10:00.

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

    Default Re: read and write in serial port

    > Of course,My program is problem because other programs (C# .net , Hercules) work very well.

    So what? Maybe they (those programs) do not trace the EV_ERR event flag. This flag coming from the device driver, and QtSerialPort < 5.6 handles this error when it is occurred.

    > My problem is bug of QSerialPort?

    You problem is bug of HW/driver of device.

  9. The following user says thank you to kuzulis for this useful post:

    neda (10th February 2016)

  10. #8
    Join Date
    Jan 2016
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    31

    Default Re: read and write in serial port

    Thanks you very much.
    Your answer was a big help for me.

    serial->setDataTerminalReady(false);

Similar Threads

  1. Serial read misses to read data from the serial port
    By mania in forum Qt for Embedded and Mobile
    Replies: 11
    Last Post: 18th August 2014, 09:49
  2. qext-serial-port write problem.
    By rex in forum Qt Programming
    Replies: 11
    Last Post: 9th December 2013, 08:18
  3. Replies: 4
    Last Post: 10th July 2010, 18:34
  4. Replies: 1
    Last Post: 16th June 2009, 10:09
  5. How to write bytes read from serial port to a QFile
    By shamik in forum Qt Programming
    Replies: 19
    Last Post: 25th June 2007, 15:12

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.