comparison Discovery/Src/settings.c @ 319:d8e86af78474 fix-version

bugfix: correct packed main version number in dive header This fixes a rather mysterious bug. Users report that up to 1.3.5 beta, a correct version number is shown in libdivecomputer based applications (like in Subsurface, in the extra data tab). Careful examining the code in both libdivecomputer and the firmware shows a subtle error in the bit mask and shift operation to pack a full X.Y.Z.beta version number in 2 bytes (as is available in the dive header) in the firmware end (as the libdivecomputer code looks sane, assuming this is the right way to pack things). Likely, this bug crept in in the conversion from the closed source Keil period into the open source GCC setup of the code base. So its impossible to document the exact history of this problem here. Further notice that the main version number is only 1 of 3 version numbers, denoting the full version of the firmware (besides Font and RTE). Finally notice that this way of packing is limited to 2^5 bits (decimal 32), so we could easily build a 1.4.21, but not a 1.4.55. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Wed, 19 Jun 2019 14:31:50 +0200
parents 733877ab87d9
children d4d8d717e9a7
comparison
equal deleted inserted replaced
313:49f5db6139d5 319:d8e86af78474
1389 } 1389 }
1390 1390
1391 1391
1392 uint8_t firmwareVersion_16bit_high(void) 1392 uint8_t firmwareVersion_16bit_high(void)
1393 { 1393 {
1394 return ((firmware_FirmwareData.versionFirst & 0x1F) << 3) + ((firmware_FirmwareData.versionSecond & 0x1C) >> 5); 1394 return ((firmware_FirmwareData.versionFirst & 0x1F) << 3) + ((firmware_FirmwareData.versionSecond & 0x1C) >> 2);
1395 } 1395 }
1396 1396
1397 uint8_t firmwareVersion_16bit_low(void) 1397 uint8_t firmwareVersion_16bit_low(void)
1398 { 1398 {
1399 return ((firmware_FirmwareData.versionSecond & 0x03) << 6) + ((firmware_FirmwareData.versionThird & 0x1F) << 1) + (firmware_FirmwareData.versionBeta & 0x01); 1399 return ((firmware_FirmwareData.versionSecond & 0x03) << 6) + ((firmware_FirmwareData.versionThird & 0x1F) << 1) + (firmware_FirmwareData.versionBeta & 0x01);