delphipascalplcsiemenslibnodave

How to handle libnodave error message with Delphi?


I have a function that reads some values from Siemens PLC using libnodave.dll and nodave unit but I cannot figure out the error output. I am on purpose forcing to go in error and what I get from AError := string(daveStrerror(readResult)); is an incomprehensible message:

'桴'#$2065'敤楳敲'#$2064'摡牤獥'#$2073'獩戠祥湯'#$2064'楬業⁴潦'#$2072'桴獩倠䍌'

Maybe 2064/2065/2073/2072 all represent a different error code which I have to handle independently? And why chinese? My machine is set up in Italian language.


Solution

  • Clearly the library works with ANSI/ASCII chars. The nodave.pas unit works with PChar, which is PAnsiChar in Delphi versions up to D2007 and PWideChar above. You need to adjust the nodave.pas unit to handle that.

    You might get away with replacing all PChar with PAnsiChar, but I haven't inspected it more deeply.