function [P] = ParseRawData(raw_data,S)


names = fieldnames(S);
j = 1;
for i = 1:length(names)
   switch class(S.(names{i}))
       case 'uint32'
           P.(names{i}) = typecast(raw_data(j+3:-1:j),'uint32');
           j = j+4;
       case 'int32'
           %names{i}
           %raw_data(j+3)
           %raw_data(j+2)
           %raw_data(j+1)
           %raw_data(j)
           P.(names{i}) = typecast(raw_data(j+3:-1:j),'int32');
           j = j+4;
       case 'uint16'
           P.(names{i}) = typecast(raw_data(j+1:-1:j),'uint16');
           j = j+2;
       case 'int16'
           P.(names{i}) = typecast(raw_data(j+1:-1:j),'int16');
           j = j+2;
       case 'double'
           P.(names{i}) = typecast(raw_data(j+7:-1:j),'double');
           j = j+8;
       case 'single'
           P.(names{i}) = typecast(raw_data(j+3:-1:j),'single');
           j = j+4;    
       otherwise 
           error('Unknown type in "ParseRawData"');
   end
end

