Use symbolic constants for the model numbers.

This commit is contained in:
Jef Driesen 2011-07-09 12:19:10 +02:00
parent 7a238281f6
commit 608008cd33
3 changed files with 30 additions and 13 deletions

View File

@ -39,6 +39,10 @@
#define MEMORYSIZE 0x4000
#define PACKETSIZE 0x20
#define NEMO 0
#define NEMOEXCEL 17
#define NEMOAPNEIST 18
typedef struct mares_nemo_device_t {
mares_common_device_t base;
serial_t *port;
@ -309,11 +313,11 @@ mares_nemo_extract_dives (device_t *abstract, const unsigned char data[], unsign
const mares_common_layout_t *layout = NULL;
switch (data[1]) {
case 0: // Nemo
case 17: // Nemo Excel
case NEMO:
case NEMOEXCEL:
layout = &mares_nemo_layout;
break;
case 18: // Nemo Apneist
case NEMOAPNEIST:
layout = &mares_nemo_apneist_layout;
break;
default: // Unknown, try nemo

View File

@ -28,6 +28,14 @@
#include "utils.h"
#include "array.h"
#define NEMO 0
#define NEMOWIDE 1
#define NEMOAIR 4
#define PUCK 7
#define NEMOEXCEL 17
#define NEMOAPNEIST 18
#define PUCKAIR 19
typedef struct mares_nemo_parser_t mares_nemo_parser_t;
struct mares_nemo_parser_t {
@ -87,7 +95,7 @@ mares_nemo_parser_create (parser_t **out, unsigned int model)
// Get the freedive mode for this model.
unsigned int freedive = 2;
if (model == 1 || model == 7)
if (model == NEMOWIDE || model == PUCK)
freedive = 3;
// Set the default values.
@ -147,7 +155,7 @@ mares_nemo_parser_set_data (parser_t *abstract, const unsigned char *data, unsig
unsigned int extra = 0;
const unsigned char marker[3] = {0xAA, 0xBB, 0xCC};
if (memcmp (data + length - 3, marker, sizeof (marker)) == 0) {
if (parser->model == 19)
if (parser->model == PUCKAIR)
extra = 7;
else
extra = 12;
@ -161,7 +169,7 @@ mares_nemo_parser_set_data (parser_t *abstract, const unsigned char *data, unsig
unsigned int header_size = 53;
unsigned int sample_size = 2;
if (extra) {
if (parser->model == 19)
if (parser->model == PUCKAIR)
sample_size = 3;
else
sample_size = 5;
@ -368,7 +376,7 @@ mares_nemo_parser_samples_foreach (parser_t *abstract, sample_callback_t callbac
if (profiles) {
// Get the freedive sample interval for this model.
unsigned int interval = 4;
if (parser->model == 18)
if (parser->model == NEMOAPNEIST)
interval = 1;
// Calculate the number of samples that should be present

View File

@ -39,6 +39,11 @@
#define PACKETSIZE 0x20
#define MAXRETRIES 4
#define NEMOWIDE 1
#define NEMOAIR 4
#define PUCK 7
#define PUCKAIR 19
typedef struct mares_puck_device_t {
mares_common_device_t base;
serial_t *port;
@ -161,13 +166,13 @@ mares_puck_device_open (device_t **out, const char* name)
// Override the base class values.
switch (header[1]) {
case 1: // Nemo Wide
case NEMOWIDE:
device->base.layout = &mares_nemowide_layout;
break;
case 4: // Nemo Air
case NEMOAIR:
device->base.layout = &mares_nemoair_layout;
break;
case 7: // Puck
case PUCK:
device->base.layout = &mares_puck_layout;
break;
default: // Unknown, try puck
@ -444,13 +449,13 @@ mares_puck_extract_dives (device_t *abstract, const unsigned char data[], unsign
const mares_common_layout_t *layout = NULL;
switch (data[1]) {
case 1: // Nemo Wide
case NEMOWIDE:
layout = &mares_nemowide_layout;
break;
case 4: // Nemo Air
case NEMOAIR:
layout = &mares_nemoair_layout;
break;
case 7: // Puck
case PUCK:
layout = &mares_puck_layout;
break;
default: // Unknown, try puck