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. Send QString by UART
Forum Updated to NodeBB v4.3 + New Features

Send QString by UART

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.3k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rcaji
    wrote on last edited by
    #1

    Hi,
    I try to send a QString by UART but only recieve one charcater.
    This is my code:

    QString word = "Hello";

    send = write(fd, word.toStdString().c_str(), strlen(word.toStdString().c_str()));

    Only recieve H.

    Any idea?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Maybe you are just getting the length of a pointer? Try with word.length() instead.

      (Z(:^

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Beowolve
        wrote on last edited by
        #3

        You don't want the StdString.

        Use:
        @
        write(fd, word.toLatin1().constData(), word.length());
        @

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rcaji
          wrote on last edited by
          #4

          Thanks it works now.

          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