function trackResults = trackingEntryPoint( pathName, fileName)                          

fprintf( '\n /----------------------------------------------------------\\\n');
fprintf( '/------------------------------------------------------------\\\n' );
fprintf( '||                                                          ||\n'  );
fprintf( '||             GPS Software Receiver in Matlab              ||\n'  );
fprintf( '||            Signal Tracking - FLL/PLL and DLL             ||\n'  );
fprintf( '||       Copyright (c) 2003-2017  David S. De Lorenzo       ||\n'  );
fprintf( '||                     2018-2023    Trimble Inc.            ||\n'  );
fprintf( '||                                                          ||\n'  );
fprintf( '\\------------------------------------------------------------/\n' );
fprintf( ' \\----------------------------------------------------------/\n'  );
%#ok<*AGROW>

%==============================================================================%
%                                                                              %
%   Set pathName and fileName strings                                          %
%                                                                              %
%==============================================================================%
% pathName = 'TestData';
% fileName = 'TestDataFile';


%==============================================================================%
%                                                                              %
%   Load acquisition results from file                                         %
%                                                                              %
%==============================================================================%
load( fullfile(pathName, [fileName '_acqResults']), 'settings', 'acqResults' );
acquisitionShowResults( fileName, acqResults );


%==============================================================================%
%                                                                              %
%   Initialize tracking settings                                               %
%                                                                              %
%==============================================================================%
settings = trackingSettings( settings );

%=== Optional --> provide user-specified changes to primary settings ==========%
if ( exist( fullfile(pathName, [fileName '___settings.m']), 'file' ) == 2)
    run( fullfile(pathName, [fileName '___settings.m']) );
elseif strcmp( fileName, 'TestDataFile' )
    %--- Quick-start for TestDataFile that accompanies this code release -------
    settings.trk.prnToTrack         = [ 3 15 ];     % PRN #
    settings.trk.msToProcess        =   2000;       % [ms]
% elseif 1
    % %--- Quick-start for data w/o a dedicated "settings" file ----------------
    % settings.trk.prnToTrack         = [ 3 15 ];     % PRN #
    % settings.trk.msToProcess        =   2000;       % [ms]
else
    error( 'No user-specified settings were loaded at run-time!!' );
end

%=== Calculate secondary settings =============================================%
fileInfo = dir( fullfile(pathName, fileName) );
settings = trackingSettingsSecondary( settings, fileInfo );


%==============================================================================%
%                                                                              %
%   Open the input data file                                                   %
%                                                                              %
%==============================================================================%
fidIn = fopen( fullfile(pathName, fileName), 'r' );
if ( fidIn ~= -1 )
    fprintf( '\nData file opened successfully:  %s\n', fileName );
else
    error( '***  ERROR OPENING FILE:  %s  ***', fullfile(pathName, fileName) );
end


%==============================================================================%
%                                                                              %
%   Track the signals                                                          %
%                                                                              %
%==============================================================================%
%--- Determine which satellites to track by intersecting the acquired ----------
%    satellites with those included in the tracking settings.
[prnToTrack, ~, acqChannel] = intersect( settings.trk.prnToTrack, ...
                                         [acqResults.prn] );

%--- Loop over receiver tracking channels --------------------------------------
for channelNr = 1:length(prnToTrack)
    
    %=== Main tracking driver ==================================================
    trackResults(channelNr) = trackingDriver( fidIn, settings, ...
                                            acqResults(acqChannel(channelNr)) );
    
end


%==============================================================================%
%                                                                              %
%   Close the input data file                                                  %
%                                                                              %
%==============================================================================%
status = fclose( fidIn );
if ( status ~= -1 )
    fprintf( '\nData file closed successfully:  %s\n', fileName );
else
    error( '***  ERROR CLOSING FILE!!  *** ' );
end


%==============================================================================%
%                                                                              %
%   Show & plot tracking results and save plots to JPEG                        %
%                                                                              %
%==============================================================================%
trackingShowResults( fileName, trackResults );
trackingPlotResults( pathName, fileName, settings, trackResults );


%==============================================================================%
%                                                                              %
%   Save results to disk                                                       %
%                                                                              %
%==============================================================================%
trackingSaveResults( pathName, fileName, settings, acqResults, trackResults );


end
%===============================================================================