Results 1 to 3 of 3

Thread: Qserial Read Problem

  1. #1

    Default Qserial Read Problem

    hiii,

    I tried some Stuff on QSerialPort.
    Having some protocol which is Tx and Rx the bytes.
    i Monitored the serial port through Sniffer data will be sent through UI successfully but receiving acknowledge cant received in UI but the controller sent Ack on Port ,sniffer will detect it, but my UI application cant received the data.

    unsigned char Buffer[64];

    //TX
    SerialPort->write((const char *)Buffer,1);

    //RX
    SerialPort->read(char *)Buffer,1);

    i put some delay between TX n RX but still QT Ui doesn't get response.

  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: Qserial Read Problem

    Use the signal/slot's approach. E.g. the readyRead signal to know when data is available to read.

    In your current case all wrong.

    UPD: At least you should use waitForX() methods (in case you do not use the signal/slot), e.g.:

    Qt Code:
    1. //TX
    2. SerialPort->write((const char *)Buffer,1);
    3. SerialPort->waitForBytesWritten(5000);
    4.  
    5. //RX
    6. SerialPort->waitForReadyRead(5000);
    7. SerialPort->read(char *)Buffer,1);
    To copy to clipboard, switch view to plain text mode 

    But I don't recommend use the waitForX() methods because they still have some bugs.

  3. #3
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qserial Read Problem

    But I don't recommend use the waitForX() methods because they still have some bugs.
    I have used the library for asynchronous communication in many production environments and never received ONE complaint. But as kuzulis says, there is some bug in synchronous communication. Try async methods, it is anyway a better design. It will work like a charm.

    And Thank you kuzulis for this lovely library. Hope the sync methods can be resolved soon.

Similar Threads

  1. Qserial Port for windows
    By vishme7 in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2013, 12:59
  2. problem to read excel file
    By keyurparekh in forum Qt Programming
    Replies: 4
    Last Post: 27th June 2011, 13:25
  3. QSerial problem:receives random data
    By omegaKnot in forum Qt Programming
    Replies: 5
    Last Post: 27th May 2011, 09:32
  4. XML read problem
    By Archa4 in forum Newbie
    Replies: 2
    Last Post: 7th February 2011, 11:12

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.