kandiral / Kandiral

Delphi components by Kandiral Ruslan
14 stars 9 forks source link

Read/Write, The error status code is negative #3

Open cfzy opened 3 years ago

cfzy commented 3 years ago

Read error status code: -5, -104 Write error status code: -5, -102 Negative code has no error message, It has always been No errors.

kandiral commented 3 years ago

See TKRModbusMaster.ErrorMsg method:

function TKRModbusMaster.ErrorMsg(AError: integer; var ALevel: String): String;
var
  err: integer;
begin
  if AError>0 then begin
    ALevel:='Device error';
    if(AError<=MB_ERRORS_COUNT)then Result:=MODBUS_ERRORS_MSG[AError]
    else Result:='Unknown error';
  end else if(AError<0)AND(AError>-100)then begin
    ALevel:='Data processing error';
    err:=-AError;
    if(err<=MBM_ERRORS_COUNT)then Result:=MB_PARSER_ERRORS_MSG[err]
  end else if AError<-100 then begin
    ALevel:='Data transmission error';
    err:=-AError-100;
    Result:=FConnector.ErrorMsg(err);
  end else if AError=0 then begin
    ALevel:='';
    Result:='No errors';
  end else begin
    ALevel:='';
    Result:='Unknown error';
  end;
end;
cfzy commented 3 years ago

TKRModbusMaster.ErrorMsg method is not English, Project tips not fully converted to English.

kandiral commented 3 years ago

I will fix this shortly

cfzy commented 3 years ago

I will fix this shortly

Can it be fixed this month?

kandiral commented 3 years ago

I've already made changes but haven't committed them yet. The changes are not limited to language files. Changes have also been made to the Modbus protocol files.

I'll update the code tomorrow. But on my website (https://kandiral.ru), I will update the unit descriptions within a month. After updating components, Delphi may report missing properties error. Such errors should be ignored.

Thanks to the changes made, it was possible to almost double the speed of Modbus and at the same time reduce the load on the CPU.

Glad you chose my code to use. Sorry for the delay.

kandiral commented 3 years ago

Libraries updated

All messages are in files with the ending "Lng". To enable the default language (English), you need to comment out the define RUSSIAN_LANGUAGE in the file \Includes\language.inc