Results 1 to 3 of 3

Thread: read data from serial port

  1. #1
    Join Date
    Jun 2011
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default read data from serial port

    Hi...

    I want to write and read hex data from serial port..
    I have successfully opened serial port and also able to write hex data on serial port,but when i try to read that data it only reads first seven bits and ignore the last bit..

    E.g.
    Qt Code:
    1. unsigned char a[2] = {0x87,0x0D};
    2. unsigned char b[2] = {0x7F,0x0D};
    3. unsigned char c;
    4.  
    5. write(fd,a or b,sizeof(a or b));
    6. read(fd,&c,sizeof(c));
    To copy to clipboard, switch view to plain text mode 

    In case of read b,it gives perfect answer hex-0x7F dec-127 bin-01111111
    In case of read a,it ignores MSB bit hex-0x87 dec-128 bin-10000000

    So my problem is how to read hex data that gives me perfect output without ignoring MSB bit.

    Waiting for quick reply..

    Thanks..

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: read data from serial port

    Very strange, post your code please
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: read data from serial port

    Have you set the "data bits" of the port??
    Last edited by mcosta; 20th July 2011 at 18:13. Reason: updated contents
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. Replies: 4
    Last Post: 2nd June 2012, 08:04
  2. Replies: 4
    Last Post: 10th July 2010, 18:34
  3. Replies: 1
    Last Post: 16th June 2009, 10:09
  4. data from serial port
    By bhe in forum Newbie
    Replies: 4
    Last Post: 3rd May 2009, 11:19
  5. How to write bytes read from serial port to a QFile
    By shamik in forum Qt Programming
    Replies: 19
    Last Post: 25th June 2007, 15: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.