Search code examples
c#serial-communicationmodbus

Response code indication while using Modbus RTU


I am using Modbus RTU protocol to read data. I have Slave Id = 1 and Modbus Address = 40023. I am configuring Start Address = 22. Is it correct with my Modbus Address?

If I am configuring following details:

Slave Id= 1 Baud Rate = 19200 Stop Bits = 2 Data Bits = 8 Parity = None Start Address = 22

I am reading data with following code

var master = ModbusSerialMaster.CreateRtu(port);
ushort[] registers = master.ReadHoldingRegisters(slaveId, startAddress, 1);  //2 is number of points

With these details I am getting this response in console: INFO Modbus.IO.ModbusSerialTransport - TX: 1, 3, 2, 0, 0, 184, 68

In above response I only know some of them what they indicate like first digit 1 indicate Slave Id, 3 indicate function Code, 22 indicate Start Address, 2 indicate number of points.

Can anyone please explain me remaining code? What they indicate?

Thanks!


Solution

  • Start address is encoded in two bytes (0, 22). Number of registers is also encoded in two bytes (0, 2). (37, 207) is the CRC, needed in all Modbus RTU frames.