OPC client with Lazarus lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- vinceducat · 2010-07-18 16:28 Hi i want to know if someone developpe an OPC client With Lazarus. ---------------------------------------------------------------------- felipemdc · 2010-08-08 11:35 What is OPC? ---------------------------------------------------------------------- ahmetnurideniz · 2010-08-12 22:32 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. ---------------------------------------------------------------------- Guzzi · 2013-08-07 11:56 You will find a OPC Client Tool Kit for Delphi and Lazarus at: http://www.dopc.kassl.de It is not free, you have to pay for it. ---------------------------------------------------------------------- avra · 2013-08-08 07:26 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. ---------------------------------------------------------------------- mig-31 · 2013-08-08 08:41 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. ---------------------------------------------------------------------- avra · 2013-08-09 20:34 Quote from: mig-31 on August 08, 2013, 10:41:52 amI 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. QuoteAnyway 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. ---------------------------------------------------------------------- jl · 2015-07-14 06:36 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. ---------------------------------------------------------------------- avra · 2015-07-27 11:24 Quote from: touchring on July 14, 2015, 08:36:42 amIt 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. ---------------------------------------------------------------------- avra · 2016-08-17 09:43 https://sourceforge.net/projects/myopcclient/?source=directory OPC components now exist for Lazarus, too. Unfortunately GPL. ---------------------------------------------------------------------- jl · 2016-08-17 09:52 Quote from: avra on August 17, 2016, 11:43:03 amhttps://sourceforge.net/projects/myopcclient/?source=directory OPC components now exist for Lazarus, too. Unfortunately GPL. It's only OPC DA, still no UA. ---------------------------------------------------------------------- avra · 2016-08-17 10:44 Quote from: touchring on August 17, 2016, 11:52:22 amIt'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. ---------------------------------------------------------------------- ZbynekZ · 2016-09-27 20:44 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) . Disclaimer: This is a self-promotion. ---------------------------------------------------------------------- Daren453 · 2017-05-10 00:24 Did you have issues with opcconnect on the encoding? If so can you tell me the work-around? Thanks, Daren ---------------------------------------------------------------------- LacaK · 2020-06-05 12:33 I have created pascal wrapper to open source http://open62541.org. You can look at https://lacak.sourceforge.io/ for headers and Windows DLL There are also implementations of other industrial communication protocols like Modbus TCP or EtherNet/IP ---------------------------------------------------------------------- avra · 2020-06-05 21:21 Quote from: LacaK on June 05, 2020, 02:33:24 pmI have created pascal wrapper to open source http://open62541.orgI am so happy . 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/pa ckages/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 ---------------------------------------------------------------------- Fred vS · 2020-06-05 21:41 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/ ---------------------------------------------------------------------- avra · 2020-06-05 21:47 Quote from: Fred vS on June 05, 2020, 11:41:41 pmQuote 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. ---------------------------------------------------------------------- Fred vS · 2020-06-05 21:59 QuoteI 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 ---------------------------------------------------------------------- avra · 2020-06-05 22:08 Quote from: Fred vS on June 05, 2020, 11:59:07 pmYou may also download + install last version of mingw-w64, libgcc_s_sjlj-1.dll is included. http://mingw-w64.org/doku.php/downloadI 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. ---------------------------------------------------------------------- Fred vS · 2020-06-05 22:11 QuoteI 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? ---------------------------------------------------------------------- avra · 2020-06-05 23:03 Quote from: Fred vS on June 06, 2020, 12:11:34 amQuoteI 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. ---------------------------------------------------------------------- LacaK · 2020-06-08 05:39 Quote from: avra on June 05, 2020, 11:21:58 pm1) 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 Quote from: avra on June 05, 2020, 11:21:58 pm2) 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. Quote from: avra on June 05, 2020, 11:21:58 pm3) 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 Quote from: avra on June 05, 2020, 11:21:58 pm4) 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 Quote from: avra on June 05, 2020, 11:21:58 pm5) 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/win dows_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 ... ---------------------------------------------------------------------- LacaK · 2020-06-08 10:36 I have added demo application and Win64 DLLs: https://lacak.sourceforge.io/ (Win64 application works, but when closing - UA_Client_delete(client) is called - something goes wrong ...) ---------------------------------------------------------------------- avra · 2020-06-10 12:52 Quote from: LacaK on June 08, 2020, 12:36:30 pmI have added demo application and Win64 DLLs: http://lacak.users.sourceforge.net/Thank you for the effort. It is really appreciated. ---------------------------------------------------------------------- henk86 · 2020-06-15 17:02 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? ---------------------------------------------------------------------- LacaK · 2020-06-16 05:06 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" ---------------------------------------------------------------------- henk86 · 2020-06-16 16:12 Thank you that worked. Now I'm going to figure out how to translate a int16 value correctly. ---------------------------------------------------------------------- Riodev · 2020-06-20 20:29 Quote from: LacaK on June 05, 2020, 02:33:24 pmI 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   scert.Loa dFromFile(ExtractFilePath(Application.ExeName)+'server_cert.der');  kc ert.LoadFromFile(ExtractFilePath(Application.ExeName)+'server_key.der' );  certificate := _UA_STRING(PAnsiChar(scert.Text));  privateKey := _UA_STRING(PAnsiChar(kcert.Text));   UA_ClientConfig_setDefault(conf);  conf^.securityMode:= UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;   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 ---------------------------------------------------------------------- LacaK · 2020-06-22 05:19 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 ---------------------------------------------------------------------- LacaK · 2020-06-22 13:02 Updated headers and Windows DLLs to version 1.1 (open62541 released 06/2020)   (https://github.com/open62541/open62541/releases/tag/v1.1) at https://lacak.sourceforge.io/freepascal.html#open62541 ---------------------------------------------------------------------- Riodev · 2020-06-22 16:13 Quote from: LacaK on June 22, 2020, 03:02:21 pmUpdated 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? ---------------------------------------------------------------------- avra · 2020-06-22 17:14 Quote from: LacaK on June 22, 2020, 03:02:21 pmUpdated 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? ---------------------------------------------------------------------- LacaK · 2020-06-23 05:14 Quote from: Riodev on June 22, 2020, 06:13:14 pmAccess 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(...)) ---------------------------------------------------------------------- LacaK · 2020-06-23 05:22 Quote from: avra on June 22, 2020, 07:14:04 pmWhat 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) Quote from: avra on June 22, 2020, 07:14:04 pmIs 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? ---------------------------------------------------------------------- avra · 2020-06-23 09:55 Quote from: LacaK on June 23, 2020, 07:22:46 amQuote from: avra on June 22, 2020, 07:14:04 pmWhat 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. Quote from: LacaK on June 23, 2020, 07:22:46 amQuote from: avra on June 22, 2020, 07:14:04 pmIs 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. Quote from: avra on June 22, 2020, 07:14:04 pmCurrently 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). ---------------------------------------------------------------------- LacaK · 2020-06-23 12:26 Quote from: avra on June 23, 2020, 11:55:46 amQuote from: LacaK on June 23, 2020, 07:22:46 amQuote from: avra on June 22, 2020, 07:14:04 pmWhat 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/d ownload/v1.1/open62541.h there is present, but in headers included in https://github.com/open62541/open62541/releases/download/v1.1/open6254 1-win32.zip is removed. See commit https://github.com/open62541/open62541/commit/97ce87470c934 23f7adf6b1d8fd87cd8d3252fb3#diff-44b00b50652139af475d451264d49ffd which removes it. ---------------------------------------------------------------------- avra · 2020-06-23 13:43 Quote from: LacaK on June 23, 2020, 02:26:40 pmYes it is strange in ht tps://github.com/open62541/open62541/releases/download/v1.1/open62541. h there is present, but in headers included in https://github.com/open 62541/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. ---------------------------------------------------------------------- LacaK · 2020-06-29 09:32 Quote from: avra on June 23, 2020, 11:55:46 amQuote from: LacaK on June 23, 2020, 07:22:46 amQuote from: avra on June 22, 2020, 07:14:04 pmIs 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) ---------------------------------------------------------------------- avra · 2020-07-01 19:13 Quote from: LacaK on June 29, 2020, 11:32:02 amI have added some server side functionsTHANK YOU !!! ---------------------------------------------------------------------- LacaK · 2020-12-04 18:02 I have added some other functions to header file and extended demo application http://lacak.sourceforge.io/freepascal.html#open62541 ---------------------------------------------------------------------- Lazarus™ · 2021-07-10 13:01 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... ---------------------------------------------------------------------- LacaK · 2021-07-12 11:55 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 ... ---------------------------------------------------------------------- denny.chou · 2021-10-12 03:26 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? ---------------------------------------------------------------------- LacaK · 2021-10-12 05:16 Hard to say without deeper look at source code ... can you provide source code which reads values? ---------------------------------------------------------------------- denny.chou · 2021-10-12 05:38 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  i:Integer;  retval: UA_StatusCode;   Request: UA_ReadRequest;  Response: UA_ReadResponse;  ids: Array[0..2] of UA_ReadValueId;  res: UA_DataValue;  outValue: String;begin  Result:=UA_STATUSCODE_GOOD;  try    UA_ReadRequest_init(Request);    try      ids[0].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13      ids[0].nodeId := UA_NODEID_NUMERIC(5, 6024);    // Custom node on the server       ids[1].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13      ids[1].nodeId := UA_NODEID_NUMERIC(5, 6025);    // Custom node on the server       ids[2].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13    ids[2].nodeId := UA_NODEID_NUMERIC(5, 6026);    // Custom node on the server       UA_ReadValueId_init(ids[0]);      Request.nodesToRead[0].nodeId:= ids[0].nodeId;      Request.nodesToRead[0].attributeId:=ids[0].attributeId;       UA_ReadValueId_init(ids[1]);      Request.nodesToRead[1].nodeId:= ids[1].nodeId;      Request.nodesToRead[1].attributeId:=ids[1].attributeId;       UA_ReadValueId_init(ids[2]);      Request.nodesToRead[2].nodeId:= ids[2].nodeId;      Request.nodesToRead[2].attributeId:=ids[2].attributeId;             Request.nodesToRead:=@ids[0];      Request.nodesToReadSize:=3;       Response:=UA_Client_Service_read(client, Request);      retval:=Response.responseHeader.serviceResult;      if retval=UA_STATUSCODE_GOOD then        if Response.resultsSize<>3 then        begin          UA_clear(@Response, @UA_TYPES[UA_TYPES_READRESPONSE]);          Result:=UA_STATUSCODE_BADUNEXPECTEDERROR;          Exit;        end;       for i:=0 to 2 do      begin        outValue:='';        if Response.results[i].status<>UA_STATUSCODE_GOOD          then continue;         res := Response.results[i];   (*     if Not res.hasvalue then        begin          valueItems.Append('');        break;        end;  *)         if res.value._type=@UA_TYPES[UA_TYPES_INT32] then          outValue:=IntToStr(UA_Variant_getInteger(res.value))        else      if res.value._type=@UA_TYPES[UA_TYPES_INT16] then          outValue:=IntToStr(UA_Variant_getSmallint(res.value))        else      if res.value._type=@UA_TYPES[UA_TYPES_DOUBLE] then          outValue:=UA_Variant_getDouble(res.value).ToString;          valueItems.Append(outValue);      end;    except      //    end;  finally    UA_clear(@Response, @UA_TYPES[UA_TYPES_READRESPONSE]);  end;end; ---------------------------------------------------------------------- denny.chou · 2021-10-12 08:25 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? ---------------------------------------------------------------------- denny.chou · 2021-10-14 03:42 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? ---------------------------------------------------------------------- LacaK · 2021-10-14 17:31 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 ... ---------------------------------------------------------------------- denny.chou · 2021-10-15 06:20 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? ---------------------------------------------------------------------- LacaK · 2021-10-15 16:56 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/mast er/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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i       UA_ReadValueId_init(ids[0]);      ids[0].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13      ids[0].nodeId := UA_NODEID_NUMERIC(5, 6024);    // Custom node on the server       UA_ReadValueId_init(ids[1]);      ids[1].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13      ids[1].nodeId := UA_NODEID_NUMERIC(5, 6025);    // Custom node on the server       UA_ReadValueId_init(ids[2]);      ids[2].attributeId := ord(UA_ATTRIBUTEID_VALUE);  // 13      ids[2].nodeId := UA_NODEID_NUMERIC(5, 6026);    // Custom node on the server       Request.nodesToRead:=@ids[0];      Request.nodesToReadSize:=3; ---------------------------------------------------------------------- denny.chou · 2021-10-20 08:50 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? ---------------------------------------------------------------------- lupus-rain · 2021-10-21 09:04 Quote from: denny.chou on October 20, 2021, 10:50:13 amFinally, 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. ---------------------------------------------------------------------- lupus-rain · 2021-10-25 09:19 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; ---------------------------------------------------------------------- LacaK · 2021-10-26 07:43 Yes, you are right! (probably this was changed in 1.0 -> 1.1 release branch) Thank you! ---------------------------------------------------------------------- denny.chou · 2021-11-02 02:16 Quote from: lupus-rain on October 25, 2021, 11:19:56 amFound 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. ---------------------------------------------------------------------- olivluca · 2021-11-04 11:44 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. ---------------------------------------------------------------------- LacaK · 2021-11-04 16:53 @olivluca: can you please also update definition of record UA_ConnectionConfig in https://github.com/fluisgirardi/fpopen62541/blob/main/open62541.pas as suggested above ... ---------------------------------------------------------------------- denny.chou · 2021-11-23 09:26 Hello, can this also be used to connect opc-da? ---------------------------------------------------------------------- avra · 2021-11-23 21:26 Quote from: denny.chou on November 23, 2021, 10:26:51 amHello, 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 ---------------------------------------------------------------------- denny.chou · 2021-11-24 03:17 Quote from: avra on November 23, 2021, 10:26:18 pm 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 ---------------------------------------------------------------------- denny.chou · 2021-11-24 05:57 "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 ---------------------------------------------------------------------- avra · 2021-11-24 08:14 Quote from: denny.chou on November 24, 2021, 06:57:33 amWhat 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. ---------------------------------------------------------------------- denny.chou · 2021-11-26 03:18 Quote from: avra on November 24, 2021, 09:14:46 amContact 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. ---------------------------------------------------------------------- Чебурашка · 2022-07-06 10:36 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? ---------------------------------------------------------------------- LacaK · 2022-07-23 11:29 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) ---------------------------------------------------------------------- yus · 2022-07-26 18:02 If you need OPC DA. https://github.com/seryal/OPCComponent ---------------------------------------------------------------------- ruedi · 2022-08-02 12:35 Hallo, It is possible to insert several monitored items in one subscription. I would like to subscribe to several variables. ---------------------------------------------------------------------- Чебурашка · 2022-08-25 08:13 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 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 ---------------------------------------------------------------------- Чебурашка · 2022-08-25 08:33 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? ---------------------------------------------------------------------- LacaK · 2022-08-26 11:58 Quote from: tt on August 25, 2022, 10:33:44 amI 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 ? ---------------------------------------------------------------------- Чебурашка · 2022-08-26 12:20 Quote from: LacaK on August 26, 2022, 01:58:51 pmQuote from: tt on August 25, 2022, 10:33:44 amI 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. ---------------------------------------------------------------------- TheMouseAUS · 2023-04-22 00:42 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? ---------------------------------------------------------------------- avra · 2023-04-22 11:47 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. ---------------------------------------------------------------------- TheMouseAUS · 2023-04-22 12:54 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 ---------------------------------------------------------------------- avra · 2023-04-22 20:47 Quote from: TheMouseAUS on April 22, 2023, 02:54:44 pmYes 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$IFDEF UNIX}  libopen62541 = 'libopen62541.so';{$ELSE}  libopen62541 = 'libopen62541.dll'; // GCC libgcc_s_sjlj-1.dll and libwinpthread-1.dll are also required                                     //  they can be downloaded from packages at http://win- builds.org/1.5.0/packages/windows_32/{$ENDIF} Quote from: TheMouseAUS on April 22, 2023, 02:54:44 pmI 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 workingTry this older version compatible with open62541 v1.2: https://github.com/fluisgirardi/fpopen62541/tree/d9132e968d9d050c90225 a493121acb67cdceac3 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/libor to make the change permanent you can add /usr/local/lib to /etc/ld.so.conf and run ldconfig as root. ---------------------------------------------------------------------- TheMouseAUS · 2023-04-22 23:37 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 :-) ---------------------------------------------------------------------- avra · 2023-04-23 00:15 Quote from: TheMouseAUS on April 23, 2023, 01:37:15 amWhen 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. Quote from: TheMouseAUS on April 23, 2023, 01:37:15 amThree 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. ---------------------------------------------------------------------- TheMouseAUS · 2023-04-23 00:34 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. ---------------------------------------------------------------------- TheMouseAUS · 2023-04-23 09:16 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 - ') ---------------------------------------------------------------------- avra · 2023-04-23 16:25 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 ---------------------------------------------------------------------- TheMouseAUS · 2023-04-23 18:41 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. ---------------------------------------------------------------------- Miniekans · 2023-05-30 11:35 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. ---------------------------------------------------------------------- alr1976 · 2023-08-05 14:35 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? ---------------------------------------------------------------------- lagodnol · 2024-03-05 06:52 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 Win32. Dll version: 1.2-RC2, 1.2.6 ---------------------------------------------------------------------- lagodnol · 2024-03-09 18:59 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; ---------------------------------------------------------------------- mrogerf · 2024-04-08 18:51 Quote from: Miniekans on May 30, 2023, 01:35:54 pmHello, 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. How do you could compile fpopen? I tried code from there and got this error: TestOpcUa1.pas(244,23) Error: Unknown record field identifier "memberTypeIndex" ---------------------------------------------------------------------- Thaddy · 2024-04-09 04:52 Can it be that there is a name clash at play here? fpopen is a fpc function in the unix rtl... from baseunix.fpopen? --> resolves to unix open. In that case you can fix that with .fpopen Or rename the other fpopen (since it seems to compile on windows I suspect the name clash, since windows does not use baseunix, so it can use a different fpopen without issue) ---------------------------------------------------------------------- mrogerf · 2024-04-10 17:17 Quote from: Thaddy on April 09, 2024, 06:52:16 amCan it be that there is a name clash at play here? fpopen is a fpc function in the unix rtl... from baseunix.fpopen? --> resolves to unix open. No ... it's not the standard fpopen. It's fpopen62541, a freepascal wraper to open62541 OPC UA C library. Miniekans commented that could successfully compile the example application. But I could not due the errors from my previous post. ---------------------------------------------------------------------- ponsdaniel · 2024-06-18 15:32 Good, I am testing the example in lazarus to connect to an OPC UA server using the libopen62541.dll library. The source code is an example that I have found on the net, that other forums have answered working on linux. Here in windows I can't find the problem because it is not working for me. I have placed the library in the executable folder, I have placed a path in another folder where the library is. But I always get the error. Who can help me? Translated with DeepL.com (free version) ---------------------------------------------------------------------- Truffaldino · 2025-01-23 12:18 Hello, friends! Has anyone managed to make an OPCUA component for Lazarus? The wrapper from this topic is good, but the component is better. ---------------------------------------------------------------------- colddudu49 · 2025-01-29 21:24 Quote from: lagodnol on March 05, 2024, 07:52:17 amHas 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 Win32. Dll version: 1.2-RC2, 1.2.6 Hello, I'm also using the wrapper in Delphi, the test application connect to server but secure channel is closed. connect state after connection : UA_SESSIONSTATE_ACTIVATED/UA_SECURECHANNELSTATE_CLOSED. Can anyone tell me what I am doing wrong? The same code is working fine in Lazarus ---------------------------------------------------------------------- LacaK · 2025-04-11 08:12 You must have also others DLLs there (beside libopen62541.dll): - libgcc_s_sjlj-1.dll, - libwinpthread-1.dll Look at http://win-builds.org/1.5.0/packages/ (gcc and winpthreads package) or https://sourceforge.net/projects/mingw- w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw- builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj- rt_v6-rev0.7z ---------------------------------------------------------------------- TheMouseAUS · 2026-01-09 19:20 Does anyone have a working example of using the library as a client connecting to a server that requires username and password? I cant seem to make it work. I have built open62541.so with encryption support as I read somewhere it must be otherwise authentication does not work but I cannot get much further. Any help would be appreciated. Thanks :-) ---------------------------------------------------------------------- TheMouseAUS · 2026-01-23 03:56 OK I have spent many days trying to figure this out. This is  what I have come to :- Build the library with encryption enabled (I chose OpenSSL). Use create_self-signed.py script to generate the certificate and key for the client with the argument --uri urn:open62541.client The URI in the cert must the same as clientDescription.applicationUri in the client itself. Get the server certificate from your server in .der format,  this needs to be added to the trust list on connection. I was playing around with the examples provided in the open62541 library and I finally got a connection working that sent back the server time. The example provided was ran as follows ./client_encryption opc.tcp://:4840 client_cert.der client_key.der server- certificate.der The code in c is Code: [Select] const char *endpointUrl = argv[1]; /* Load certificate and private key */ UA_ByteString certificate = loadFile(argv[2]); UA_ByteString privateKey  = loadFile(argv[3]); size_t trustListSize = 0; if(argc > MIN_ARGS)     trustListSize = (size_t)argc-MIN_ARGS; UA_STACKARRAY(UA_ByteString, trustList, trustListSize+1); for(size_t trustListCount = 0; trustListCount < trustListSize; trustListCount++)     trustList[trustListCount] = loadFile(argv[trustListCount+4]); UA_ByteString *revocationList = NULL; size_t revocationListSize = 0; UA_Client *client = UA_Client_new(); UA_ClientConfig *cc = UA_Client_getConfig(client); cc->securityMode = UA_MESSAGESECURITYMODE_SIGNANDENCRYPT; UA_ClientConfig_setDefaultEncryption(cc, certificate, privateKey,                                      trustList, trustListSize,                                      revocationList, revocationListSize); UA_ByteString_clear(&certificate); UA_ByteString_clear(&privateKey); for(size_t deleteCount = 0; deleteCount < trustListSize; deleteCount++) {     UA_ByteString_clear(&trustList[deleteCount]); } cc->clientDescription.applicationUri = UA_STRING_ALLOC("urn:open62541.client"); UA_StatusCode retval = UA_Client_connectUsername(client, endpointUrl, "user", "password"); Moving across to Pascal, this is what I ended up with, I get 'Good' as the response and I can now read data from the server. Code: [Select] function LoadStringFromFile(const FileName: string): string; var   FS: TFileStream;   Len: Int64; begin   Result := '';   if FileExists(FileName) then   begin     FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);     try       Len := FS.Size;       SetLength(Result, Len);       FS.Read(Pointer(Result)^, Len);     finally       FS.Free;     end;   end; end; Var certificate, privateKey, TrustList : UA_ByteString;     cc: PUA_ClientConfig;     Client : PUA_Client; begin     certificate := _UA_STRING_ALLOC(LoadStringFromFile('client_cert.der'));     privateKey := _UA_STRING_ALLOC(LoadStringFromFile('client_key.der'));     TrustList := _UA_STRING_ALLOC(LoadStringFromFile('server- certificate.der'));     client := UA_Client_new();     cc := UA_Client_getConfig(client);     cc^.securityMode:= UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;     UA_ClientConfig_setDefaultEncryption(cc, certificate, privateKey, @TrustList, 1, nil, 0);     cc^.clientDescription.applicationUri := _UA_STRING_ALLOC('urn:open62541.client');     res := UA_Client_connectUsername(client, 'opc.tcp://':4840' , 'user', 'password'); end; I hope this helps someone else.