Matlab executable throws error in opc.ua.Client

I used MATLAB Compiler (2022b) to deploy a small algorithm that grabs data over the matlab opc-ua interface. So i used the icomm\opc...On the computer where i have all the toolboxes the executeable can be run without throwing an error. But when i run it on another computer, where i installed the 2022b runtime i get the following error-stack:
file: C:\Programm Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\icomm\opc\opc\+opc\+ua\Client.m
name: Client.Client
line: 386
I tried it on severals pc´s, only when there is also a matlab license of the toolbox containing the opc-ua it works.
Can someone please give me a hint how i can solve the problem.

댓글 수: 4

From the fact that the error stack mentions the MCR, I'm guessing you're not using MATLAB Coder to generate C or C++ code from your application but that you're using MATLAB Compiler to generate a standalone application. Can you confirm that my guess is correct?
Something else that supports my guess is the fact that the documentation page for the opcua function does not list "C/C++ Code Generation" as an extended capability, suggesting to me that it is not supported for use with MATLAB Coder.
If I'm correct, how are you creating the object or getting it into your application? Are you perhaps calling load to load a MAT-file containing a previously created object into your application?
Thank you, you are absolutely right. I create a standalone application with MATLAB Compiler. --> I will correct my question.
What do you mean with how i create the object? The opc-ua object is not stored in a mat file. The configuration of the OPC-UA is done via loading json-files. The opc-ua connection is created within a method of a class that i directly use in my function.
Can you show the code for the method in which you create the opc-ua connection?
I just use the connect function of matlab.
Here is the code:
obj.client = opcua(hostname,portNr);
obj.client.setSecurityModel('None')
%Connect client to server
connect(obj.client);
One additional information: I checked the availability of the opc-ua server with UA-Expert on all computers when i tried to run the exe-file. So, the connection is OK (checked with UA-Expert), but on every computer i´ve tried to run it with the mcr 2022b, the error above was thrown. The line 386 of the error suggests a wrong server, port or datatype of these parameters, but they are read out by the same json-file as on the computer where is runs without any trouble.

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2024년 9월 8일
편집: Image Analyst 2024년 9월 8일

0 개 추천

Try including that file explicitly in your compilation, something like
mcc yourapp.m -a " C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\icomm\opc\opc\+opc\+ua\Client.m"
but actually you must change the path to what it is on your computer, not the target computer, so it will find it.

댓글 수: 4

Thank you for your hint.
Unfortunately, this does not solve the problem. The new exe-file runs on the computer where i generated/deployed it, but it throws the above error on another where only the mcr is installed. On both i checked the opc-ua connection with the UA-Expert.
Search the whole hard drive for Client.m. Also search the hidden CTF folder. For example C:\Users\MyUserName\AppData\Local\Temp\MyUserName\mcrCache7.16\MyApp\.
Thank you for your answer and the interesting link.
I found 2 files called Client.m on different paths inside the MATLAB folder of the target computer:
  1. C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\icomm\opc\opc\+opc\+ua\Client.m
  2. C:\Program Files\MATLAB\R2022b\mcr\toolbox\icomm\opc\opc\+opc\+ua\Client.m
A binar comparison shows differences in those files...
I also found a link in the CTF folder which links to the 1. file.
I tried the dependency walker but, to be honest, i cannot read out anything from the detected erros, which name some missing dll-files.
I don't know what that thing is. It's not something that shows up as an applet inside MATLAB is it? Does it have it's own GUI? Because I think applets on the Apps tab of the tool ribbon cannot be included in a standalone executable. Otherwise I'd try to recompile with the latest R2024a and try that. If that doesn't work, call tech support.

댓글을 달려면 로그인하십시오.

Stefanie Schwarz
Stefanie Schwarz 2024년 9월 16일

0 개 추천

The error in line 386 of "opc.ua.Client" indicates that there might be an issue with resolving the OPA UA endpoint hostname. See the following MATLAB Answer for more info:

카테고리

도움말 센터File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2024년 9월 6일

답변:

2024년 9월 16일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by