Receive, Read and Interpret the Bytes Received via UDP Packets

Hello Everyone,
I have two nodes connected and continously communicating via UDP Sockets.
I tried with fscanf(udp) and fread commands but I got the following error: "Warning: Unsuccessful read: The specified amount of data was not returned within the Timeout period."
I changed the DatagramTerminateMode to be off. Do I have to set the buffer size or any other property, and if yes then how? I would really appreciate any help.
Regards

3 Commenti

How large are your packets and how quickly are they being sent? Are you sending termination characters with the packets?
Hello Walter,
on First laptop PTP daemon is running which sends packets continously to the another laptop where I want to receive these. Messages are normally 86 bytes on Wire and are sent with a very high frequency which means i receive 1000 of packets in a short time. I have confirmed it by Wireshark software.
I also tried using callback functions if at all I am able to receive and read the packets sent.
My mainM file
u1 = udp('192.168.2.10',320,'LocalPort',320);
u1.InputBufferSize = 1024;
u1.DatagramTerminateMode = 'on';
u1.DatagramReceivedFcn = {@callback_u1};
fopen(u1);
My callback_u1 function file
function output = callback_u1(obj, event)
disp('data received')
[data,count,errmsg] = fread(u1,64,'uchar');
But sometimes nothing happens at all as if no packets are received which is not true and sometimes i get *error messages like:
data received undefined function or variable 'u1'
Error in callback_u1(line 4)
Error in instrcb(line 36)
Warning: The DataReceivedFcn is being disabled. To enable the callback property either connect to the hardware with FOPEN or set the DataReceivedFcn property.*
I still do not know what I am doing wrong. Everything seems to be in place. Only i am not able to read the packets in Matlab. Please help me with this.
Kind regards
Here is the wireshark file that I have attached and also the errors:

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Instrument Control Toolbox in Centro assistenza e File Exchange

Richiesto:

PTP
il 23 Feb 2016

Commentato:

PTP
il 28 Feb 2016

Community Treasure Hunt

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

Start Hunting!

Translated by