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. Confused with QSerialPort control

Confused with QSerialPort control

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 146 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.
  • S Offline
    S Offline
    SOrton
    wrote on last edited by
    #1

    Hi,

    I'm using this to receive data from an Arduino script:

    QObject::connect(arduino, SIGNAL(readyRead()), this, SLOT(readSerial()));
    

    This line is inside a "begin" button, and calls the readSerial function
    It works perfectly when I first run the program and I receive data like this (as intended):
    "x"
    "x"
    "x"
    "r"
    "x"
    "x"

    I then have a 'pause' button, where I send a stop command to my Arduino. Once I restart the Serial read (AFTER a pause), I'm receiving data incorrectly like this:
    "x"
    ""
    "x"
    ""
    "x"
    ""
    "r"
    ""
    "x"
    ""
    "x"
    I believe this is causing an issue with my system.
    I have a stop command in my Arduino to stop sending data, but do I have to somehow stop my signal/slot thing?
    Would love if somebody can help me/ requires more info on my program.

    Cheers

    JonBJ 1 Reply Last reply
    0
    • S SOrton

      Hi,

      I'm using this to receive data from an Arduino script:

      QObject::connect(arduino, SIGNAL(readyRead()), this, SLOT(readSerial()));
      

      This line is inside a "begin" button, and calls the readSerial function
      It works perfectly when I first run the program and I receive data like this (as intended):
      "x"
      "x"
      "x"
      "r"
      "x"
      "x"

      I then have a 'pause' button, where I send a stop command to my Arduino. Once I restart the Serial read (AFTER a pause), I'm receiving data incorrectly like this:
      "x"
      ""
      "x"
      ""
      "x"
      ""
      "r"
      ""
      "x"
      ""
      "x"
      I believe this is causing an issue with my system.
      I have a stop command in my Arduino to stop sending data, but do I have to somehow stop my signal/slot thing?
      Would love if somebody can help me/ requires more info on my program.

      Cheers

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @SOrton said in Confused with QSerialPort control:

      This line is inside a "begin" button, and calls the readSerial function

      Once I restart the Serial read (AFTER a pause), I'm receiving data incorrectly like this:

      Make sure you are not doing your connect() statement a second time? Your output looks like you might be doing two serial reads for each readyRead() signal, hence the alternating "blank" results?

      As a separate issue, do yourself a favour and change your connect()s to use the "new" syntax which was introduced over a decade ago....

      S 1 Reply Last reply
      2
      • S SOrton has marked this topic as solved on
      • JonBJ JonB

        @SOrton said in Confused with QSerialPort control:

        This line is inside a "begin" button, and calls the readSerial function

        Once I restart the Serial read (AFTER a pause), I'm receiving data incorrectly like this:

        Make sure you are not doing your connect() statement a second time? Your output looks like you might be doing two serial reads for each readyRead() signal, hence the alternating "blank" results?

        As a separate issue, do yourself a favour and change your connect()s to use the "new" syntax which was introduced over a decade ago....

        S Offline
        S Offline
        SOrton
        wrote on last edited by
        #3

        @JonB That makes perfect sense! not sure how I missed that :)

        Thanks for the speedy response!

        1 Reply Last reply
        0

        • Login

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