SIMULINK Attempt to extract field 'ConnectTCPIP' from 'mxArray'.
Show older comments
Hello, I am trying to connect a PI Hexapod Robot via TCPIP by SIMULINK MATLAB Function. For this purpose following code has been written.
function y =fcn(a)
coder.extrinsic('PI_GCS_Controller')
persistent Controller
if isempty(Controller)
Controller = PI_GCS_Controller();
ip = '169.254.10.196';
port = 50000;
Controller = Controller.ConnectTCPIP(ip, port);
end
y=a+5;
end
I do not encounter any problem when I try MATLAB instead of SIMULINK. However, when trying on SIMULINK MATLAB Function with the code above, following error shows up:
Attempt to extract field 'ConnectTCPIP' from 'mxArray'.
The solution is recommended as preinitializing the variable. But I already initialized "Controller" as "PI_GCS_Controller()". So I do not understand the problem. "ConnectTCPIP" function is inside the "@PI_GCS_Controller" folder which is at the Current folder of MATLAB.
If needed, the "ConnectTCPIP" function written by PI is as follows:
if(~libisloaded(c.libalias))
c = LoadGCSDLL(c);
end
FunctionName = 'PI_ConnectTCPIP';
if(any(strcmp(FunctionName,c.dllfunctions)))
try
[c.ID] = calllib(c.libalias,FunctionName,szHostName,nPort);
if(c.ID<0)
iError = GetError(c);
szDesc = TranslateError(c,iError);
error(szDesc);
end
catch
rethrow(lasterror);
end
else
error('%s not found',FunctionName);
end
Why do I get error? Thanks in advance..
Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!