title: Modify "Modbus TCP" to "Modbus RTU" with QT - QModbusTcpClient
body: <p>I would have to send <code>Modbus</code> request for specific data, my problem is that I have to use mobile communication, wifi, connect to a custom electronic card, which is right in <code>Modbus RTU</code>.</p>
  
  <p>My working code connecting to the electronic board:</p>
  
  <pre><code>#include "connessione.h"
  #include &lt;QModbusTcpClient&gt;
  #include &lt;QVariant&gt;
  #include &lt;QModbusDataUnit&gt;
  #include &lt;QDebug&gt;
  
  connessione::connessione(QObject *parent) : QObject(parent)
  {
      qDebug() &lt;&lt; "here debug " &lt;&lt; "ok";
  
      clientX = new QModbusTcpClient();
      clientX-&gt;setConnectionParameter(QModbusDevice::NetworkAddressParameter, "192.168.222.1");
      clientX-&gt;setConnectionParameter(QModbusDevice::NetworkPortParameter, 5555);
  
      if (clientX-&gt;connectDevice())
      {
          qDebug()  &lt;&lt; "connected: " &lt;&lt; clientX-&gt;state();
      }
      else
      {
          qDebug()  &lt;&lt; "ERRORE" &lt;&lt; clientX-&gt;errorString();
      }
  }
  
  void connessione::clickButton(){
  
      QModbusDataUnit readUnit(QModbusDataUnit::HoldingRegisters, 0, 1); // just read input register 40006
      //qDebug() &lt;&lt; "readUnit" &lt;&lt; readUnit.RegisterType;
      qDebug() &lt;&lt; "readUnit" &lt;&lt; clientX-&gt;state();
  
  
      if (auto *reply = clientX-&gt;sendReadRequest(readUnit, 255)) // client id 255
      {
          if (!reply-&gt;isFinished())
          {
              // connect the finished signal of the request to your read slot
              qDebug() &lt;&lt; "connected" &lt;&lt; reply-&gt;errorString();
              connect(reply, &amp;QModbusReply::finished, this, &amp;connessione::readReady);
          }
          else
          {
              qDebug() &lt;&lt; "Errore" &lt;&lt; reply-&gt;errorString();
              delete reply; // broadcast replies return immediately
          }
      }
      else
      {
          qDebug() &lt;&lt; "Errore" &lt;&lt; reply-&gt;errorString();
          // request error
      }
  }
  
  void connessione::readReady()
  {
      QModbusReply *reply = qobject_cast&lt;QModbusReply *&gt;(sender());
      if (!reply)
          return;
  
      if (reply-&gt;error() == QModbusDevice::NoError)
      {
          const QModbusDataUnit unit = reply-&gt;result();
          int startAddress = unit.startAddress(); // the start address,
          int value = unit.value(0); // value of the start address + 0
  
          qDebug() &lt;&lt; "NESSUN ERRORE" &lt;&lt; reply-&gt;errorString();
      }
      else
      {
          qDebug() &lt;&lt; "Errore readReady" &lt;&lt; reply-&gt;errorString();
          // reply error
      }
  
      reply-&gt;deleteLater(); // delete the reply
  }
  </code></pre>
  
  <p>log string TCP sent: </p>
  
  <blockquote>
    <p>D/libmodbusMobile.so( 8042): (null):0 ((null)): qt.modbus: (TCP
    client) Sent TCP PDU: 0x0300000001 with tId: 2</p>
  </blockquote>
  
  <p>this is right: <strong>0x0300000001</strong></p>
  
  <p>But unfortunately, my electronic card, the integrated firmware I can not modify, is right with <code>Modbus RTU</code>, so I should change <code>0x0300000001</code> to <code>0x010300000001C1C2</code> where C1 and C2 are the checksums.</p>
  
  <p>I believe that <strong>QModbusDataUnit</strong> generate buffer to send. So how to change it? Exist manual solution where I build the buffer?</p>
  
  <p>how to change it and create custom send buffer like the example?</p>
  
  <p>Thanks</p>