How to transfer Data Between Two Computers Using GUI MATLAB

4 views (last 30 days)
I'm in progress the projet for graduating about ANPR relating to transferring data between 2 computer, I tried to use UDP in Command prompt, it's OK. However, When I write in .m flie or in GUI, it always shows error timeout: Warning: A timeout occurred before the Terminator was reached.
ans =
''
How do I fix this error?
Thank you very much.
My file:
In first computer:
%these values to be those of your first computer:
ipA = '192.168.1.7'; portA = 9090;
%these values to be those of your second computer:
ipB = '192.168.1.4'; portB = 9091;
%%Create UDP Object
udpB = udp(ipA,portA,'LocalPort',portB);
%%Connect to UDP Object
fopen(udpB)
fscanf(udpB)
In second computer:
%%Define computer-specific variables
ipA = '192.168.1.7'; portA = 9090 % Modify these values to be those of your first computer.
ipB = '192.168.1.4'; portB = 9091; % Modify these values to be those of your second computer.
%%Create UDP Object
udpA = udp(ipB,portB,'LocalPort',portA);
%%Connect to UDP Object
fopen(udpA)
fprintf(udpA,'number two.')
  5 Comments
Kevin Bartlett
Kevin Bartlett on 17 Mar 2021
@leo, sorry to hijack this question thread, but I want @Samuel Gray to see this message. Samuel, you sent me a message today, but I am unable to respond because you apparently do not have "Allow users to contact me securely" selected in your community profile (there is no "Contact" button displayed above the "Badges" section of your author page).
Samuel Gray
Samuel Gray on 18 Mar 2021
um, thank you sir, but I believe the problem was not in my personal config, but in the fact that there was no clear way to make additional comments in the thread for which I sent that email to you.

Sign in to comment.

Accepted Answer

leo
leo on 11 Apr 2013
Edited: leo on 11 Apr 2013
I have increased Timeout=60; // in second But it still warrant error Timeout? Who can help me, please?

More Answers (1)

Samuel Gray
Samuel Gray on 4 Mar 2021
Edited: Samuel Gray on 18 Mar 2021
fprintf(udpA,'number two.')
what exactly is your terminator
[hint: add a \l or a \n to the above string]
if you use get(hpipe) it will tell you what it expects to see as a terminator for string data, it is timing-out because it's not seeing the terminator
I realize this is almost 10 years old now but still I'm trying to get UDP comm to work in Matlab right now and it is NOT WORKING..I've got TCP to work using matlab as a client butnow I'm trying to get udp to work as a server. It really should not be this difficult.
It should say in the documentation, set the local and remote ports to the same value, set the local ID if you're receiving udp packets and the remote IP if you're sending them, use fopen and fprintf and fscanf and it should send a string with no problem.
Use fwrite and fread and it should send binary data with no problem.
It's clearly not that simple.
  2 Comments
Oscar Parra
Oscar Parra on 3 May 2021
I have a similar problem, have you been able to solve it and make the communication?
Samuel Gray
Samuel Gray on 3 May 2021
I have not really looked at UDP much since I posted that, but I hvae had enough success with TCP transfers in R2020a/b in Matlab to be comfortable with it so for now I have just worked with TCP. I Googled some 2 or 3 line examples of UDP in Matlab out of many examples on mathworks and in C that you might want to start with searching on stackoverflow.com, also remember that UDP transfers datagrams, which are blocks of data of a fixed size. Not TCP-like packets, no handshaking. I'm sure that they both can be configured in many ways but generally that's what is used. Also UDP has a text/binary issue that I'm hoping to get around with Matlab.
This should be a lot easier than programming it in C/C+.
It's not because there are so many more examples of it in C/C++ than in Matlab.
Even a fair amount in Python.
And in Matlab there are "old" and "new" code examples, Java junk and useful non-Java stuff [I thought that Java was such a security risk that it had been phased out], and a proclivity for setting-up examples that are just running the client and server on the same machine, which is a useless example unless you're doing IPC...it is very easy to get these examples to work on the same machine. The trouble is getting them to work on different machines as the IP stack is very touchy about how the threads are managed.
I can only tell you that I've spent some weeks working on this in Matlab and got to the point that I needed to get to and moved on. It's a learning process but eventually you'll get it to work.

Sign in to comment.

Categories

Find more on Performance and Memory in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!