TCP connection with external software
3 次查看(过去 30 天)
显示 更早的评论
Hi to everyone!
I'm experiencing some problems when trying to create a communication between Matlab and OpenSees (a sofware that adopts tcl as programming language) using tcp. In particular I'm able to create the connection adopting this simple script:
clear all;clc
tcpipServer = tcpip('127.0.0.1', 30001,'NetworkRole','server');
fopen(tcpipServer);
X=fread(tcpipServer)
After this command, Matlab stands for the output from the software. Thus, to produce the output, I need to execute the software adopting an external command, and then the output from the software is directly retrieved from matlab.
Now, I need to run the software from the same script instead of using an external command, but if I adopt the following command at the end of the previous script:
system(['OpenSees > source ','Model_joint_pop.tcl'],'-echo');
Matlab does not execute the command until the tcp connection is closed, standing for the output from the connection. Since the software is not executed, Matlab stands for the connection until the timeout is reached. In the same way, if I execute the sofware as a first command, the connection is not found from tcl and the software is aborted.
Is there any solution to execute the software right after the creation of the connection (without executing command as sequential) in order to make Matlab to read the output from the same software?
Thank you in advance.
3 个评论
Walter Roberson
2019-7-17
https://blogs.mathworks.com/pick/2017/06/09/launch-and-manage-external-processes-from-matlab/
https://www.mathworks.com/matlabcentral/fileexchange/13851-popen-read-and-write
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!