Page 1 of 1

Modbus Master response buffer

Posted: Thu Dec 06, 2018 11:18 am
by markavo42
Hi

Can anyone help out and explain please.
I am working with modbus RTU master and flowcode 8 i send a question and get a response the question is correct and crc is correct.
The question expects a response but how do i process this response ?

I guess i should be using GetResponce() i read the explanation and it says:
Collects as much incoming data as possible and stored into the response buffer. The number of bytes received will be stored into location 0 of the response buffer.
Return value indicates validity of incoming CRC. 0 = OK, 1 = CRC fail, 255 = No Data
I receive 0 for OK but how do i access and process the data received meaning how do i access the locations of the response buffer ?
Thank you :D

Re: Modbus Master response buffer

Posted: Thu Dec 06, 2018 11:34 am
by Benj
Hello,

Have you looked at the examples on the wiki?
https://www.matrixtsl.com/wiki/index.ph ... 79aa54014a

The GetResponseByte allows you to read a single byte from the slave response. I believe the data might start at byte 2 or 3 but I'll check this for you.

edit. the response looks like this.

0 = Slave Address - Assuming one byte address
1 = Command Byte
2... = Data

0 = Slave Address MSB - Assuming two byte address
1 = Slave Address LSB
2 = Command Byte
3... = Data

The console window can be very useful for looking at the master commands and slave responses. On embedded hardware you could print out the return bytes to a display to help determine what the values are.

Re: Modbus Master response buffer

Posted: Thu Dec 06, 2018 1:51 pm
by markavo42
Thank you i will take a look :D