Replace the clock calibration with a fixed epoch
Currently the date/time parsing assumes the reference time (epoch) of
the device clock is unknown. Hence we retrieve the current time of the
device (devtime) and the host system (systime) during the download.
Since both timestamps represent the same instant in time, but with a
different reference time, we can calibrate the device clock as follows:
ticks = parser->systime - (parser->devtime - timestamp) / 2
But this produces wrong results once the device clock has been adjusted
manually. Adjusting the device clock will suddenly increase (or
decrease) the devtime, while the systime continues ticking forwards
normally. Hence all dives recorded before the time adjustment will get
an incorrect date/time value.
Fortunately all devices appear to use a fixed epoch (2000-01-01 00:00:00
UTC) and we can simply replace the calibration with a hardcoded value.
Reported-By: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
7f2384d665
commit
a196255841
@ -64,6 +64,8 @@
|
||||
#define GAUGE 0x00001000
|
||||
#define SALINITY 0x00100000
|
||||
|
||||
#define EPOCH 946684800 // 2000-01-01 00:00:00 UTC
|
||||
|
||||
typedef enum {
|
||||
PRESSURE_DEPTH,
|
||||
RBT,
|
||||
@ -723,7 +725,7 @@ uwatec_smart_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime
|
||||
|
||||
unsigned int timestamp = array_uint32_le (abstract->data + 8);
|
||||
|
||||
dc_ticks_t ticks = parser->systime - (parser->devtime - timestamp) / 2;
|
||||
dc_ticks_t ticks = EPOCH + timestamp / 2;
|
||||
|
||||
if (table->timezone != UNSUPPORTED) {
|
||||
// For devices with timezone support, the UTC offset of the
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user