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

2 vues (au cours des 30 derniers jours)
Kyriakos
Kyriakos le 15 Mar 2023
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 commentaire
HimeshNayak
HimeshNayak le 16 Mar 2023
“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?

Connectez-vous pour commenter.

Réponses (1)

Sai Sumanth Korthiwada
Sai Sumanth Korthiwada le 31 Mar 2023
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!

Tags

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by