% (c):          Joan Vila Carbó

function [index,data]=UDPreceiveDATA(port)
persistent recv_pkt;
if (isempty(recv_pkt))
    recv_pkt = java.net.DatagramPacket(uint8(zeros(1,1085)), 1085);
end
rsock = java.net.DatagramSocket(port);
rsock.receive(recv_pkt);
rsock.close();

recv_data=recv_pkt.getData();

n=recv_pkt.getLength();
i=0;
for j = 6:36:n
    i=i+1;
    index_bytes=recv_data(j:j+3);
    index(i)=typecast(index_bytes,'uint32');
    for k=1:8
        data_bytes = recv_data(j+4*k:j+4*k+3);
        data((i-1)*8+k)=typecast(data_bytes,'single');
    end
end