Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix issues with time the time offset #29

@TMBell05

Description

@TMBell05

Decode time in this way:


        % Modified to compute the UTC time at boot up

                % Search for first recorded GPS timestamp when GPS got satellites locked in
                I = max(find(GPS_col.GWk, 1, 'first'), find(GPS_col.GMS, 1, 'first'));
                
                % Extract GPS and System time
                recv_timeUS = GPS_col.TimeUS(I);
                recv_GWk = GPS_col.GWk(I);
                recv_GMS = GPS_col.GMS(I);
                
                % Calculate the gps-time datenum
                %  Ref: http://www.oc.nps.edu/oc2902w/gps/timsys.html
                %  Ref: https://confluence.qps.nl/display/KBE/UTC+to+GPS+Time+Correction
                gps_zero_datenum = datenum('1980-01-06 00:00:00.000','yyyy-mm-dd HH:MM:SS.FFF');
                days_since_gps_zero = recv_GWk*7 + recv_GMS/1e3/60/60/24;
                recv_gps_datenum = gps_zero_datenum + days_since_gps_zero;
                % Adjust for leap seconds (disagreement between GPS and UTC)
                leap_second_table = datenum(...
                    ['Jul 01 1981'
                     'Jul 01 1982'
                     'Jul 01 1983'
                     'Jul 01 1985'
                     'Jan 01 1988'
                     'Jan 01 1990'
                     'Jan 01 1991'
                     'Jul 01 1992'
                     'Jul 01 1993'
                     'Jul 01 1994'
                     'Jan 01 1996'
                     'Jul 01 1997'
                     'Jan 01 1999'
                     'Jan 01 2006'
                     'Jan 01 2009'
                     'Jul 01 2012'
                     'Jul 01 2015'
                     'Jan 01 2017'], 'mmm dd yyyy');
                leapseconds = sum(recv_gps_datenum > leap_second_table);
                recv_utc_datenum = recv_gps_datenum - leapseconds/60/60/24;
                % Record adjusted time to the log's property
                boot_time_utc = recv_utc_datenum - recv_timeUS/1e6/60/60/24;

                % Put a human-readable version in the public properties
                boot_date = datestr(boot_time_utc, 'yyyy-mm-dd HH:MM:SS');
end```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions