%close all
%clear all

%global P;
%global count;

function SurfaceLogFileDecoderRing(path,filename,results_path)
%path = 'X:\707976 EPBuoyPrototypeAndTesting\Deployments\Nov2012 Deployment\134.89.12.189\data\R00001\';
%filename = 'D000021_121113_142331';

%results_path = 'X:\707976 EPBuoyPrototypeAndTesting\Deployments\Nov2012 Deployment\DecodedResults\';

grav = 9.81;  %m/s^2
epoch_serialdate = datenum(1970,1,1,0,0,0);

[DataSize S] = PacketDefinition;



  fid = fopen([path filename]);
  count = DataSize;
  ii = 0;
  while (count == DataSize)
    ii = ii+1
    [A, count] = fread(fid,DataSize);
    if(count == DataSize)
       P = ParseRawData(uint8(A),S);
       Eng = ScaleData(P,S);
       names = fieldnames(Eng);
       for jj = 1:length(names)
          eval([names{jj} '(ii) = Eng.' names{jj} ';']);
       end
    end
  end
  fclose(fid);

  save([results_path filename])
 
  clear P Eng
  


