Open an ethernet connection

31 vues (au cours des 30 derniers jours)
dsq dq
dsq dq le 30 Juil 2021
Réponse apportée : dsq dq le 17 Août 2021
Hey everyone ! :)
I am currently trying to open an Ethernet connection with matlab. Because I'm quite new in Matlab programming, my program is not working. Here is what I've done :
echotcpip("on",2049);
t = tcpclient("192.168.10.94", 2049);
message_to_send = "11009¶1¶1";
write(t,message_to_send);
data = read(t,10);
clear t;
echotcpip("off");
I know the message to send is quite strange, but this is the logic of the external device. I'm 100 % sure that the IP adress and the port number are good. I tried to open the connection with Putty and it worked well, but now I'm trying with Matlab it timeout when it's supposed to read the data from the external device. Is my program wrong or I'm stupid and my error is somewhere else ?
Thanks you very much in advance !

Réponses (1)

dsq dq
dsq dq le 17 Août 2021
Hey everyone,
I'm back from vacation and now I've got this :
IP= '192.168.10.94';
port = 2049;
tcpipObj=tcpip(IP, port);
fopen(tcpipObj);
tcpipObj.Terminator = 'CR/LF';
fprintf(tcpipObj,'11009¶1¶1');
A = fread(tcpipObj,500,'char') ;
A = char (A);
fclose(tcpipObj);
The external device answer, but it takes to much time and I have this warning :
'Warning: The specified amount of data was not returned within the Timeout period.
'tcpip' unable to read all requested data. For more information on possible reasons, see TCPIP Read Warnings. '
I didn't find the solution on Internet and I really know why ... Nobody knows how to fix it ? :(

Community Treasure Hunt

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

Start Hunting!

Translated by