Results 1 to 10 of 10

Thread: why bytesAvailable() returns '0' when there are answer data from serial port monitor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question why bytesAvailable() returns '0' when there are answer data from serial port monitor

    hello, everyone. i use qextserialport in my application to realize serial communication.
    i can write data using writeData(const char * data, qint64 maxSize). But the function bytesAvailable () returns '0' while reading, so i can't get any data through readData(char * data, qint64 maxSize). But i can see the answer data from serial port monitor. WHY??
    my code:
    Qt Code:
    1. if(RS232->open(QIODevice::ReadWrite))
    2. {
    3. RS232->writeData(Data,13);
    4. //usleep(500);
    5.  
    6. int i= RS232->QIODevice::bytesAvailable();
    7. if(i > 0)
    8. {
    9. char *pStr=NULL;
    10. RS232->readData(pStr,25);
    11. }
    12. RS232->close();
    13. }
    To copy to clipboard, switch view to plain text mode 
    adding the "usleep(500);" has no use.

    thanks very much for any advice!
    Last edited by to_guliang; 3rd June 2008 at 08:28.

Similar Threads

  1. First attempt to display serial port data on GUI
    By ShaChris23 in forum Newbie
    Replies: 12
    Last Post: 4th May 2007, 09:14
  2. Replies: 16
    Last Post: 7th March 2006, 15:57

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.