Results 1 to 13 of 13

Thread: Serial Port Reading problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Join Date
    Feb 2008
    Posts
    491
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    12
    Thanked 142 Times in 135 Posts

    Default Re: Serial Port Reading problem

    Maybe this is your problem. From the canReadLine() docs:
    Note that unbuffered devices, which have no way of determining what can be read, always return false.
    I communicate with an unbuffered device and if I were using your onReceive() function it would look something like this:

    Qt Code:
    1. void Motor::onReceive()
    2. {
    3. QMutexLocker locker(&m);
    4. while(port->bytesAvailable()< RX_BUF_SIZE) {} //wait for data
    5.  
    6. char tmp[RX_BUF_SIZE];
    7. qint64 len = port->read(tmp, RX_BUF_SIZE); //use read instead of readline
    8. data.fromRawData(tmp,len);
    9.  
    10. quint8 fault = 0;
    11.  
    12. // do something with the data before
    13. // clearing the buffer
    14.  
    15. data.clear();
    16.  
    17. rxcnt++;
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to norobro for this useful post:

    sfabel (18th February 2010)

Similar Threads

  1. Problem in reading port using QextSerialPort
    By cutie.monkey in forum Qt Programming
    Replies: 6
    Last Post: 2nd July 2009, 02:07
  2. Replies: 1
    Last Post: 1st July 2009, 00:37
  3. Replies: 1
    Last Post: 1st July 2009, 00:36
  4. serial port communiction
    By jagadish in forum Qt Programming
    Replies: 4
    Last Post: 7th July 2007, 12:04
  5. Serial Port
    By b1 in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2007, 02:05

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.