필터 지우기
필터 지우기

no matter what i do i get this error: (line 17) fopen(server);

조회 수: 2 (최근 30일)
Kyriakos
Kyriakos 2023년 3월 15일
답변: Sai Sumanth Korthiwada 2023년 3월 31일
this is the part of my code i get the error
% Set up TCP/IP server for receiving data
server = tcpip('0.0.0.0', 12345, 'NetworkRole', 'server');
server.InputBufferSize = N;
server.Timeout = 30;
fopen(server);
% Wait for client connection
disp('Waiting for client connection...');
while server.BytesAvailable == 0
pause(0.1);
end
disp('Client connected.');
% Set up TCP/IP client for sending data
client = tcpip('localhost', 12345, 'NetworkRole', 'client');
client.OutputBufferSize = N;
fopen(client);
% Transmit and receive data between client and server
T_near_edge = transmit_and_receive_data(T_sensor, client, server, N);
% Close TCP/IP server and client
fclose(server);
fclose(client);
delete(server);
delete(client);
  댓글 수: 1
HimeshNayak
HimeshNayak 2023년 3월 16일
“fopen” tells it to wait until a connection is requested. After the “fopen” there will be a connection unless the attempt fails.
Could you share the exact error you are receiving?

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

답변 (1개)

Sai Sumanth Korthiwada
Sai Sumanth Korthiwada 2023년 3월 31일
Hi Kyriakos,
I understand that you are facing an issue with 'fopen()'. As per the shared code, you are using 'tcpip()' and 'fopen()' methods.
Use 'tcpclient()' to create a TCP/IP client that connects to a server or hardware and perform read and write operations.
'tcpip()' will be removed in a future release. Please use tcpclient or tcpserver instead. For more information on updating your code, see Compatibility Considerations.
And create 'tcpip' client using: Create TCP/IP Client and Configure Settings
Also, 'fopen(obj)' function will be removed in a future release. Use serialport object functions instead. For more information on updating your code, see Compatibility Considerations.
Hope this helps!

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by