Results 1 to 13 of 13

Thread: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through them

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through th

    Check returns value from

    Qt Code:
    1. setDataBits(QSerialPort::Data8)
    To copy to clipboard, switch view to plain text mode 

    at successful should be "true".

  2. #2
    Join Date
    Mar 2012
    Posts
    14
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through th

    Is true.

    Thank you kuzulis.

  3. #3
    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: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through th

    Is true.
    It is strange. Give a code where you configure and open port.

  4. #4
    Join Date
    Mar 2012
    Posts
    14
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through th

    Qt Code:
    1. SettingsDialog::Settings s = settingsDialog->settings();
    2. serial->setPortName(s.name);
    3. serial->open(QIODevice::ReadWrite);
    4. if (!serial->setBaudRate(s.baudRate)
    5. && serial->setDataBits(s.dataBits)
    6. && serial->setParity(s.parity)
    7. && serial->setStopBits(s.stopBits)
    8. && serial->setFlowControl(s.flowControl))
    9. return; // Failed
    To copy to clipboard, switch view to plain text mode 

  5. #5
    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: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through th

    Please replace part of code to:

    Qt Code:
    1. bool success = serial->open(QIODevice::ReadWrite)
    2. && serial->setBaudRate(s.baudRate)
    3. && serial->setDataBits(s.dataBits)
    4. && serial->setParity(s.parity)
    5. && serial->setStopBits(s.stopBits)
    6. && serial->setFlowControl(s.flowControl);
    7.  
    8. if (!success ) {
    9. return; // Failed
    10. }
    To copy to clipboard, switch view to plain text mode 

    and check now.

  6. #6
    Join Date
    Mar 2012
    Posts
    14
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through th

    Still true.

    Thank you kuzulis.

  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: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through th

    In this case, check the correctness of installation of databits in DCB in debugger after setDataBits() call.

  8. #8
    Join Date
    Mar 2012
    Posts
    14
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QserialPort and QTcpSocket, led to a difference in the QByteArray sent through th

    My fault! Everything is working now. May be a full rebuild/make was required to effectively apply the setDataBits.

    Sorry.

Similar Threads

  1. Qt5 cmake and QSerialPort
    By Chris.Burner in forum Newbie
    Replies: 1
    Last Post: 21st April 2013, 16:13
  2. Replies: 1
    Last Post: 24th March 2013, 22:37
  3. Replies: 6
    Last Post: 23rd June 2010, 14:48
  4. QTcpSocket QDataStream QByteArray
    By Grimlock in forum Newbie
    Replies: 1
    Last Post: 14th December 2009, 22:47
  5. Difference between normal socket and QTcpSocket
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 16th June 2007, 04:38

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.