필터 지우기
필터 지우기

Matlab : Telnet to remote machine not successful

조회 수: 4 (최근 30일)
Siva Meduri
Siva Meduri 2024년 6월 24일
답변: Aneela 2024년 7월 24일
tCmd = tcpip("10.232.133.147", 5023);
fopen(tCmd);
fwrite(tCmd,':SOUR:POW:AMPL -63 DBM ' );
fclose(tCmd);
I also tried with tcpclient in place of tcpip , still telnet is unsuccesful to remote machine
  댓글 수: 4
Siva Meduri
Siva Meduri 2024년 6월 25일
편집: Walter Roberson 2024년 6월 25일
Even I gave \n in fprintf , I am not able to send command to server appropriately. Please share what I am missing.
t = tcpip('10.232.133.147', 5023);
set(t, 'InputBufferSize', 30000);
fopen(t);
command =':SOUR:POW:AMPL -63 DBM'
fprintf(t, "%s\n", command);
pause(1)
while (get(t, 'BytesAvailable') > 0)
t.BytesAvailable
DataReceived = fscanf(t)
end
fclose(t);
Walter Roberson
Walter Roberson 2024년 6월 25일
Possibly the other side needs \r\n ?

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

답변 (1개)

Aneela
Aneela 2024년 7월 24일
Hi Siva,
I am able to create a server which accepts TCP connections using the following code in MATLAB R2023b.
tCmd = tcpclient("127.0.0.1", 5023);
command = 'ls\n';
write(tCmd, uint8(command));
pause(1);
if tCmd.NumBytesAvailable > 0
response = read(tCmd, tCmd.NumBytesAvailable, "uint8");
disp(char(response'));
else
disp('No response received from the server.');
end
clear tCmd;
I have configured the server to respond with a “Hi” message, received a response saying “Hi” when the request is sent from MATLAB client.
I suggest you ensure that the server is handling the client requests appropriately.
Also, I recommend using “tcpclient” as “tcpip” will be deprecated in the future releases.

카테고리

Help CenterFile Exchange에서 Programming Utilities에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by