필터 지우기
필터 지우기

TCP connection with external software

조회 수: 4 (최근 30일)
Marco Gaetani d'Aragona
Marco Gaetani d'Aragona 2019년 7월 17일
댓글: Walter Roberson 2019년 7월 17일
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
Marco Gaetani d'Aragona
Marco Gaetani d'Aragona 2019년 7월 17일
편집: Marco Gaetani d'Aragona 2019년 7월 17일
Hi thank you for the response.
I need to run the software from Matlab and, then, to retrieve and elaborate the output in Matlab. The problem is that Matlab doesn't run a second command (run the external software) before the first is completely terminated (open tcp). Could you please send me the link to the file exchange page? Thanks
Walter Roberson
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!

Translated by