Results 1 to 4 of 4

Thread: COM port reading with Qextserialport is creating problem:

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: COM port reading with Qextserialport is creating problem:

    What you are reading is what you sent, so what is the problem?

  2. #2
    Join Date
    Mar 2011
    Posts
    15
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: COM port reading with Qextserialport is creating problem:

    Thanks for reply.

    I know what am reading, but the method followed to read, was that correct??? because it cud able to read only one byte, rest all showing junk....

    piece of code which i have posted can be referred and correct me where I went wrong......

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: COM port reading with Qextserialport is creating problem:

    Your code looks how many bytes are available (could be 1, could be 5000), reads that number of bytes, assumes that is some sort of valid string, and appends it to the text edit. Since the data you are sending is not printable characters this will produce rubbish in the text edit. The odd characters you show seem consistent with treating the data you say was sent as ASCII characters, which was squidge's point.

    If you want to display binary data in a readable form you will have to convert it somehow. Hexadecimal is often chosen for this purpose.

    If you need all 6 bytes to be present before you do something with the packet then you need to allow for all 6 bytes to arrive one at at time, buffer them, and do something when you have a full set. You would need to do this to check your checksum.

Similar Threads

  1. Serial Port Reading problem
    By sfabel in forum Qt Programming
    Replies: 12
    Last Post: 18th February 2010, 14:59
  2. Problem in reading port using QextSerialPort
    By cutie.monkey in forum Qt Programming
    Replies: 6
    Last Post: 2nd July 2009, 02:07
  3. Replies: 1
    Last Post: 1st July 2009, 00:36
  4. QextSerialPort with QTimer approch for reading
    By PaceyIV in forum Qt Programming
    Replies: 1
    Last Post: 18th May 2009, 14:33
  5. Replies: 7
    Last Post: 29th August 2008, 10:24

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.