S
S
Slavka2016-01-26 10:32:57
Qt
Slavka, 2016-01-26 10:32:57

I just can't figure out how to create a ModBus ASCII request?

no need to pass a string like ":260300000004LRCcrlf"
but I don't know how to store it in the code and how to pass it through QtSerialPort
here is the LRC calculation code

char calculateLRC( char b[], int n){
          char lrc = 0x00;
         for (int i = 1; i < n; i++)
         {
             lrc = ( char)((lrc + b[i]) & 0xFF);
         }
         lrc = ( char)(((lrc ^ 0xff) + 1) & 0xFF);
         return lrc;
 }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question