Open sebastien-rosset opened 1 month ago
In addition, the "Local GNSS Clock" is wrong after the GPS watchdog timemout. In the attached screenshot, the time is stuck at "18:00:00 LCL". It should display something like "---" or string showing GNSS date is not available.
Describe the bug The displayed sunrise/sunset times are sometimes wrong. It seems to occur immediately after a GPS watchdog timeout.
To Reproduce Steps to reproduce the behavior:
Expected behavior The sunrise/sunset times should be displayed correctly. If the program is unable to calculate the time, it should not display an invalid date.
Screenshots
I've added some debugging to troubleshoot the problem. It looks like after a GPS watchdog timeout, the
m_dt
variable is set to January 1st 1970, and that causes sunrise/sunset calculation errors.Desktop (please complete the following information if applicable):
Additional Context: Here are some findings based on troubleshooting/debugging:
Immediately after a GPS watchdog time, the
void DashboardInstrument_Sun::SetUtcTime(wxDateTime data)
function is invoked with the epoch date/time. The code sets them_dt
variable to the epoch time, and that variable is used to calculate the sunrise/sunset.https://github.com/OpenCPN/OpenCPN/blob/41173d9eb6d911472a3a1b1b76a454ce9f527f0c/plugins/dashboard_pi/src/clock.cpp#L328
The time is set to
1969-12-31T16:00:00
at this line after the GPS timeout: https://github.com/OpenCPN/OpenCPN/blob/41173d9eb6d911472a3a1b1b76a454ce9f527f0c/plugins/dashboard_pi/src/dashboard_pi.cpp#L3120The
m_fixtime
is set to 0, with a code comment that states it "invalidates fix time". However0
is a valid date, sowxDateTime.IsValid()
returns true when the milliseconds since epoch is set to 0: https://github.com/OpenCPN/OpenCPN/blob/ba6e2330330c607dcfdacaa9119a7f476beb0d9e/gui/src/ocpn_frame.cpp#L5066