Lazarus

Programming => Networking and Web Programming => Topic started by: vinceducat on July 18, 2010, 06:28:51 pm

Title: OPC client with Lazarus
Post by: vinceducat on July 18, 2010, 06:28:51 pm
Hi i want to know if someone developpe an OPC client With Lazarus.

Title: Re: OPC client with Lazarus
Post by: felipemdc on August 08, 2010, 01:35:54 pm
What is OPC?
Title: Re: OPC client with Lazarus
Post by: ahmetnurideniz on August 13, 2010, 12:32:01 am
opc is  device programing on com port or lan port may be plc(programing locig control)
i want to develop it. but i don't know enought freepascal and lazarus programing.
if you use simens plc you can test libnodave components. it has delphi and pascal version. may be it can port for lazarus.
Title: Re: OPC client with Lazarus
Post by: Guzzi on August 07, 2013, 01:56:19 pm
You will find a OPC Client Tool Kit for Delphi and Lazarus at:
http://www.dopc.kassl.de (http://www.dopc.kassl.de)
It is not free, you have to pay for it.
Title: Re: OPC client with Lazarus
Post by: avra on August 08, 2013, 09:26:49 am
There is a lot of free Delphi OPC server/client code here:
http://www.opcconnect.com/delphi.php

Maybe with latest COM/DCOM advances in Lazarus, conversion would be possible with some manual effort. Anyway if you decide to try it then I suggest using SVN Laz+FPC versions.
Title: Re: OPC client with Lazarus
Post by: mig-31 on August 08, 2013, 10:41:52 am
I think it will be better to release server/client for OPC UA. It is multi-platform . Do not need COM/DCOM.
Anyway mostly it better use MODBUS TCP to communicate with PCL and HMI devices. PascalScada project support it.
Title: Re: OPC client with Lazarus
Post by: avra on August 09, 2013, 10:34:45 pm
I think it will be better to release server/client for OPC UA. It is multi-platform . Do not need COM/DCOM.
OPC UA specification is not free and available only to members. There isn't any free implementation even for Delphi. The day it shows for either Delphi or Lazarus will make me very happy. Till then, OPC DA is quite fine and working with current OPC servers.

Quote
Anyway mostly it better use MODBUS TCP to communicate with PCL and HMI devices. PascalScada project support it.
That is all right if your device is also talking MODBUS. Although MODBUS is one of most widely used protocols there are thousands of others, and if you make your application OPC client instead of just MODBUS client, then you will be able to talk to almost any device (not just ones with MODBUS) since OPC servers exist for virtually all of them.
Title: Re: OPC client with Lazarus
Post by: jl on July 14, 2015, 08:36:42 am
It has been 2 years and lots of new solutions are using OPC UA, just want to check with you guys if there's any endeavor on OPC-UA Client along the likes of the opcdelphi project?  Thanks in advance.  :)
Title: Re: OPC client with Lazarus
Post by: avra on July 27, 2015, 01:24:23 pm
It has been 2 years and lots of new solutions are using OPC UA, just want to check with you guys if there's any endeavor on OPC-UA Client along the likes of the opcdelphi project?
There isn't FPC/LAZ solution yet. The good thing is that that there is now an open source solution in C at http://open62541.org. The bad thing is that no one with free time seams to be interested enough to convert it into Pascal. There is another C solution at http://www.openopcua.org, but unfortunately author allowed using it only as a library from Pascal - which makes it a worse candidate.
Title: Re: OPC client with Lazarus
Post by: avra on August 17, 2016, 11:43:03 am
https://sourceforge.net/projects/myopcclient/?source=directory

OPC components now exist for Lazarus, too. Unfortunately GPL.
Title: Re: OPC client with Lazarus
Post by: jl on August 17, 2016, 11:52:22 am
https://sourceforge.net/projects/myopcclient/?source=directory

OPC components now exist for Lazarus, too. Unfortunately GPL.


It's only OPC DA, still no UA.
Title: Re: OPC client with Lazarus
Post by: avra on August 17, 2016, 12:44:16 pm
It's only OPC DA, still no UA.
I am happy anyway, because I will be able to get rid of D7 in few of my old projects. Unfortunately because of GPL I will not be able to use the component, but since OPCDA headers are not under GPL I can use just them. It will save me some time at least.

UPDATE: Just changed server from Kassl to Matrikon which I had on my dev machine and Test1 demo works.
Title: Re: OPC client with Lazarus
Post by: ZbynekZ on September 27, 2016, 10:44:01 pm
It is possible to develop OPC client in Lazarus with QuickOPC, http://www.quickopc.com. It is a commercial product. For Windows only. Supports OPC DA, OPC A&E, and OPC Unified Architecture (data, and Alarms&Conditions, currently). Some more info: http://kb.quickopc.com/First_experiences_using_QuickOPC_with_Free_Pascal_(Lazarus) (http://kb.quickopc.com/First_experiences_using_QuickOPC_with_Free_Pascal_(Lazarus)) .

Disclaimer: This is a self-promotion.
Title: Re: OPC client with Lazarus
Post by: Daren453 on May 10, 2017, 02:24:40 am
Did you have issues with opcconnect on the encoding? If so can you tell me the work-around?

Thanks,
Daren
Title: Re: OPC client with Lazarus
Post by: LacaK on June 05, 2020, 02:33:24 pm
I have created pascal wrapper to open source http://open62541.org.
You can look at http://lacak.users.sourceforge.net/ for headers and Windows DLL

There are also implementations of other industrial communication protocols like Modbus TCP or EtherNet/IP
Title: Re: OPC client with Lazarus
Post by: avra on June 05, 2020, 11:21:58 pm
I have created pascal wrapper to open source http://open62541.org
I am so happy :D :P :D. THANK YOU!!!

1) Do you plan to include some examples other then client example inside of open62541.pas?
2) Do you intend to put your wrapper in some repository like github so others can contribute?
3) Is your wrapper for official open62541 v1.0?
4) Did you test it only on win32? Have you tried it on win64, linux, or even arm?
5) I was able to find 64 bit version of libopen62541.dll on official site, and libwinpthread-1.dll inside of http://win-builds.org/1.5.0/packages/windows_64/winpthreads-v3.3.0-2-x86_64-w64-mingw32.txz. Could you tell me where should I look for 64 bit libgcc_s_sjlj-1.dll?

Sorry for so many questions  :-[
Title: Re: OPC client with Lazarus
Post by: Fred vS on June 05, 2020, 11:41:41 pm
Quote
Could you tell me where should I look for 64 bit libgcc_s_sjlj-1.dll?

Afaik, you may find it in FPC/3.3.1/bin/x86_64-win64/
Title: Re: OPC client with Lazarus
Post by: avra on June 05, 2020, 11:47:04 pm
Quote
Could you tell me where should I look for 64 bit libgcc_s_sjlj-1.dll?

Afaik, you may find it in FPC/3.3.1/bin/x86_64-win64/
Thanks! I hope it's a match.
Title: Re: OPC client with Lazarus
Post by: Fred vS on June 05, 2020, 11:59:07 pm
Quote
I hope it's a match.

You may also download + install last version of mingw-w64, libgcc_s_sjlj-1.dll is included.

http://mingw-w64.org/doku.php/download
Title: Re: OPC client with Lazarus
Post by: avra on June 06, 2020, 12:08:28 am
You may also download + install last version of mingw-w64, libgcc_s_sjlj-1.dll is included.

http://mingw-w64.org/doku.php/download
I didn't want exe setup so I ended up at win-builds.org looking for plain DLLs - but got lost in all those txz files where I could find only DLL needed for threading.
Title: Re: OPC client with Lazarus
Post by: Fred vS on June 06, 2020, 12:11:34 am
Quote
I didn't want exe setup so I ended up at win-builds.org looking for plain DLLs - but got lost in all those txz files where I could find only DLL needed for threading.

Is the attachment of my previous post not working?
Title: Re: OPC client with Lazarus
Post by: avra on June 06, 2020, 01:03:11 am
Quote
I didn't want exe setup so I ended up at win-builds.org looking for plain DLLs - but got lost in all those txz files where I could find only DLL needed for threading.

Is the attachment of my previous post not working?
Your attachment is more preferred then setup exe. I didn't test it yet.
Title: Re: OPC client with Lazarus
Post by: LacaK on June 08, 2020, 07:39:20 am
1) Do you plan to include some examples other then client example inside of open62541.pas?
Yes I can, no problem ... I will inform when it happens

2) Do you intend to put your wrapper in some repository like github so others can contribute?
No, I have no account on github and I have no free time to maintain it in long term. I created this wrapper as I neded it for one of my work projects (so only subset of API is translated). On other side I provide it as freeware (public doman) so anybody interested can do it.

3) Is your wrapper for official open62541 v1.0?
I think that yes. I created it in April 2020 from github sources so this time 1.0 was already released

4) Did you test it only on win32? Have you tried it on win64, linux, or even arm?
Only on Win32, I can test it also on Win64

5) I was able to find 64 bit version of libopen62541.dll on official site, and libwinpthread-1.dll inside of http://win-builds.org/1.5.0/packages/windows_64/winpthreads-v3.3.0-2-x86_64-w64-mingw32.txz. Could you tell me where should I look for 64 bit libgcc_s_sjlj-1.dll?
Already answered ;-) I remember that searching for win32 libraries was also for me complicated job ...
Title: Re: OPC client with Lazarus
Post by: LacaK on June 08, 2020, 12:36:30 pm
I have added demo application and Win64 DLLs: http://lacak.users.sourceforge.net/
(Win64 application works, but when closing - UA_Client_delete(client) is called - something goes wrong ...)
Title: Re: OPC client with Lazarus
Post by: avra on June 10, 2020, 02:52:11 pm
I have added demo application and Win64 DLLs: http://lacak.users.sourceforge.net/
Thank you for the effort. It is really appreciated.
Title: Re: OPC client with Lazarus
Post by: henk86 on June 15, 2020, 07:02:38 pm
Nice work,

I tried the example and connecting works. But read and write are not working for me. I used for the node id a string like this:

"ns=4;s=|var|CODESYS Control for Raspberry Pi SL.Application.PLC_PRG.iCounter"

Do you have any suggestions?


Title: Re: OPC client with Lazarus
Post by: LacaK on June 16, 2020, 07:06:08 am
You must type or select nameSpace index 4 from combobox beside "Namespace:" then in "Node Id:" edit box write name of variable probably in your case "|var|CODESYS Control for Raspberry Pi SL.Application.PLC_PRG.iCounter"
Title: Re: OPC client with Lazarus
Post by: henk86 on June 16, 2020, 06:12:49 pm
Thank you that worked.
Now I'm going to figure out how to translate a int16 value correctly.
Title: Re: OPC client with Lazarus
Post by: Riodev on June 20, 2020, 10:29:30 pm
I have created pascal wrapper to open source http://open62541.org.
You can look at http://lacak.users.sourceforge.net/ for headers and Windows DLL

There are also implementations of other industrial communication protocols like Modbus TCP or EtherNet/IP


Code: Pascal  [Select][+][-]
  1.   scert.LoadFromFile(ExtractFilePath(Application.ExeName)+'server_cert.der');
  2.   kcert.LoadFromFile(ExtractFilePath(Application.ExeName)+'server_key.der');
  3.   certificate := _UA_STRING(PAnsiChar(scert.Text));
  4.   privateKey := _UA_STRING(PAnsiChar(kcert.Text));
  5.  
  6.   UA_ClientConfig_setDefault(conf);
  7.   conf^.securityMode:= UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;
  8.  
  9.   UA_ClientConfig_setDefaultEncryption(conf, certificate, privateKey, nil, 0, nil,0);

I have a problem function UA_ClientConfig_setDefaultEncryption Access violation error

Please publish working example code for securityMode SIGNANDENCRYPT

thank
Title: Re: OPC client with Lazarus
Post by: LacaK on June 22, 2020, 07:19:37 am
Hello,
if you use bundled DLLs, which I took from pre-compiled v.1.0 DLLs, which were released https://github.com/open62541/open62541/releases/tag/v1.0
then they does not support SIGN and SIGN&ENCRYPT as they were compiled without UA_ENABLE_ENCRYPTION
Title: Re: OPC client with Lazarus
Post by: LacaK on June 22, 2020, 03:02:21 pm
Updated headers and Windows DLLs to version 1.1 (open62541 released 06/2020)
  (https://github.com/open62541/open62541/releases/tag/v1.1)
at http://lacak.users.sourceforge.net/#open62541
Title: Re: OPC client with Lazarus
Post by: Riodev on June 22, 2020, 06:13:14 pm
Updated headers and Windows DLLs to version 1.1 (open62541 released 06/2020)
  (https://github.com/open62541/open62541/releases/tag/v1.1)
at http://lacak.users.sourceforge.net/#open62541


Access violation error

sorry sir UA_ClientConfig_setDefaultEncryption function is a problem for me   
Not sure if I did something wrong or not?

Title: Re: OPC client with Lazarus
Post by: avra on June 22, 2020, 07:14:04 pm
Updated headers and Windows DLLs to version 1.1 (open62541 released 06/2020)
Thank you!

What happened to UA_ClientState in wrapper for v1.1?

Is there a chance for getting a server part wrapper sometime in the future?
Title: Re: OPC client with Lazarus
Post by: LacaK on June 23, 2020, 07:14:40 am
Access violation error
sorry sir UA_ClientConfig_setDefaultEncryption function is a problem for me   

function UA_ClientConfig_setDefaultEncryption() is not part of precompiled DLL, so when application links at runtime to this open62541.DLL entry point is not found, so is not assigned = nil. When you try call this function AV happens. It is expected.
(You may test before call: if Assigned(UA_ClientConfig_setDefaultEncryption) then UA_ClientConfig_setDefaultEncryption(...))
Title: Re: OPC client with Lazarus
Post by: LacaK on June 23, 2020, 07:22:46 am
What happened to UA_ClientState in wrapper for v1.1?
As far as I can cee from sources, this enumeration was removed and also function UA_Client_getState was changed.
(it is backward incompatible change)

Is there a chance for getting a server part wrapper sometime in the future?
I do not need server part in my project, so I do not plan do it. If you need some very limited subset of functions I can add them ...

Currently unresolved problems are:
- Win64 client has problem while UA_Client_delete() is called
- UA_Client_connectUsername() does not work for me (may be that my testing OPC UA Server does not support it, or there is any problem)
Has somebody any feedback on these two problems?
Title: Re: OPC client with Lazarus
Post by: avra on June 23, 2020, 11:55:46 am
What happened to UA_ClientState in wrapper for v1.1?
As far as I can cee from sources, this enumeration was removed and also function UA_Client_getState was changed.
(it is backward incompatible change)
Strange, since I can still find it in official v1.1 open62541.h at https://github.com/open62541/open62541/releases/tag/v1.1.

Is there a chance for getting a server part wrapper sometime in the future?
I do not need server part in my project, so I do not plan do it. If you need some very limited subset of functions I can add them ...
That would be fantastic! I looked at server examples and the one with the smallest number of methods and structures (but still having at least one tag) seams to be server.cpp. Whatever you can implement from there would be a jump start for me to try.

Currently unresolved problems are:
- Win64 client has problem while UA_Client_delete() is called
- UA_Client_connectUsername() does not work for me (may be that my testing OPC UA Server does not support it, or there is any problem)
Has somebody any feedback on these two problems?
My plan is to translate some original examples and do some testing needed for my use case, but because of the deadlines I currently have, it does not seam to be possible before the end of August (or even beginning of September since new ct4laz will be needed for Laz 2.0.10 with FPC 3.2.0).
Title: Re: OPC client with Lazarus
Post by: LacaK on June 23, 2020, 02:26:40 pm
What happened to UA_ClientState in wrapper for v1.1?
As far as I can cee from sources, this enumeration was removed and also function UA_Client_getState was changed.
(it is backward incompatible change)
Strange, since I can still find it in official v1.1 open62541.h at https://github.com/open62541/open62541/releases/tag/v1.1.
Yes it is strange in https://github.com/open62541/open62541/releases/download/v1.1/open62541.h there is present, but in headers included in https://github.com/open62541/open62541/releases/download/v1.1/open62541-win32.zip is removed.
See commit https://github.com/open62541/open62541/commit/97ce87470c93423f7adf6b1d8fd87cd8d3252fb3#diff-44b00b50652139af475d451264d49ffd which removes it.
Title: Re: OPC client with Lazarus
Post by: avra on June 23, 2020, 03:43:49 pm
Yes it is strange in https://github.com/open62541/open62541/releases/download/v1.1/open62541.h there is present, but in headers included in https://github.com/open62541/open62541/releases/download/v1.1/open62541-win32.zip is removed.
It seams that UA_ClientState is really gone. New v1.1 of client_async.c and client_subscription_loop.c no longer reference it.
Title: Re: OPC client with Lazarus
Post by: LacaK on June 29, 2020, 11:32:02 am
Is there a chance for getting a server part wrapper sometime in the future?
I do not need server part in my project, so I do not plan do it. If you need some very limited subset of functions I can add them ...
That would be fantastic! I looked at server examples and the one with the smallest number of methods and structures (but still having at least one tag) seams to be server.cpp. Whatever you can implement from there would be a jump start for me to try.

I have added some server side functions to:
- run OPC UA server
- add variable
- write value to variable
+ updated demo program, which now can work as client and also as server
(it is minimalistic but can be used)
Title: Re: OPC client with Lazarus
Post by: avra on July 01, 2020, 09:13:07 pm
I have added some server side functions
THANK YOU !!!  :D 8-) :D
Title: Re: OPC UA client with Lazarus (open62541)
Post by: LacaK on December 04, 2020, 07:02:15 pm
I have added some other functions to header file and extended demo application
http://lacak.users.sourceforge.net/freepascal.html#open62541
Title: Re: OPC client with Lazarus
Post by: Lazarus™ on July 10, 2021, 03:01:59 pm
Dear Lacak,
please can you generate a package with all dll's (actual Open62541 - Version 1.2.2), Open62541.pas and Server- Client Sample ?

if you wan't you can also send me an email...
Title: Re: OPC client with Lazarus
Post by: LacaK on July 12, 2021, 01:55:49 pm
Problem is that, open62541 project https://github.com/open62541/open62541/releases
no more releases pre-compiled DLLs for Windows. So only way is compile from source codes ... currently I do not have free time to play with this.
If someone provides these DLLs then I can update open62541.pas and demo application of course ...
Title: Re: OPC client with Lazarus
Post by: denny.chou on October 12, 2021, 05:26:21 am
Excuse me, I have a problem in use...

When UA_Client_Service_read reads multiple nodes, the result will be UA_STATUSCODE_GOOD, but only the first node has data and the others are empty

Why is this happening?
Title: Re: OPC client with Lazarus
Post by: LacaK on October 12, 2021, 07:16:43 am
Hard to say without deeper look at source code ... can you provide source code which reads values?
Title: Re: OPC client with Lazarus
Post by: denny.chou on October 12, 2021, 07:38:00 am
When UA_Client_Service_read reads multiple nodes, the result will be UA_STATUSCODE_GOOD, but only the first node has data and the others are empty

Why is this happening?

This is part of the function, the connection to the server has been completed before the parameter client is passed in...

Code: Pascal  [Select][+][-]
  1. var
  2.   i:Integer;
  3.   retval: UA_StatusCode;
  4.  
  5.   Request: UA_ReadRequest;
  6.   Response: UA_ReadResponse;
  7.   ids: Array[0..2] of UA_ReadValueId;
  8.   res: UA_DataValue;
  9.   outValue: String;
  10. begin
  11.   Result:=UA_STATUSCODE_GOOD;
  12.   try
  13.     UA_ReadRequest_init(Request);
  14.     try
  15.       ids[0].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13
  16.       ids[0].nodeId := UA_NODEID_NUMERIC(5, 6024);    // Custom node on the server
  17.  
  18.       ids[1].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13
  19.       ids[1].nodeId := UA_NODEID_NUMERIC(5, 6025);    // Custom node on the server
  20.  
  21.       ids[2].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13
  22.       ids[2].nodeId := UA_NODEID_NUMERIC(5, 6026);    // Custom node on the server
  23.  
  24.       UA_ReadValueId_init(ids[0]);
  25.       Request.nodesToRead[0].nodeId:= ids[0].nodeId;
  26.       Request.nodesToRead[0].attributeId:=ids[0].attributeId;
  27.  
  28.       UA_ReadValueId_init(ids[1]);
  29.       Request.nodesToRead[1].nodeId:= ids[1].nodeId;
  30.       Request.nodesToRead[1].attributeId:=ids[1].attributeId;
  31.  
  32.       UA_ReadValueId_init(ids[2]);
  33.       Request.nodesToRead[2].nodeId:= ids[2].nodeId;
  34.       Request.nodesToRead[2].attributeId:=ids[2].attributeId;
  35.      
  36.       Request.nodesToRead:=@ids[0];
  37.       Request.nodesToReadSize:=3;
  38.  
  39.       Response:=UA_Client_Service_read(client, Request);
  40.       retval:=Response.responseHeader.serviceResult;
  41.       if retval=UA_STATUSCODE_GOOD then
  42.         if Response.resultsSize<>3 then
  43.         begin
  44.           UA_clear(@Response, @UA_TYPES[UA_TYPES_READRESPONSE]);
  45.           Result:=UA_STATUSCODE_BADUNEXPECTEDERROR;
  46.           Exit;
  47.         end;
  48.  
  49.       for i:=0 to 2 do
  50.       begin
  51.         outValue:='';
  52.         if Response.results[i].status<>UA_STATUSCODE_GOOD
  53.           then continue;
  54.  
  55.         res := Response.results[i];
  56.    (*     if Not res.hasvalue then
  57.         begin
  58.           valueItems.Append('');
  59.           break;
  60.         end;  *)
  61.  
  62.         if res.value._type=@UA_TYPES[UA_TYPES_INT32] then
  63.           outValue:=IntToStr(UA_Variant_getInteger(res.value))
  64.         else
  65.         if res.value._type=@UA_TYPES[UA_TYPES_INT16] then
  66.           outValue:=IntToStr(UA_Variant_getSmallint(res.value))
  67.         else
  68.         if res.value._type=@UA_TYPES[UA_TYPES_DOUBLE] then
  69.           outValue:=UA_Variant_getDouble(res.value).ToString;
  70.  
  71.  
  72.         valueItems.Append(outValue);
  73.       end;
  74.     except
  75.       //
  76.     end;
  77.   finally
  78.     UA_clear(@Response, @UA_TYPES[UA_TYPES_READRESPONSE]);
  79.   end;
  80. end;
  81.  
Title: Re: OPC client with Lazarus
Post by: denny.chou on October 12, 2021, 10:25:00 am
in addition...
1. UA_Client_connect(client 1, IP_1);
You can connect to IP_1 normally

but...
2.
UA_Client_connect(client 1, IP_1);
UA_Client_connect(client 2, IP_2);
Only IP_1 can connect normally;
The return result of IP_2 is UA_STATUSCODE_BADINTERNALERROR = $80020000;

Can I connect to another server only after client_1 is disconnected?
Title: Re: OPC client with Lazarus
Post by: denny.chou on October 14, 2021, 05:42:07 am
Please help me with the subscription function...

Verified the results of the subscription function...
{$DEFINE HAVE_PROSYSSIMULATIONSERVER}
monResponse.statusCode returns UA_STATUSCODE_BADINTERNALERROR ($80020000)
The sample program you provided is used for verification: TestOpcUa1

More specifically... if lines 243-280 are removed, response.responseHeader.serviceResult will not be UA_STATUSCODE_GOOD

Why is this happening?
Title: Re: OPC client with Lazarus
Post by: LacaK on October 14, 2021, 07:31:58 pm
I am sorry, but I have limited experience with this.
I did TestOpcUa program during testing implementation of Pascal port of library "open62541".
It worked for me in given test scenario with PROSYS SIMULATION SERVER ...
Title: Re: OPC client with Lazarus
Post by: denny.chou on October 15, 2021, 08:20:29 am
I'm sorry for not clarifying the environment I use, I am using delphi XE10, directly quote the open62541.pas you provided

I really don't know the difference between fp and xe10?
Title: Re: OPC client with Lazarus
Post by: LacaK on October 15, 2021, 06:56:38 pm
open62541.pas should work with Delphi also.
I do not think that problem you described is caused by Delphi itself.

Take look at example: https://github.com/open62541/open62541/blob/master/src/client/ua_client_highlevel.c

In your example, you assign values it ids[0] and then you call UA_ReadValueId_init(ids[0]); which clears content. Is it okay?

Try:
Code: Pascal  [Select][+][-]
  1.       UA_ReadValueId_init(ids[0]);
  2.       ids[0].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13
  3.       ids[0].nodeId := UA_NODEID_NUMERIC(5, 6024);    // Custom node on the server
  4.  
  5.       UA_ReadValueId_init(ids[1]);
  6.       ids[1].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13
  7.       ids[1].nodeId := UA_NODEID_NUMERIC(5, 6025);    // Custom node on the server
  8.  
  9.       UA_ReadValueId_init(ids[2]);
  10.       ids[2].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13
  11.       ids[2].nodeId := UA_NODEID_NUMERIC(5, 6026);    // Custom node on the server
  12.  
  13.       Request.nodesToRead:=@ids[0];
  14.       Request.nodesToReadSize:=3;
  15.  
Title: Re: OPC client with Lazarus
Post by: denny.chou on October 20, 2021, 10:50:13 am
Finally, I changed to Lazarus's development platform to implement it, and none of the three issues mentioned above exist... :(

But there is a problem with the implementation of stateCallback, as long as UA_Client_connect is executed, an error will be reported:
... raised exception class'External:SIGSEGV'

why?
Title: Re: OPC client with Lazarus
Post by: lupus-rain on October 21, 2021, 11:04:25 am
Finally, I changed to Lazarus's development platform to implement it, and none of the three issues mentioned above exist... :(

But there is a problem with the implementation of stateCallback, as long as UA_Client_connect is executed, an error will be reported:
... raised exception class'External:SIGSEGV'

why?

I stumbled upon the same problem the same day. Having connecion problems in my self written wrapper (based on open62541 V 0.3), i found this project and tried to include it into my components.

The open62541 c++ example works well with stateCallback, but as soon as i try stateCallback in Delphi, i get an Access violation.

One strange thing I observed: The callback procedure is called one time, and the Session State parameter has a value of -1, which is invalid. In c++ I don't see this value.
Title: Re: OPC client with Lazarus
Post by: lupus-rain on October 25, 2021, 11:19:56 am
Found the fault in open62541.pas wrapper: record UA_ConnectionConfig was enhanced 24. Jan. 2020 to

  UA_ConnectionConfig = record
      protocolVersion: UA_UInt32;
      recvBufferSize: UA_UInt32;
      sendBufferSize: UA_UInt32;
      localMaxMessageSize: UA_UInt32; (*  (0 = unbounded) *)
      remoteMaxMessageSize: UA_UInt32;  (*  (0 = unbounded) *)
      localMaxChunkCount: UA_UInt32; (*  (0 = unbounded) *)
      remoteMaxChunkCount: UA_UInt32;  (*  (0 = unbounded) *)
  end;
Title: Re: OPC client with Lazarus
Post by: LacaK on October 26, 2021, 09:43:31 am
Yes, you are right!
(probably this was changed in 1.0 -> 1.1 release branch)
Thank you!
Title: Re: OPC client with Lazarus
Post by: denny.chou on November 02, 2021, 03:16:17 am
Found the fault in open62541.pas wrapper: record UA_ConnectionConfig was enhanced 24. Jan. 2020 to

  UA_ConnectionConfig = record
      protocolVersion: UA_UInt32;
      recvBufferSize: UA_UInt32;
      sendBufferSize: UA_UInt32;
      localMaxMessageSize: UA_UInt32; (*  (0 = unbounded) *)
      remoteMaxMessageSize: UA_UInt32;  (*  (0 = unbounded) *)
      localMaxChunkCount: UA_UInt32; (*  (0 = unbounded) *)
      remoteMaxChunkCount: UA_UInt32;  (*  (0 = unbounded) *)
  end;

Wow, it was really unexpected. I tried to modify the definition of UA_ConnectionConfig synchronously. The problem of reporting an error as soon as the stateCallback executes UA_Client_connect did not happen anymore. Thank you very much.
Title: Re: OPC client with Lazarus
Post by: olivluca on November 04, 2021, 12:44:18 pm
FYI, I'm trying to build v1.2.2 of the dll under windows (32 bits). I'm facing some problems I exposed on the open62541 mailing list (with no replies so far).
In case you're interesed and/or can help, this is the message:

https://groups.google.com/g/open62541/c/pTc8pSneN74

the problem is that the files types_generated.inc (with my modified tool) and types_generated.h (with the stock tool) are different under windows and linux, so I cannot generate consistent bindings that works under both platforms.
Title: Re: OPC client with Lazarus
Post by: LacaK on November 04, 2021, 05:53:32 pm
@olivluca: can you please also update definition of record UA_ConnectionConfig in https://github.com/fluisgirardi/fpopen62541/blob/main/open62541.pas as suggested above ...
Title: Re: OPC client with Lazarus
Post by: denny.chou on November 23, 2021, 10:26:51 am
Hello, can this also be used to connect opc-da?
Title: Re: OPC client with Lazarus
Post by: avra on November 23, 2021, 10:26:18 pm
Hello, can this also be used to connect opc-da?
Normally not, but there are OPC-UA to OPC-DA gateways which allow that.

For direct OPC-DA access you can use something like this: https://github.com/seryal/OPCComponent
Title: Re: OPC client with Lazarus
Post by: denny.chou on November 24, 2021, 04:17:58 am

Normally not, but there are OPC-UA to OPC-DA gateways which allow that.

For direct OPC-DA access you can use something like this: https://github.com/seryal/OPCComponent

Thank you for your valuable response
Title: Re: OPC client with Lazarus
Post by: denny.chou on November 24, 2021, 06:57:33 am
"For direct OPC-DA access you can use something like this: https://github.com/seryal/OPCComponent"

What should I do if such an error message appears when installing this component? thanks!

OPCtypes.pas(37,69) Error: Data element too large
Title: Re: OPC client with Lazarus
Post by: avra on November 24, 2021, 09:14:46 am
What should I do if such an error message appears when installing this component?
Contact author or open a github issue? I haven't used that coponent for a while, so maybe trying older Lazarus like 2.0.x might be worth trying.
Title: Re: OPC client with Lazarus
Post by: denny.chou on November 26, 2021, 04:18:40 am
Contact author or open a github issue? I haven't used that coponent for a while, so maybe trying older Lazarus like 2.0.x might be worth trying.

Thank you very much for your suggestion. The author has assisted with this issue.
Title: Re: OPC client with Lazarus
Post by: Чебурашка on July 06, 2022, 12:36:12 pm
Hello,
I just downloaded the free pascal wrapper from https://github.com/fluisgirardi/fpopen62541 but if I run the test application, when I try to add the variable, it fails with error BADNODEATTRIBUTESINVALID.
I am running free pascal/lazarus under linux and compiled open62541 under linux from sources.


I use open62541 version 1.2.3, maybe is no longer supported?

What version of open62541 has to be used to make sure it works?
Title: Re: OPC client with Lazarus
Post by: LacaK on July 23, 2022, 01:29:48 pm
According to sources on https://github.com/fluisgirardi/fpopen62541 the version there should be compatible with open62541 version 1.2
(originial test application was developed and tested against version 1.1. Header files for version 1.1 you can find in this discussion earlier if you want test them)
Title: Re: OPC client with Lazarus
Post by: yus on July 26, 2022, 08:02:08 pm
If you need OPC DA.

https://github.com/seryal/OPCComponent
Title: Re: OPC client with Lazarus
Post by: ruedi on August 02, 2022, 02:35:32 pm
Hallo,
It is possible to insert several monitored items in one subscription.
I would like to subscribe to several variables.
Title: Re: OPC client with Lazarus
Post by: Чебурашка on August 25, 2022, 10:13:51 am
Hello everybody,
I tried running the TestOpcUa demo bundled with the free pascal open62541 wrapper.

I use library version 1.2.3 located in same dir as application.

When I try starting the server with the <start> button I get this:

user@debian:~/Documents/dev/3rd-party/fpopen62541-main$ LD_LIBRARY_PATH=. ./TestOpcUa

[...]
[2022-08-25 10:11:59.161 (UTC+0200)] warn/server        AccessControl: Unconfigured AccessControl. Users have all permissions.
[2022-08-25 10:11:59.161 (UTC+0200)] info/server        AccessControl: Anonymous login is enabled
[2022-08-25 10:11:59.161 (UTC+0200)] warn/server        Username/Password configured, but no encrypting SecurityPolicy. This can leak credentials on the network.
[2022-08-25 10:11:59.161 (UTC+0200)] warn/userland      AcceptAll Certificate Verification. Any remote certificate will be accepted.
[2022-08-25 10:11:59.161 (UTC+0200)] info/network       TCP network layer listening on opc.tcp://debian:4840/
[2022-08-25 10:11:59.212 (UTC+0200)] info/network       Shutting down the TCP network layer


Last line in log is the problem. It seems that server is started and immedialy stopped, as if the "running" variable passed to control server execution is not read correclty, despite in TestOpcUa is set correctly before passing to run method.

I tried to create another C program to call the library directly and once started it does not show the above red line:

user@debian:~/dev/open62541-v1.2.3/build/bin/custom$ LD_LIBRARY_PATH=. ./custom-OpcServer

[...]
[2022-08-25 10:09:36.109 (UTC+0200)] warn/server   AccessControl: Unconfigured AccessControl. Users have all permissions.
[2022-08-25 10:09:36.109 (UTC+0200)] info/server   AccessControl: Anonymous login is enabled
[2022-08-25 10:09:36.109 (UTC+0200)] warn/server   Username/Password configured, but no encrypting SecurityPolicy. This can leak credentials on the network.
[2022-08-25 10:09:36.109 (UTC+0200)] warn/userland   AcceptAll Certificate Verification. Any remote certificate will be accepted.
[2022-08-25 10:09:36.109 (UTC+0200)] info/network   TCP network layer listening on opc.tcp://debian:4840/


Any ideas?
Thank you

Title: Re: OPC client with Lazarus
Post by: Чебурашка on August 25, 2022, 10:33:44 am
Hi again,
I did same test with library version 1.1.0 and seems to work correctly, probably something was changed in open62541 and wrapper does not support newer versions.

Any ideas?
Title: Re: OPC client with Lazarus
Post by: LacaK on August 26, 2022, 01:58:51 pm
I did same test with library version 1.1.0 and seems to work correctly, probably something was changed in open62541 and wrapper does not support newer versions.
Try report it on https://github.com/fluisgirardi/fpopen62541 ?
Title: Re: OPC client with Lazarus
Post by: Чебурашка on August 26, 2022, 02:20:01 pm
I did same test with library version 1.1.0 and seems to work correctly, probably something was changed in open62541 and wrapper does not support newer versions.
Try report it on https://github.com/fluisgirardi/fpopen62541 ?

Done.
Thank you.
Title: Re: OPC client with Lazarus
Post by: TheMouseAUS on April 22, 2023, 02:42:26 am
I have decided to attempt to switch from OPC-DA to OPC-UA and use Ignition as the Allen Bradley OPC server under Linux (trying to get away from windows as I really dont think the current windows versions ie 10 and 11 are any good for industrail use).

I am running Fedora and have open62541 (ver 1.3.4)  installed and using the wrapper discussed here but I cannot get a connection all I get is error 80AD0000 which I believe is a disconnect by the sever. Does anyone have a simple client example I can follow so I can see what I am missing? I am guessing its on the client config but not sure what. I have security disabled in the server and using a Quick OPC client I can see the tags so that side is working.

This is what I am doing in my connect procedure ;-

client := UA_Client_new();
conf := UA_Client_getConfig(client);
UA_ClientConfig_setDefault(conf);
res := UA_Client_connect(client, 'opc.tcp://localhost:62541');

Edit :- i changed the server url to something that does not exist just to see if the error message changes but it remains the same, so I can only assume that its not even trying to connect maybe its an version issue?

Title: Re: OPC client with Lazarus
Post by: avra on April 22, 2023, 01:47:23 pm
Basic troubleshooting would be these 2 steps:

1. Check if you can connect from open62541 local pascal client to open62541 local server. If that is not working then try original C based client. With this you confirm that your open62541 is locally working.
2. Use some external OPC UA client (for example Matrikon on Windows) and try to connect to your Ignition OPC UA server. If that does not work try to connect to open62541 OPC UA server. If that also does not work then look if Ignition has installed some internal OPC UA client and try that to connect with local Ignition OPC UA server. If that works, then you probably have to change some Ignition OPC UA server security settings. With this you confirm that Ignition OPC UA server is working and if it's access is protected.
Title: Re: OPC client with Lazarus
Post by: TheMouseAUS on April 22, 2023, 02:54:44 pm
Yes that was my first troubleshooting test, I used a OPC test client based on python and it worked perfectly so I know Ignition is configured and operating correctly.

I tried to compile the test example that is shipped with fpopen62541 but it does not compile, there is an issue with an identifier 'memberTypeIndex' so I cannot run the TestOPCUa to test it. Do you have a pascal client I can use to test with so I can confirm open62541 is working
Title: Re: OPC client with Lazarus
Post by: avra on April 22, 2023, 10:47:10 pm
Yes that was my first troubleshooting test, I used a OPC test client based on python and it worked perfectly so I know Ignition is configured and operating correctly.
You confirmed step 2, but not a word about step 1. Do you have libopen62541.so on your system? Did you follow https://www.open62541.org/doc/1.3/installing.html#installing instructions? Can you compile some open62541 server and client examples? If for instance you compile some example like gcc -std=c99 -o server tutorials_server_firststeps.c -lopen62541 and after that you execute objdump -p server | grep NEEDED or ldd server you will see that something like libopen62541.so.1 is needed for execution.

You can also take a look at open62541.pas:
Code: Pascal  [Select][+][-]
  1. {$IFDEF UNIX}
  2.   libopen62541 = 'libopen62541.so';
  3. {$ELSE}
  4.   libopen62541 = 'libopen62541.dll'; // GCC libgcc_s_sjlj-1.dll and libwinpthread-1.dll are also required
  5.                                      //  they can be downloaded from packages at http://win-builds.org/1.5.0/packages/windows_32/
  6. {$ENDIF}

I tried to compile the test example that is shipped with fpopen62541 but it does not compile, there is an issue with an identifier 'memberTypeIndex' so I cannot run the TestOPCUa to test it. Do you have a pascal client I can use to test with so I can confirm open62541 is working
Try this older version compatible with open62541 v1.2:
https://github.com/fluisgirardi/fpopen62541/tree/d9132e968d9d050c90225a493121acb67cdceac3
You will probably need to match it with https://github.com/open62541/open62541/releases/tag/v1.2.6

Btw, if libopen62541.so is installed, but still can not be found you can execute this for current session:
Code: Bash  [Select][+][-]
  1. export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
or to make the change permanent you can add /usr/local/lib to /etc/ld.so.conf and run ldconfig as root.
Title: Re: OPC client with Lazarus
Post by: TheMouseAUS on April 23, 2023, 01:37:15 am
Sorry did not fully understand the first question.

When I first tried to compile and run I got the message could not open open libopen62541.so. I check the fedora repo's and it was there for install both implementation and dev packages so no I did not compile libopen62541.so I just installed them. After that the application runs but just no connection is happening, as its version 1.3.4 , maybe its just incompatible with the wrapper at this stage.

Three months ago ver 1.3 was added to fpopen62541 and there has been commits since but maybe its incomplete at this time. I will attempt to compile and install ver 1.2.6 and see how I go. Thanks :-)
Title: Re: OPC client with Lazarus
Post by: avra on April 23, 2023, 02:15:57 am
When I first tried to compile and run I got the message could not open open libopen62541.so. I check the fedora repo's and it was there for install both implementation and dev packages so no I did not compile libopen62541.so I just installed them. After that the application runs but just no connection is happening, as its version 1.3.4 , maybe its just incompatible with the wrapper at this stage.
If you do not compile and test some open62541 server and client, or at least server and test it with some external client, we will not know if problem is in open62541 or fpopen62541 part.

Three months ago ver 1.3 was added to fpopen62541 and there has been commits since but maybe its incomplete at this time. I will attempt to compile and install ver 1.2.6 and see how I go. Thanks :-)
I suggest you to first compile just demo from old fpopen62541 version I gave you with open62541 1.3 you already have. I can compile similar version locally. Only if that Lazarus demo compiles but does not execute well, you should try to uninstall open62541 1.3 and install 1.2.
Title: Re: OPC client with Lazarus
Post by: TheMouseAUS on April 23, 2023, 02:34:00 am
Yes I was thinking that :-)
OK i found fedora open62541 rpm's for version 1.2.6 which I have just installed. I have just compiled the fpopen62541 version you gave me and attempted to connect to Ignition.

Same fault 'Fail status code: 80AD0000 BadDisconnect'

I started the UA server in fpopen62541 and attempted to connect to that

'4/6 UA_SESSIONSTATE_ACTIVATED/UA_SECURECHANNELSTATE_OPEN'

so open62541 works. I just cannot connect to Ignition for some reason.

Using FreeOpcUa I can connect and see the PLC so I know the server is working.
Title: Re: OPC client with Lazarus
Post by: TheMouseAUS on April 23, 2023, 11:16:43 am
Been investigating and I think it maybe a configuration issue, trying to work out the different config options.

The test server reports the following when queried

uaclient.uaclient - INFO - Endpoint 1:')
uaclient.uaclient - INFO -   Endpoint URL: opc.tcp://localhost:4840')
uaclient.uaclient - INFO -   Application URI: urn:open62541.server.application')
uaclient.uaclient - INFO -   Product URI: http://open62541.org')
uaclient.uaclient - INFO -   Application Name: LocalizedText(Locale='en', Text='open62541-based OPC UA Application')')
uaclient.uaclient - INFO -   Application Type: 0')
uaclient.uaclient - INFO -   Discovery URL: opc.tcp://localhost:4840')
uaclient.uaclient - INFO -   Server Certificate: [no certificate]')
uaclient.uaclient - INFO -   Security Mode: 1')
uaclient.uaclient - INFO -   Security Policy URI: http://opcfoundation.org/UA/SecurityPolicy#None')
uaclient.uaclient - INFO -   User policy: open62541-anonymous-policy')
uaclient.uaclient - INFO -     Token type: 0')
uaclient.uaclient - INFO -   User policy: open62541-username-policy')
uaclient.uaclient - INFO -     Token type: 1')
uaclient.uaclient - INFO -     Security Policy URI: http://opcfoundation.org/UA/SecurityPolicy#None')
uaclient.uaclient - INFO -   Transport Profile URI: http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary')
uaclient.uaclient - INFO -   Security Level: 1')
uaclient.uaclient - INFO - ')

the Ignition server :-

uaclient.uaclient - INFO - Endpoint 1:')
uaclient.uaclient - INFO -   Endpoint URL: opc.tcp://localhost:62541')
uaclient.uaclient - INFO -   Application URI: urn:inductiveautomation:ignition:opcua:server:5e954f0a-ab48-41cb-bbac-f36d4fcc3819')
uaclient.uaclient - INFO -   Product URI: urn:inductiveautomation:ignition:opcua:server')
uaclient.uaclient - INFO -   Application Name: LocalizedText(Locale='en', Text='Ignition OPC UA Server')')
uaclient.uaclient - INFO -   Application Type: 0')
uaclient.uaclient - INFO -   Discovery URL: opc.tcp://localhost:62541/discovery')
uaclient.uaclient - INFO -   Server Certificate: commonName=Ignition OPC UA Server, organizationName=Inductive Automation, organizationalUnitName=, localityName=Folsom, stateOrProvinceName=CA, countryName=US (self-signed), 2023-04-20 14:00:00 - 2026-04-20 14:00:00')
uaclient.uaclient - INFO -   Security Mode: 1')
uaclient.uaclient - INFO -   Security Policy URI: http://opcfoundation.org/UA/SecurityPolicy#None')
uaclient.uaclient - INFO -   User policy: anonymous')
uaclient.uaclient - INFO -     Token type: 0')
uaclient.uaclient - INFO -   User policy: username')
uaclient.uaclient - INFO -     Token type: 1')
uaclient.uaclient - INFO -     Security Policy URI: http://opcfoundation.org/UA/SecurityPolicy#Basic256')
uaclient.uaclient - INFO -   Transport Profile URI: http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary')
uaclient.uaclient - INFO -   Security Level: 32')
uaclient.uaclient - INFO - ')
Title: Re: OPC client with Lazarus
Post by: avra on April 23, 2023, 06:25:05 pm
I am glad you have your Lazarus OPC UA client working now. Now disconnection issue...

Comparing logs, differences seam to be that Ignition has certificate, and that Ignition has security policy Basic256 (with security level 32).

Can you temporary switch off all security in Ignition server and try Lazarus OPC UA client again?

Are Ignition, Python OPC UA client, and Lazarus OPC UA client all on the same physical computer? If not, can you try that and report? How does Python code that connects with success look like?

Maybe you can get an idea related to possibly missing client encryption parameters here: https://github.com/open62541/open62541/tree/master/examples/encryption

If all fails, then you could adapt some open62541 C client example to read a single Ignition tag and if still the same problem discuss it and report on open62541 IRC, mail list, or report an issue.


Btw, it seams that Basic256 has been dropped from OPC UA 1.04, so if open62541 decided to follow it maybe Basic256 is no longer supported and that can be the problem. Try to change security in Ignition and report results.
https://github.com/open62541/open62541/issues/3619
Title: Re: OPC client with Lazarus
Post by: TheMouseAUS on April 23, 2023, 08:41:19 pm
I think I have figured it out. I decided to install wireshark and see if I could see anything out of the ordinary. I saw the issue immediately. open62541 would seem to default to IP v6 where as asyncua for python uses IP v4. As soon as I changed the address from 'localhost' to 127.0.0.1 it connected.

What made me think of this is I knew I could not be security as that security policy was 'None' for anonymous user and the test client was set to no security and it could connect.

localhost:62541

7   1.361425663   ::1   ::1   TCP   94   46204 → 62541 [SYN] Seq=0 Win=65476 Len=0 MSS=65476 SACK_PERM TSval=458882369 TSecr=0 WS=128
8   1.361462140   ::1   ::1   TCP   74   62541 → 46204 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0

127.0.0.1:62541

39   8.175677017   127.0.0.1   127.0.0.1   TCP   74   42252 → 62541 [SYN] Seq=0 Win=65495 Len=0 MSS=65495 SACK_PERM TSval=1879333019 TSecr=0 WS=128
40   8.175759508   127.0.0.1   127.0.0.1   TCP   74   62541 → 42252 [SYN, ACK] Seq=0 Ack=1 Win=65483 Len=0 MSS=65495 SACK_PERM TSval=1879333019 TSecr=1879333019 WS=128

Thank for you help. Now I have to figure out how to read and write data, onto the next step.
Title: Re: OPC client with Lazarus
Post by: Miniekans on May 30, 2023, 01:35:54 pm
Hello,
I have a strange issue with fpopen and Linux.
open62541 v1.3.3 library built with MSVS 2022 on Windows 10 and everything works fine. I can connect to OPC UA server, read and write values. I use built-in fpopen example.

But, on Linux some strange things happens. Not all function from libopen62541.so is working.
I can connect to OPC UA server and read values via UA_Client_readValueAttribute but i cant write because functions like UA_Variant_setScalarCopy, UA_Variant_setInteger, UA_Client_readDataTypeAttribute and others does not working properly. UA_TYPES array items is empty. UA_Copy returns zeros and some garbage in result.

I have done some reads and writes in QT and everything is ok.

Lazarus and Linux new for me, so maybe its my issue. But everything works on Win10 and it confuses me.

Lazarus 2.0.6 (FPC 3.0.4) on Ubuntu 20.04.

Title: Re: OPC client with Lazarus
Post by: alr1976 on August 05, 2023, 04:35:32 pm
Hi!

I have problem to use Client stateCallback. Doesn' t works. It notify me nothing....

 client := nil;
  client := UA_Client_new();

  conf := UA_Client_getConfig(client);
 UA_ClientConfig_setDefault(conf);
  conf^.timeout:= 60000;
  conf^.stateCallback:=@mystatecallback;


procedure mystateCallback(client: PUA_Client; channelState: UA_SecureChannelState; sessionState: UA_SessionState; connectStatus: UA_StatusCode);
begin
   showmessage('ok');
end;

any ideas?
 
Title: Re: OPC client with Lazarus
Post by: lagodnol on March 05, 2024, 07:52:17 am
Has anyone managed to get the wrapper to work correctly in Delphi? Everything works in Lazarus. In Delphi I can connect, read the values, but I can't add a variable on the server and I can't subscribe.
And even when reading values, if I make a second reading request after more than 30 seconds, I get the error: BadSessionIdInvalid.
I suspect there are differences in the configuration structures, but I haven't figured them out in two days.
I would be grateful for any suggestions.
I use the code: https://github.com/fluisgirardi/fpopen62541 (https://github.com/fluisgirardi/fpopen62541)
Win32. Dll version: 1.2-RC2, 1.2.6
Title: Re: OPC client with Lazarus
Post by: lagodnol on March 09, 2024, 07:59:09 pm
Looks like I found the problem. It is related to the optimization of record transfer in Delphi: if the const keyword is specified, the address of the record is transmitted, and not the record itself. It is necessary to remove the const when passing records in imported functions. For example:
Code: [Select]
   UA_Client_Subscriptions_delete: function(client: PUA_Client; const request: UA_DeleteSubscriptionsRequest): UA_DeleteSubscriptionsResponse; cdecl;
should be replaced by
Code: [Select]
   UA_Client_Subscriptions_delete: function(client: PUA_Client; request: UA_DeleteSubscriptionsRequest): UA_DeleteSubscriptionsResponse; cdecl;
TinyPortal © 2005-2018