Incorrect serial number in JDiveLog

Legacy OSTC's
Post Reply
Laurie_the_Knot
Posts: 58
Joined: 27 Jan 2012, 17:46

Incorrect serial number in JDiveLog

Post by Laurie_the_Knot »

Hi all you JdiveLog users,

I have been looking through the java code for the OSTC in JDiveLog and I've found the bug that reports the serial number incorrectly.

If you have recorded more than 255 dives you will note that the dive count is also incorrect.

The problem is that when the 2 bytes storing the serial number and total dive counts are converted to integers the high byte is multiplied by 255 instead of 256.

If you want to see for yourself the bug is in the following files in directory
src/net/sf/jdivelog/ci/ostc

[pre]
OSTCProtocol080115.java at line 91: int serial = (0xff & data[offset]) + 255 * (0xff&data[offset+1]);
OSTCProtocol080115.java at line 93: int numOfDives = (0xff & data[offset+2]) + 255 * (0xff&data[offset+3]);

OSTCProtocol080121.java at line 176: int serial = (0xff & data[offset]) + 255 * (0xff & data[offset + 1]);
OSTCProtocol080121.java at line 178: int numOfDives = (0xff & data[offset + 2]) + 255 * (0xff & data[offset + 3]);

OSTCProtocol080321.java at line 59: int serial = (0xff & data[offset]) + 255 * (0xff & data[offset + 1]);
OSTCProtocol080321.java at line 61: int numOfDives = (0xff & data[offset + 2]) + 255 * (0xff & data[offset + 3]);

OSTCProtocol081130.java at line 149: int serial = (0xff & data[offset]) + 255 * (0xff & data[offset + 1]);
OSTCProtocol081130.java at line 151: int numOfDives = (0xff & data[offset + 2]) + 255 * (0xff & data[offset + 3]);

OSTCProtocol100801.java at line 88: int serial = (0xff & data[offset]) + 255 * (0xff & data[offset + 1]);
OSTCProtocol100801.java at line 90: int numOfDives = (0xff & data[offset + 2]) + 255 * (0xff & data[offset + 3]);

OSTCProtocol100801Mk2.java at line 123: int serial = (0xff & data[offset]) + 255 * (0xff & data[offset + 1]);
OSTCProtocol100801Mk2.java at line 125: int numOfDives = (0xff & data[offset + 2]) + 255 * (0xff & data[offset + 3]);
[/pre]


If you are running OSTC firmware 1.50 or later only the last file is relevant. If you have the source of JDiveLog and are comfortable editing and recompiling java changing 255 to 256 in these two lines will fix the problem.
Happy diving,
Laurie (OSTC2 #11454)
scubatinoo
Posts: 675
Joined: 01 Jan 2012, 22:41

Re: Incorrect serial number in JDiveLog

Post by scubatinoo »

Could you please send this to Pascal too? Or post it in the JDiveLog-Forums:
http://sourceforge.net/projects/jdivelog/forums
regards,
scubatinoo

> OSTC 2N 3705 & OSTC 2 18807 <
Laurie_the_Knot
Posts: 58
Joined: 27 Jan 2012, 17:46

Re: Incorrect serial number in JDiveLog

Post by Laurie_the_Knot »

You should find this posting in the sourceforge.net JDiveLog open forum now.
:)
Happy diving,
Laurie (OSTC2 #11454)
Post Reply