coassoftwaresystems / delphi-modbus

Delphi ModbusTCP components
MIT License
119 stars 64 forks source link

Small issue with WriteRegisters in C++Builder? #21

Closed Daijobou closed 6 years ago

Daijobou commented 7 years ago

Hello,

Delphi IdModbusClient.pas: function WriteRegisters(const RegNo: Word; const RegisterData: array of Word): Boolean;

C++Builder IdModbusClient.hpp: bool __fastcall WriteRegisters(const System::Word RegNo, const System::Word *RegisterData, const int RegisterData_High);

When I use

System::Word myData[25]; 
// ..added values to myData and submit to register 1000 for 7 registers
WriteRegisters(1000, myData, 7);

I get on server side for "Count" instead of 7 a value of 8.

void __fastcall TForm1::IdModBusServer1WriteRegisters(const TIdContext *Sender, const int RegNr, const int Count, const TModRegisterData &Data, const TModBusRequestBuffer &RequestBuffer, BYTE &ErrorCode)
{
    Caption = IntToStr(Count);
}

Why? Is this a bug?

UPDATE: I think "RegisterData_High" means the last index for this "RegisterData"-array. Its not better to say here a Count? But that is now maybe not changeable without break exists code. So you can close this ticket. ;)