coassoftwaresystems / delphi-modbus

Delphi ModbusTCP components
MIT License
116 stars 64 forks source link

Error in comunication with PLC #29

Open flaviodei opened 6 years ago

flaviodei commented 6 years ago

Hello, I'm trying to use the TIdModBusClient component with a plc management software that communicates via MODBUS, I encounter problems in sending commands, I always receive an exception of DoResponseMismatch. By debugging at the component level in the TIdModBusClient.SendCommand function, I receive data from the server but in the code step {$ IFDEF DMB_INDY10} iSize: = IOHandler.InputBuffer.Size; IOHandler.ReadBytes (RecBuffer, iSize); Move (RecBuffer [0], ReceiveBuffer, iSize); the value of AModBusFunction that initially contains the correct code is reset to zero. I do not understand where I'm wrong ... Thanks for your help.

JensMertelmeyer commented 6 years ago

Can't you record the network traffic to reproduce the issue? Or at least extract the raw bytes by using the debugger and post them here. If the ModbusFunction in the reply of your PLC is zero, then this is not a valid Modbus reply as the highest bit in the function code has to be set.