Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QSerialport
Forum Updated to NodeBB v4.3 + New Features

Problem with QSerialport

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 280 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    marpan70
    wrote on last edited by
    #1

    I have build a application with Qt and use QSerialport for communication with an arduino device. When I write a command to the Arduino I get a response back and try to read the data with a Signal-SLOT (readyread()) and in this slot I execute a serial->readall() call. Sometimes I get the whole message of 32 bytes but sometimes I get a part of the message and in the next message I have the other part of the message. That's ok, but.... I get the message again and sometimes 3 times.
    example message complete in one call:
    "Writefunction not implemented yet\r\n"
    example message complete in two calls:
    *"Writefunction not implement"
    "ed yet\r\nWritefunction not implemented yet\r\n" *

    Can someone help me what is happening here? When I look with a terminal program I see the message only once.

    aha_1980A 1 Reply Last reply
    0
    • M marpan70

      I have build a application with Qt and use QSerialport for communication with an arduino device. When I write a command to the Arduino I get a response back and try to read the data with a Signal-SLOT (readyread()) and in this slot I execute a serial->readall() call. Sometimes I get the whole message of 32 bytes but sometimes I get a part of the message and in the next message I have the other part of the message. That's ok, but.... I get the message again and sometimes 3 times.
      example message complete in one call:
      "Writefunction not implemented yet\r\n"
      example message complete in two calls:
      *"Writefunction not implement"
      "ed yet\r\nWritefunction not implemented yet\r\n" *

      Can someone help me what is happening here? When I look with a terminal program I see the message only once.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @marpan70

      Sometimes I get the whole message of 32 bytes but sometimes I get a part of the message and in the next message I have the other part of the message.

      Well, thats how serial ports work. You need to define a protocol to come around this. Most often, line endings are used to indicate the end of a message.

      That's ok, but.... I get the message again and sometimes 3 times.
      example message complete in one call:
      "Writefunction not implemented yet\r\n"
      example message complete in two calls:
      *"Writefunction not implement"
      "ed yet\r\nWritefunction not implemented yet\r\n"

      That would be an error in your code, which you didnt show us so far.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved