Effacer les filtres
Effacer les filtres

Receive, Read and Interpret the Bytes Received via UDP Packets

3 vues (au cours des 30 derniers jours)
PTP
PTP le 23 Fév 2016
Commenté : PTP le 28 Fév 2016
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 commentaires
PTP
PTP le 28 Fév 2016
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
PTP
PTP le 28 Fév 2016
Here is the wireshark file that I have attached and also the errors:

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by