function [utc] = parseNSTButc(fid);
%---------------------------------------------------------
% parse NSTB message type 31 (utc)
% Ju-Yong Do,  Jan 22, 2009
%---------------------------------------------------------
% input  : NSTB file indicator
% output : UTC message in "utc"
%=========================================================
%=========================================================
global rx option

%read header
receiverId      = fread(fid, 1, 'uint16');
gpsweek         = fread(fid, 1, 'uint16');
utc.tow         = fread(fid, 1, 'uint32')*1e-3; %time of validity in time of week (ms->sec)

%=========================================================
%read utc message
utc.a0          = fread(fid, 1, 'uint32')*2^-30;%UTC offset coef (sec)
utc.a1          = fread(fid, 1, 'uint32')*2^-50;%UTC offset coef (sec/sec)
utc.dtls        = fread(fid, 1, 'uint8');       %delta time due to leap seconds (sec)
utc.tot         = fread(fid, 1, 'uint8')*2^12;  %reference time for UTC (sec)
utc.wnt         = fread(fid, 1, 'uint8');       %reference week number for UTC (weeks)
utc.wnlsf       = fread(fid, 1, 'uint8');       %effectivity reference week number (weeks)
utc.dn          = fread(fid, 1, 'uint8');       %effectivity reference day number (days)
utc.dtlsf       = fread(fid, 1, 'uint8');       %delta time at leap seconds event (sec)

%stack up what's collected
rx.aiding.utc       = [rx.aiding.utc utc];

%=========================================================
% CRC test for sanity check
crcTestNSTB(fid, 9, 14, 2); %(fid,headLen,bodyLen,tailLen)

if option.plot,             
    disp('=======MESSAGE 30 UTC=======================================');
    disp(['tow= ',num2str(utc.tow),' sec']); 
end

return
%=========================================================
%=========================================================
