MATLAB Answers

0

Why do I stop receiving UDP data sent over Ethernet?

Asked by Matt Flood on 27 Aug 2019
I have two laptops, each recording data from separate instruments using TCP/IP. In order to time-synchronize the data collected from both laptops, I must send a signal (trigger) from one laptop to the other. To do this, one computer sends a UDP packet containing a 1 or 2, which is read in from the ethernet port (2222) on the other computer through a MatLab UDP object. Once received, I know when both data recodings begin/end.
Sometimes all will work fine, sometimes the UDP packets stop receiving after the first trigger, sometimes nothing is received at all. As far as I can tell, the first laptop is sending the triggers correctly, and on the other laptop, the ethernet port is always open and the UDP object listening to it.
There appears to be no consistent pattern leading to this issue - opening one laptop before the other, sending triggers repeatedly, etc.
Every time that I set up the UDP object, I make sure that all previously open/connected ports are closed and workspace variables/objects are deleted and cleared.
fclose(Data); % Data = TCP/IP object for data recording
fclose(Trigger); % Trigger = UDP object for receiving trigger value (1 or 2)
delete(Data);
delete(Trigger);
clear Data Trigger
I also use instrreset to refresh the ports.
instrreset
I am aware that UDP is not a reliable protocol to transmit data, but the random failure to receive data using the MatLab UDP object is baffling...
Any help would be greatly appreciated!

  0 Comments

Sign in to comment.

0 Answers