Shearwater Petrel: make the hardware ID decoding a bit easier to read

Dirk seems to have some documentation about the different ID's, plus it
just makes sense to order the switch statement by number.

This is partly based on Dirk's original commit to do the different model
numbers, with various changes over time due to merge conflict
resolution.  Dirk's sign-off comes from Dirks commit in the original
subsurface branch.

As of firmware 11, Teric identifies as 0x1F0A.

Also, just like libdivecomputer upstream, don't assume that an unknown
model is a Petrel - that was a stupid thing to do and caused downloads
with the Teric to break.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Shearwater parser: add new harware model nr for Teric

As of firmware 11 at least my Teric identifies as 0x1F0A.
Also, just like libdivecomputer upstream, don't assume that an unknown
model is a Petrel - that was a stupid thing to do and caused downloads
with the Teric to break.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2018-04-17 11:07:14 -07:00
parent cf6c0d6640
commit cdfbe4092d

View File

@ -212,28 +212,41 @@ shearwater_petrel_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
unsigned int hardware = array_uint_be (dc_buffer_get_data (buffer), dc_buffer_get_size (buffer));
unsigned int model = 0;
switch (hardware) {
case 0x0808: // Petrel 2
case 0x0909: // Petrel 1
case 0x0B0B: // Petrel 1 (newer hardware)
model = PETREL;
case 0x0101:
case 0x0202:
model = PREDATOR;
break;
case 0x0606:
case 0x0A0A: // Nerd 1
model = NERD;
break;
case 0x0E0D: // Nerd 2
model = NERD2;
break;
case 0x0707:
case 0x0404:
case 0x0909: // Petrel 1
case 0x0B0B: // Petrel 1 (newer hardware)
model = PETREL;
break;
case 0x0505:
case 0x0808: // Petrel 2
model = PETREL;
break;
case 0x0707: // documentation list 0C0D for both Perdix and Perdix AI :-(
model = PERDIX;
break;
case 0x0C0C:
case 0x0C0D:
case 0x0D0D:
model = PERDIXAI;
break;
case 0x0F0F:
case 0x1F0A:
model = TERIC;
break;
default:
WARNING (abstract->context, "Unknown hardware type %04x.", hardware);
// return a model of 0 which is unknown
WARNING (abstract->context, "Unknown hardware type %04x. Assuming Petrel.", hardware);
}
// Emit a device info event.