On Fri, Oct 10, 2014 at 02:20:20PM +0200, Jef Driesen wrote:
I spent an evening playing with the simulator and their app. Trying every single value this is the logic that I found. I think it would be a nice feature not to get the unused tanks, but my confidence that this is 100% correct is not 100% :-/. The problem is... the only way to get this more widely tested is to add the code and wait if it works as expected in all circumstances.
Does that mean you found the trick to make the Aeris application talk to the simulator? Can you share what you did, because I had so success so far.
Sure. I used the patches that I sent you. I did exactly what you suggested I should do. It took about five attempts to get the drivers to install in Windows (what a crap OS that pile of rubbish is). After that all I did was to start the simulator on /dev/ttyGS0 and to have the Windows app talk to the fake device.
I wrote a few little scripts that allowed me to easily edit the data file that I used and then it was all just a matter of dealing with the unbearably stupid Aeris app. This thing is so bad, it wants me to go all Linus and curse and stuff.
I think I found the logic. Look at the three relevant bits:
001 -> 1 011 -> 1 101 -> 1 111 -> 1 010 -> 2 110 -> 2 100 -> 3 000 -> 4
There is clearly a pattern here. All 4 combinations that map to one tank have the lowest bit set. With two tanks, the second bit is set. And so on. Thus this code should do the trick:
if (data[0x39] & 0x04) { *((unsigned int *) value) = 1; } else if (data[0x39] & 0x08) { *((unsigned int *) value) = 2; } else if (data[0x39] & 0x10) { *((unsigned int *) value) = 3; } else { *((unsigned int *) value) = 4; }
Yes, that is equivalent to my case statement.
I included this change already in the attached patches.
Originally I was puzzled by the fact that there are multiple ways to encode some values. And that makes no sense at all. But then I realized you probably made up data with the simulator to try all possible bit patterns. I
Correct
guess that in real data, we'll only see these 4 bit patterns:
001 -> 1
nope: 111 is what they use for 1 (1C, actually)
010 -> 2 100 -> 3 000 -> 4
I'll need to look what I can find in this week's dives as I simulated having two and three tanks.
BTW: your patches are completely unusable. I recommend against pushing them as they are and claiming A300CS support. At least not with my SOB line.
I have 27 dives on my A300CS. The download has been running for 15 minutes now. We're on dive 6. No, you cannot simply say "oh, the A300CS supports B1, let's force using that". This turns a perfectly usable dive computer which downloads half a dozen dives in under 10 seconds into a completely unusable piece of garbage that takes forever to download a day's worth of diving.
/D