% do this from adcpr, or where raw/ and binfiles/ and gbinfiles/ are 
% starts at the beginning and skips files till it finds a new one to do
%    (could manually set 'redo',1)
% to start later and not see the messages do this:
%
% startfilei = 100
% mk_allgbin
%
% appends error messages to ./gps2gbin.err
%


if (~exist('startfilei', 'var'))
   startfilei = 1;
end


pingpath = 'raw/adcp_pings';
files = dirs(fullfile(pingpath, '*.raw'));

for filei = startfilei:length(files)
   rawfile = files(filei).name;
   rawfilebase = rawfile(1:end-4);
   fprintf('processing file %d out of %d\n', filei, length(files))
   gps2gbin(rawfilebase,'back_to_front',1)
   
   xxx2gbin(rawfilebase, ...           %gyro heading
            'in_fext', 'gps',...
            'out_fext', 'pos',...
            'tim_gbinpath', 'gbinfiles/time',...
            'outfpath',     'gbinfiles/pcode',...
            'xxx_binpath',  'binfiles/pcode')
   xxx2gbin(rawfilebase, ...           %gyro heading
            'in_fext', 'hdg',...
            'out_fext', 'hdg',...
            'tim_gbinpath', 'gbinfiles/time',...
            'outfpath',     'gbinfiles/gyro',...
            'xxx_binpath',  'binfiles/gyro')
   xxx2gbin(rawfilebase, ...           %sound speed
            'in_fext', 'spd',...
            'out_fext', 'spd',...
            'tim_gbinpath', 'gbinfiles/time',...
            'outfpath',     'gbinfiles/sndspd',...
            'xxx_binpath',  'binfiles/sndspd')

   xxx2gbin(rawfilebase, ...           %ashtech attitude
            'in_fext', 'adu',...
            'out_fext', 'adu',...
            'tim_gbinpath', 'gbinfiles/time',...
            'outfpath',     'gbinfiles/adu2',...
            'xxx_binpath',  'binfiles/adu2')

end



%raw/adcp_pings/nbp2001_095_24726.raw has a problem
