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. Sending Hex data to a serial communication .Convert QByteArray to Hex
Forum Updated to NodeBB v4.3 + New Features

Sending Hex data to a serial communication .Convert QByteArray to Hex

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 493 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
    mganesh
    wrote on last edited by
    #1

    QByteArray monitorCommand ;
    monitorCommand = "0204000C0006B038";
    QByteArray data_to_transmit = QByteArray::fromHex(monitorCommand);
    qDebug() << monitorCommand << data_to_transmit;
    serialPort->write(data_to_transmit);

    qDebug output gives

    "0204000C0006B038" "\x02\x04\x00\f\x00\x06\xB0""8"
    but when converted as hex it should be \x02\x04\x00\0C\x00\x06\xB0\x38
    this data should tobe sent it giveing wrong

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mganesh said in Sending Hex data to a serial communication .Convert QByteArray to Hex:

      but when converted as hex it should be \x02\x04\x00\0C\x00\x06\xB0\x38

      It is. But qDebug() prints out text when the character is printable (and 0x38 is printable)

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mganesh
        wrote on last edited by
        #3

        above program is giving error when we sent this data on serial port . its not replying anything.
        may be hex value conversion wrong or may be \x00,\x00 that causing error??

        Christian EhrlicherC 1 Reply Last reply
        0
        • M mganesh

          above program is giving error when we sent this data on serial port . its not replying anything.
          may be hex value conversion wrong or may be \x00,\x00 that causing error??

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @mganesh The above code snippet is for sure not the reason for your problem.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          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