Always use the timestamp stored in the device handle.

This commit is contained in:
Jef Driesen 2009-03-11 08:48:29 +00:00
parent 731eaa2ce6
commit ebfd5b4b1a
12 changed files with 61 additions and 30 deletions

View File

@ -372,13 +372,18 @@ reefnet_sensus_device_foreach (device_t *abstract, dive_callback_t callback, voi
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
return reefnet_sensus_extract_dives (data, sizeof (data), callback, userdata, device->timestamp);
return reefnet_sensus_extract_dives (abstract, data, sizeof (data), callback, userdata);
}
device_status_t
reefnet_sensus_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata, unsigned int timestamp)
reefnet_sensus_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata)
{
reefnet_sensus_device_t *device = (reefnet_sensus_device_t*) abstract;
if (abstract && !device_is_reefnet_sensus (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
// Search the entire data stream for start markers.
unsigned int previous = size;
unsigned int current = (size >= 7 ? size - 7 : 0);
@ -424,9 +429,9 @@ reefnet_sensus_extract_dives (const unsigned char data[], unsigned int size, div
}
// Automatically abort when a dive is older than the provided timestamp.
unsigned int datetime = data[current + 2] + (data[current + 3] << 8) +
unsigned int timestamp = data[current + 2] + (data[current + 3] << 8) +
(data[current + 4] << 16) + (data[current + 5] << 24);
if (datetime <= timestamp)
if (device && timestamp <= device->timestamp)
return DEVICE_STATUS_SUCCESS;
if (callback && !callback (data + current, offset - current, userdata))

View File

@ -39,7 +39,7 @@ device_status_t
reefnet_sensus_device_set_timestamp (device_t *device, unsigned int timestamp);
device_status_t
reefnet_sensus_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata, unsigned int timestamp);
reefnet_sensus_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
parser_status_t
reefnet_sensus_parser_create (parser_t **parser);

View File

@ -327,7 +327,7 @@ reefnet_sensuspro_device_foreach (device_t *abstract, dive_callback_t callback,
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
return reefnet_sensuspro_extract_dives (data, sizeof (data), callback, userdata, device->timestamp);
return reefnet_sensuspro_extract_dives (abstract, data, sizeof (data), callback, userdata);
}
@ -362,8 +362,13 @@ reefnet_sensuspro_device_write_interval (device_t *abstract, unsigned char inter
device_status_t
reefnet_sensuspro_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata, unsigned int timestamp)
reefnet_sensuspro_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata)
{
reefnet_sensuspro_device_t *device = (reefnet_sensuspro_device_t*) abstract;
if (abstract && !device_is_reefnet_sensuspro (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
const unsigned char header[4] = {0x00, 0x00, 0x00, 0x00};
const unsigned char footer[2] = {0xFF, 0xFF};
@ -392,9 +397,9 @@ reefnet_sensuspro_extract_dives (const unsigned char data[], unsigned int size,
return DEVICE_STATUS_ERROR;
// Automatically abort when a dive is older than the provided timestamp.
unsigned int datetime = data[current + 6] + (data[current + 7] << 8) +
unsigned int timestamp = data[current + 6] + (data[current + 7] << 8) +
(data[current + 8] << 16) + (data[current + 9] << 24);
if (datetime <= timestamp)
if (device && timestamp <= device->timestamp)
return DEVICE_STATUS_SUCCESS;
if (callback && !callback (data + current, offset + 2 - current, userdata))

View File

@ -42,7 +42,7 @@ device_status_t
reefnet_sensuspro_device_write_interval (device_t *device, unsigned char interval);
device_status_t
reefnet_sensuspro_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata, unsigned int timestamp);
reefnet_sensuspro_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
parser_status_t
reefnet_sensuspro_parser_create (parser_t **parser);

View File

@ -619,9 +619,14 @@ reefnet_sensusultra_device_sense (device_t *abstract, unsigned char *data, unsig
static device_status_t
reefnet_sensusultra_parse (const unsigned char data[], unsigned int begin, unsigned int end, unsigned int *pprevious,
int *aborted, dive_callback_t callback, void *userdata, unsigned int timestamp)
reefnet_sensusultra_parse (device_t *abstract, const unsigned char data[], unsigned int begin, unsigned int end, unsigned int *pprevious,
int *aborted, dive_callback_t callback, void *userdata)
{
reefnet_sensusultra_device_t *device = (reefnet_sensusultra_device_t*) abstract;
if (abstract && !device_is_reefnet_sensusultra (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
const unsigned char header[4] = {0x00, 0x00, 0x00, 0x00};
const unsigned char footer[4] = {0xFF, 0xFF, 0xFF, 0xFF};
@ -656,9 +661,9 @@ reefnet_sensusultra_parse (const unsigned char data[], unsigned int begin, unsig
}
// Automatically abort when a dive is older than the provided timestamp.
unsigned int datetime = data[current + 4] + (data[current + 5] << 8) +
unsigned int timestamp = data[current + 4] + (data[current + 5] << 8) +
(data[current + 6] << 16) + (data[current + 7] << 24);
if (datetime <= timestamp) {
if (device && timestamp <= device->timestamp) {
if (aborted)
*aborted = 1;
return DEVICE_STATUS_SUCCESS;
@ -738,7 +743,7 @@ reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback
// Parse the page data.
int aborted = 0;
rc = reefnet_sensusultra_parse (data, offset, offset + REEFNET_SENSUSULTRA_PACKET_SIZE, &previous, &aborted, callback, userdata, device->timestamp);
rc = reefnet_sensusultra_parse (abstract, data, offset, offset + REEFNET_SENSUSULTRA_PACKET_SIZE, &previous, &aborted, callback, userdata);
if (rc != DEVICE_STATUS_SUCCESS) {
free (data);
return rc;
@ -764,7 +769,7 @@ reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback
device_status_t
reefnet_sensusultra_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata, unsigned int timestamp)
reefnet_sensusultra_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata)
{
return reefnet_sensusultra_parse (data, 0, size, NULL, NULL, callback, userdata, timestamp);
return reefnet_sensusultra_parse (abstract, data, 0, size, NULL, NULL, callback, userdata);
}

View File

@ -67,7 +67,7 @@ device_status_t
reefnet_sensusultra_device_sense (device_t *device, unsigned char *data, unsigned int size);
device_status_t
reefnet_sensusultra_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata, unsigned int timestamp);
reefnet_sensusultra_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
parser_status_t
reefnet_sensusultra_parser_create (parser_t **parser);

View File

@ -275,14 +275,20 @@ suunto_solution_device_foreach (device_t *abstract, dive_callback_t callback, vo
devinfo.serial = (data[0x1D + 0] << 16) + (data[0x1D + 1] << 8) + data[0x1D + 2];
device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo);
return suunto_solution_extract_dives (data, sizeof (data), callback, userdata);
return suunto_solution_extract_dives (abstract, data, sizeof (data), callback, userdata);
}
device_status_t
suunto_solution_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata)
suunto_solution_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata)
{
assert (size >= SUUNTO_SOLUTION_MEMORY_SIZE);
suunto_solution_device_t *device = (suunto_solution_device_t*) abstract;
if (abstract && !device_is_suunto_solution (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
if (size < SUUNTO_SOLUTION_MEMORY_SIZE)
return DEVICE_STATUS_ERROR;
unsigned char buffer[RB_PROFILE_END - RB_PROFILE_BEGIN] = {0};

View File

@ -35,7 +35,7 @@ device_status_t
suunto_solution_device_open (device_t **device, const char* name);
device_status_t
suunto_solution_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
suunto_solution_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
parser_status_t
suunto_solution_parser_create (parser_t **parser);

View File

@ -287,13 +287,18 @@ uwatec_aladin_device_foreach (device_t *abstract, dive_callback_t callback, void
devinfo.serial = (data[HEADER + 0x7ed] << 16) + (data[HEADER + 0x7ee] << 8) + data[HEADER + 0x7ef];
device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo);
return uwatec_aladin_extract_dives (data, sizeof (data), callback, userdata, device->timestamp);
return uwatec_aladin_extract_dives (abstract, data, sizeof (data), callback, userdata);
}
device_status_t
uwatec_aladin_extract_dives (const unsigned char* data, unsigned int size, dive_callback_t callback, void *userdata, unsigned int timestamp)
uwatec_aladin_extract_dives (device_t *abstract, const unsigned char* data, unsigned int size, dive_callback_t callback, void *userdata)
{
uwatec_aladin_device_t *device = (uwatec_aladin_device_t*) abstract;
if (abstract && !device_is_uwatec_aladin (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
if (size < UWATEC_ALADIN_MEMORY_SIZE)
return DEVICE_STATUS_ERROR;
@ -386,9 +391,9 @@ uwatec_aladin_extract_dives (const unsigned char* data, unsigned int size, dive_
}
// Automatically abort when a dive is older than the provided timestamp.
unsigned int datetime = buffer[11] + (buffer[12] << 8) +
unsigned int timestamp = buffer[11] + (buffer[12] << 8) +
(buffer[13] << 16) + (buffer[14] << 24);
if (datetime <= timestamp)
if (device && timestamp <= device->timestamp)
return DEVICE_STATUS_SUCCESS;
if (callback && !callback (buffer, len + 18, userdata))

View File

@ -37,7 +37,7 @@ device_status_t
uwatec_aladin_device_set_timestamp (device_t *device, unsigned int timestamp);
device_status_t
uwatec_aladin_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata, unsigned int timestamp);
uwatec_aladin_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
#ifdef __cplusplus
}

View File

@ -538,7 +538,7 @@ uwatec_smart_device_foreach (device_t *abstract, dive_callback_t callback, void
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
rc = uwatec_smart_extract_dives (buffer, length, callback, userdata);
rc = uwatec_smart_extract_dives (abstract, buffer, length, callback, userdata);
if (rc != DEVICE_STATUS_SUCCESS) {
free (buffer);
return rc;
@ -551,8 +551,13 @@ uwatec_smart_device_foreach (device_t *abstract, dive_callback_t callback, void
device_status_t
uwatec_smart_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata)
uwatec_smart_extract_dives (device_t *abstract, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata)
{
uwatec_smart_device_t *device = (uwatec_smart_device_t*) abstract;
if (abstract && !device_is_uwatec_smart (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
const unsigned char header[4] = {0xa5, 0xa5, 0x5a, 0x5a};
// Search the data stream for start markers.

View File

@ -44,7 +44,7 @@ device_status_t
uwatec_smart_device_version (device_t *device, unsigned char data[], unsigned int size);
device_status_t
uwatec_smart_extract_dives (const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
uwatec_smart_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata);
parser_status_t
uwatec_smart_parser_create (parser_t **parser, unsigned int model);