Borrar filtros
Borrar filtros

Not receiving all UDP datagrams - Problem processing received Data

1 visualización (últimos 30 días)
I am trying to receive sensor values of a Linux machine in realtime (or at least close to it) - so I wrote a C programm sending around 16.000 values/second to an UDP socket.
Now I am trying to read this data continuosly in MatLab and for that, I thought a DatagramReceivedFcn is the best approach.
But I am encountering a problem where I dont receive any more datagrams after around 10-20 (it just stops receiving them), although the server is sending many more datagrams to the socket.
Also I didn't find a way yet to store the received data for further processing (plotting, write it to a SQL database) as the data doesn't show up in the base workspace.
The Code I am currently testing with is the following:
%% Specify a Server (host name or IP address) with Port 8080
u = udp('', 8080); %UDP Object
u.InputBufferSize = 1024;
u.ReadAsyncMode = 'continuous';
u.DatagramReceivedFcn = @DatagramReceivedFcn;
u.DatagramTerminateMode = 'on';
u.Terminator = '!';
%% Open connection
if (~strcmp(u.Status,'open'))
NetworkError(u,'Connection failed!');
%% Start Data transmission by trigger
fprintf(u, 'Requesting Data')
%% Callback Function
function DatagramReceivedFcn(u,~)
datagram = fscanf(u);
disp('Data Received!');
Hope you can help me - thanks in advance!

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by