Results 1 to 5 of 5

Thread: qextserialport error

  1. #1
    Join Date
    Jul 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default qextserialport error

    I am trying to read a serial port using the above class library, and am trying to use the if(port.isOpen()) to check if the port is already opened but the function returns error.

    Again I want read data from that serial port now without checking the port is open can somebody show me how to convert the bytedata into string so that i can display it on the text label?

  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: qextserialport error

    Why did you choose QextSerialPort? Try a different library QtSerialPort.

    i can display it on the text label?
    Of course it is possible, provided that you pass the text
    Qt Code:
    1. ...
    2. QByteArray data = port->readAll();
    3. ...
    4. QString s(data);
    5. ...
    6. label->setText(s);
    7. ...
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qextserialport error

    thanx, but i have realized if i use Qstring directly it reads the data and automatically converts. but there is only one problem that am encountering, i have a device that continually send a value 200 to my com port and my programme waits for readyread so it will pick that value and display it but the values appear as 200200,200,00,0,2,02 so how can i wait for a three digit number that is being sent continually and display the correct value?

  4. #4
    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: qextserialport error

    Append each received chunk of characters onto a persistent QByteArray buffer. When the buffer has 3 or more characters in it remove the front three to display, repeat until less than three characters in buffer.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  5. #5
    Join Date
    Jul 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qextserialport error

    Quote Originally Posted by ChrisW67 View Post
    Append each received chunk of characters onto a persistent QByteArray buffer. When the buffer has 3 or more characters in it remove the front three to display, repeat until less than three characters in buffer.
    good quote. But the problem is solved. i used a logic to check the data and hold not to display any starting with 0 and should not exceed three.

Similar Threads

  1. qextserialport help
    By miilun in forum Qt Programming
    Replies: 2
    Last Post: 13th July 2012, 09:42
  2. Using qextserialport
    By udaybhaskar in forum Newbie
    Replies: 1
    Last Post: 6th April 2011, 14:46
  3. Qextserialport
    By Max123 in forum Qt Programming
    Replies: 3
    Last Post: 27th March 2010, 22:53
  4. QextSerialPort reading error: wrong values
    By Lawand in forum Qt Programming
    Replies: 9
    Last Post: 6th May 2009, 19:29
  5. QextSerialPort
    By Diph in forum Newbie
    Replies: 5
    Last Post: 13th September 2008, 19:18

Tags for this Thread

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.