Keep only a single PAGESIZE macro.

This commit is contained in:
Jef Driesen 2010-01-15 09:51:15 +00:00
parent cf009cf18b
commit 32fd37df2c
11 changed files with 109 additions and 109 deletions

View File

@ -44,7 +44,7 @@
typedef struct oceanic_atom2_device_t {
oceanic_common_device_t base;
struct serial *port;
unsigned char version[OCEANIC_ATOM2_PACKET_SIZE];
unsigned char version[PAGESIZE];
} oceanic_atom2_device_t;
static device_status_t oceanic_atom2_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size);
@ -347,19 +347,19 @@ oceanic_atom2_device_version (device_t *abstract, unsigned char data[], unsigned
if (! device_is_oceanic_atom2 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
if (size < OCEANIC_ATOM2_PACKET_SIZE)
if (size < PAGESIZE)
return DEVICE_STATUS_MEMORY;
unsigned char answer[OCEANIC_ATOM2_PACKET_SIZE + 1] = {0};
unsigned char answer[PAGESIZE + 1] = {0};
unsigned char command[2] = {0x84, 0x00};
device_status_t rc = oceanic_atom2_transfer (device, command, sizeof (command), answer, sizeof (answer));
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
memcpy (data, answer, OCEANIC_ATOM2_PACKET_SIZE);
memcpy (data, answer, PAGESIZE);
#ifndef NDEBUG
answer[OCEANIC_ATOM2_PACKET_SIZE] = 0;
answer[PAGESIZE] = 0;
message ("ATOM2ReadVersion()=\"%s\"\n", answer);
#endif
@ -375,17 +375,17 @@ oceanic_atom2_device_read (device_t *abstract, unsigned int address, unsigned ch
if (! device_is_oceanic_atom2 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % OCEANIC_ATOM2_PACKET_SIZE == 0);
assert (size % OCEANIC_ATOM2_PACKET_SIZE == 0);
assert (address % PAGESIZE == 0);
assert (size % PAGESIZE == 0);
// The data transmission is split in packages
// of maximum $OCEANIC_ATOM2_PACKET_SIZE bytes.
// of maximum $PAGESIZE bytes.
unsigned int nbytes = 0;
while (nbytes < size) {
// Read the package.
unsigned int number = address / OCEANIC_ATOM2_PACKET_SIZE;
unsigned char answer[OCEANIC_ATOM2_PACKET_SIZE + 1] = {0};
unsigned int number = address / PAGESIZE;
unsigned char answer[PAGESIZE + 1] = {0};
unsigned char command[4] = {0xB1,
(number >> 8) & 0xFF, // high
(number ) & 0xFF, // low
@ -394,19 +394,19 @@ oceanic_atom2_device_read (device_t *abstract, unsigned int address, unsigned ch
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
memcpy (data, answer, OCEANIC_ATOM2_PACKET_SIZE);
memcpy (data, answer, PAGESIZE);
#ifndef NDEBUG
message ("ATOM2Read(0x%04x,%d)=\"", address, OCEANIC_ATOM2_PACKET_SIZE);
for (unsigned int i = 0; i < OCEANIC_ATOM2_PACKET_SIZE; ++i) {
message ("ATOM2Read(0x%04x,%d)=\"", address, PAGESIZE);
for (unsigned int i = 0; i < PAGESIZE; ++i) {
message("%02x", data[i]);
}
message("\"\n");
#endif
nbytes += OCEANIC_ATOM2_PACKET_SIZE;
address += OCEANIC_ATOM2_PACKET_SIZE;
data += OCEANIC_ATOM2_PACKET_SIZE;
nbytes += PAGESIZE;
address += PAGESIZE;
data += PAGESIZE;
}
return DEVICE_STATUS_SUCCESS;
@ -421,16 +421,16 @@ oceanic_atom2_device_write (device_t *abstract, unsigned int address, const unsi
if (! device_is_oceanic_atom2 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % OCEANIC_ATOM2_PACKET_SIZE == 0);
assert (size % OCEANIC_ATOM2_PACKET_SIZE == 0);
assert (address % PAGESIZE == 0);
assert (size % PAGESIZE == 0);
// The data transmission is split in packages
// of maximum $OCEANIC_ATOM2_PACKET_SIZE bytes.
// of maximum $PAGESIZE bytes.
unsigned int nbytes = 0;
while (nbytes < size) {
// Prepare to write the package.
unsigned int number = address / OCEANIC_ATOM2_PACKET_SIZE;
unsigned int number = address / PAGESIZE;
unsigned char prepare[4] = {0xB2,
(number >> 8) & 0xFF, // high
(number ) & 0xFF, // low
@ -440,28 +440,28 @@ oceanic_atom2_device_write (device_t *abstract, unsigned int address, const unsi
return rc;
#ifndef NDEBUG
message ("ATOM2PrepareWrite(0x%04x,%d)\n", address, OCEANIC_ATOM2_PACKET_SIZE);
message ("ATOM2PrepareWrite(0x%04x,%d)\n", address, PAGESIZE);
#endif
// Write the package.
unsigned char command[OCEANIC_ATOM2_PACKET_SIZE + 2] = {0};
memcpy (command, data, OCEANIC_ATOM2_PACKET_SIZE);
command[OCEANIC_ATOM2_PACKET_SIZE] = checksum_add_uint8 (command, OCEANIC_ATOM2_PACKET_SIZE, 0x00);
unsigned char command[PAGESIZE + 2] = {0};
memcpy (command, data, PAGESIZE);
command[PAGESIZE] = checksum_add_uint8 (command, PAGESIZE, 0x00);
rc = oceanic_atom2_transfer (device, command, sizeof (command), NULL, 0);
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
#ifndef NDEBUG
message ("ATOM2Write(0x%04x,%d)=\"", address, OCEANIC_ATOM2_PACKET_SIZE);
for (unsigned int i = 0; i < OCEANIC_ATOM2_PACKET_SIZE; ++i) {
message ("ATOM2Write(0x%04x,%d)=\"", address, PAGESIZE);
for (unsigned int i = 0; i < PAGESIZE; ++i) {
message("%02x", data[i]);
}
message("\"\n");
#endif
nbytes += OCEANIC_ATOM2_PACKET_SIZE;
address += OCEANIC_ATOM2_PACKET_SIZE;
data += OCEANIC_ATOM2_PACKET_SIZE;
nbytes += PAGESIZE;
address += PAGESIZE;
data += PAGESIZE;
}
return DEVICE_STATUS_SUCCESS;
@ -482,7 +482,7 @@ oceanic_atom2_device_dump (device_t *abstract, dc_buffer_t *buffer)
}
return device_dump_read (abstract, dc_buffer_get_data (buffer),
dc_buffer_get_size (buffer), OCEANIC_ATOM2_PACKET_SIZE);
dc_buffer_get_size (buffer), PAGESIZE);
}

View File

@ -30,7 +30,6 @@ extern "C" {
#endif /* __cplusplus */
#define OCEANIC_ATOM2_MEMORY_SIZE 0x10000
#define OCEANIC_ATOM2_PACKET_SIZE 0x10
device_status_t
oceanic_atom2_device_open (device_t **device, const char* name);

View File

@ -23,6 +23,7 @@
#include <assert.h>
#include "oceanic_atom2.h"
#include "oceanic_common.h"
#include "parser-private.h"
#include "array.h"
#include "units.h"
@ -110,7 +111,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call
const unsigned char *data = abstract->data;
unsigned int size = abstract->size;
if (size < 11 * OCEANIC_ATOM2_PACKET_SIZE / 2)
if (size < 11 * PAGESIZE / 2)
return PARSER_STATUS_ERROR;
unsigned int time = 0;
@ -136,13 +137,13 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call
unsigned int pressure = data[0x42] + (data[0x42 + 1] << 8);
unsigned int temperature = data[0x47];
unsigned int offset = 9 * OCEANIC_ATOM2_PACKET_SIZE / 2;
while (offset + OCEANIC_ATOM2_PACKET_SIZE / 2 <= size - OCEANIC_ATOM2_PACKET_SIZE) {
unsigned int offset = 9 * PAGESIZE / 2;
while (offset + PAGESIZE / 2 <= size - PAGESIZE) {
parser_sample_value_t sample = {0};
// Ignore empty samples.
if (array_isequal (data + offset, OCEANIC_ATOM2_PACKET_SIZE / 2, 0x00)) {
offset += OCEANIC_ATOM2_PACKET_SIZE / 2;
if (array_isequal (data + offset, PAGESIZE / 2, 0x00)) {
offset += PAGESIZE / 2;
continue;
}
@ -155,7 +156,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call
// Vendor specific data
sample.vendor.type = SAMPLE_VENDOR_OCEANIC_ATOM2;
sample.vendor.size = OCEANIC_ATOM2_PACKET_SIZE / 2;
sample.vendor.size = PAGESIZE / 2;
sample.vendor.data = data + offset;
if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata);
@ -191,7 +192,7 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call
complete = 1;
}
offset += OCEANIC_ATOM2_PACKET_SIZE / 2;
offset += PAGESIZE / 2;
}
return PARSER_STATUS_SUCCESS;

View File

@ -29,8 +29,6 @@
#include "array.h"
#include "utils.h"
#define PAGESIZE 0x10
#define RB_LOGBOOK_DISTANCE(a,b,l) ringbuffer_distance (a, b, 0, l->rb_logbook_begin, l->rb_logbook_end)
#define RB_LOGBOOK_INCR(a,b,l) ringbuffer_increment (a, b, l->rb_logbook_begin, l->rb_logbook_end)

View File

@ -28,6 +28,8 @@
extern "C" {
#endif /* __cplusplus */
#define PAGESIZE 0x10
typedef struct oceanic_common_device_t {
device_t base;
unsigned char fingerprint[8];

View File

@ -45,7 +45,7 @@ typedef struct oceanic_veo250_device_t {
oceanic_common_device_t base;
struct serial *port;
unsigned int last;
unsigned char version[OCEANIC_VEO250_PACKET_SIZE];
unsigned char version[PAGESIZE];
} oceanic_veo250_device_t;
static device_status_t oceanic_veo250_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size);
@ -354,27 +354,27 @@ oceanic_veo250_device_version (device_t *abstract, unsigned char data[], unsigne
if (! device_is_oceanic_veo250 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
if (size < OCEANIC_VEO250_PACKET_SIZE)
if (size < PAGESIZE)
return DEVICE_STATUS_MEMORY;
unsigned char answer[OCEANIC_VEO250_PACKET_SIZE + 2] = {0};
unsigned char answer[PAGESIZE + 2] = {0};
unsigned char command[2] = {0x90, 0x00};
device_status_t rc = oceanic_veo250_transfer (device, command, sizeof (command), answer, sizeof (answer));
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
// Verify the checksum of the answer.
unsigned char crc = answer[OCEANIC_VEO250_PACKET_SIZE];
unsigned char ccrc = checksum_add_uint8 (answer, OCEANIC_VEO250_PACKET_SIZE, 0x00);
unsigned char crc = answer[PAGESIZE];
unsigned char ccrc = checksum_add_uint8 (answer, PAGESIZE, 0x00);
if (crc != ccrc) {
WARNING ("Unexpected answer CRC.");
return DEVICE_STATUS_PROTOCOL;
}
memcpy (data, answer, OCEANIC_VEO250_PACKET_SIZE);
memcpy (data, answer, PAGESIZE);
#ifndef NDEBUG
answer[OCEANIC_VEO250_PACKET_SIZE] = 0;
answer[PAGESIZE] = 0;
message ("VEO250ReadVersion()=\"%s\"\n", answer);
#endif
@ -390,17 +390,17 @@ oceanic_veo250_device_read (device_t *abstract, unsigned int address, unsigned c
if (! device_is_oceanic_veo250 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % OCEANIC_VEO250_PACKET_SIZE == 0);
assert (size % OCEANIC_VEO250_PACKET_SIZE == 0);
assert (address % PAGESIZE == 0);
assert (size % PAGESIZE == 0);
// The data transmission is split in packages
// of maximum $OCEANIC_VEO250_PACKET_SIZE bytes.
// of maximum $PAGESIZE bytes.
unsigned int nbytes = 0;
while (nbytes < size) {
// Read the package.
unsigned int number = address / OCEANIC_VEO250_PACKET_SIZE;
unsigned char answer[OCEANIC_VEO250_PACKET_SIZE + 2] = {0};
unsigned int number = address / PAGESIZE;
unsigned char answer[PAGESIZE + 2] = {0};
unsigned char command[6] = {0x20,
(number ) & 0xFF, // low
(number >> 8) & 0xFF, // high
@ -414,26 +414,26 @@ oceanic_veo250_device_read (device_t *abstract, unsigned int address, unsigned c
device->last = number;
// Verify the checksum of the answer.
unsigned char crc = answer[OCEANIC_VEO250_PACKET_SIZE];
unsigned char ccrc = checksum_add_uint8 (answer, OCEANIC_VEO250_PACKET_SIZE, 0x00);
unsigned char crc = answer[PAGESIZE];
unsigned char ccrc = checksum_add_uint8 (answer, PAGESIZE, 0x00);
if (crc != ccrc) {
WARNING ("Unexpected answer CRC.");
return DEVICE_STATUS_PROTOCOL;
}
memcpy (data, answer, OCEANIC_VEO250_PACKET_SIZE);
memcpy (data, answer, PAGESIZE);
#ifndef NDEBUG
message ("VEO250Read(0x%04x,%d)=\"", address, OCEANIC_VEO250_PACKET_SIZE);
for (unsigned int i = 0; i < OCEANIC_VEO250_PACKET_SIZE; ++i) {
message ("VEO250Read(0x%04x,%d)=\"", address, PAGESIZE);
for (unsigned int i = 0; i < PAGESIZE; ++i) {
message("%02x", data[i]);
}
message("\"\n");
#endif
nbytes += OCEANIC_VEO250_PACKET_SIZE;
address += OCEANIC_VEO250_PACKET_SIZE;
data += OCEANIC_VEO250_PACKET_SIZE;
nbytes += PAGESIZE;
address += PAGESIZE;
data += PAGESIZE;
}
return DEVICE_STATUS_SUCCESS;
@ -454,7 +454,7 @@ oceanic_veo250_device_dump (device_t *abstract, dc_buffer_t *buffer)
}
return device_dump_read (abstract, dc_buffer_get_data (buffer),
dc_buffer_get_size (buffer), OCEANIC_VEO250_PACKET_SIZE);
dc_buffer_get_size (buffer), PAGESIZE);
}

View File

@ -22,15 +22,14 @@
#ifndef OCEANIC_VEO250_H
#define OCEANIC_VEO250_H
#include "device.h"
#include "parser.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "device.h"
#include "parser.h"
#define OCEANIC_VEO250_MEMORY_SIZE 0x8000
#define OCEANIC_VEO250_PACKET_SIZE 0x10
device_status_t
oceanic_veo250_device_open (device_t **device, const char* name);

View File

@ -23,6 +23,7 @@
#include <assert.h>
#include "oceanic_veo250.h"
#include "oceanic_common.h"
#include "parser-private.h"
#include "array.h"
#include "units.h"
@ -110,7 +111,7 @@ oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t cal
const unsigned char *data = abstract->data;
unsigned int size = abstract->size;
if (size < 7 * OCEANIC_VEO250_PACKET_SIZE / 2)
if (size < 7 * PAGESIZE / 2)
return PARSER_STATUS_ERROR;
unsigned int time = 0;
@ -130,13 +131,13 @@ oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t cal
break;
}
unsigned int offset = 5 * OCEANIC_VEO250_PACKET_SIZE / 2;
while (offset + OCEANIC_VEO250_PACKET_SIZE / 2 <= size - OCEANIC_VEO250_PACKET_SIZE) {
unsigned int offset = 5 * PAGESIZE / 2;
while (offset + PAGESIZE / 2 <= size - PAGESIZE) {
parser_sample_value_t sample = {0};
// Ignore empty samples.
if (array_isequal (data + offset, OCEANIC_VEO250_PACKET_SIZE / 2, 0x00)) {
offset += OCEANIC_VEO250_PACKET_SIZE / 2;
if (array_isequal (data + offset, PAGESIZE / 2, 0x00)) {
offset += PAGESIZE / 2;
continue;
}
@ -147,7 +148,7 @@ oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t cal
// Vendor specific data
sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VEO250;
sample.vendor.size = OCEANIC_VEO250_PACKET_SIZE / 2;
sample.vendor.size = PAGESIZE / 2;
sample.vendor.data = data + offset;
if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata);
@ -161,7 +162,7 @@ oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t cal
sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata);
offset += OCEANIC_VEO250_PACKET_SIZE / 2;
offset += PAGESIZE / 2;
}
return PARSER_STATUS_SUCCESS;

View File

@ -45,7 +45,7 @@
typedef struct oceanic_vtpro_device_t {
oceanic_common_device_t base;
struct serial *port;
unsigned char version[OCEANIC_VTPRO_PACKET_SIZE];
unsigned char version[PAGESIZE];
} oceanic_vtpro_device_t;
static device_status_t oceanic_vtpro_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size);
@ -375,7 +375,7 @@ oceanic_vtpro_device_version (device_t *abstract, unsigned char data[], unsigned
if (! device_is_oceanic_vtpro (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
if (size < OCEANIC_VTPRO_PACKET_SIZE)
if (size < PAGESIZE)
return DEVICE_STATUS_MEMORY;
// Switch the device into download mode. The response is ignored here,
@ -383,21 +383,21 @@ oceanic_vtpro_device_version (device_t *abstract, unsigned char data[], unsigned
// response of the first part of the other command in this function.
unsigned char cmd[2] = {0x88, 0x00};
unsigned char ans[OCEANIC_VTPRO_PACKET_SIZE / 2 + 1] = {0};
unsigned char ans[PAGESIZE / 2 + 1] = {0};
device_status_t rc = oceanic_vtpro_transfer (device, cmd, sizeof (cmd), ans, sizeof (ans));
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
// Verify the checksum of the answer.
unsigned char crc = ans[OCEANIC_VTPRO_PACKET_SIZE / 2];
unsigned char ccrc = checksum_add_uint4 (ans, OCEANIC_VTPRO_PACKET_SIZE / 2, 0x00);
unsigned char crc = ans[PAGESIZE / 2];
unsigned char ccrc = checksum_add_uint4 (ans, PAGESIZE / 2, 0x00);
if (crc != ccrc) {
WARNING ("Unexpected answer CRC.");
return DEVICE_STATUS_PROTOCOL;
}
#ifndef NDEBUG
ans[OCEANIC_VTPRO_PACKET_SIZE / 2] = 0;
ans[PAGESIZE / 2] = 0;
message ("VTPROVersion(init)=\"%s\"\n", ans);
#endif
@ -406,30 +406,30 @@ oceanic_vtpro_device_version (device_t *abstract, unsigned char data[], unsigned
for (unsigned int i = 0; i < 2; ++i) {
unsigned char command[4] = {0x72, 0x03, i * 0x10, 0x00};
unsigned char answer[OCEANIC_VTPRO_PACKET_SIZE / 2 + 2] = {0};
unsigned char answer[PAGESIZE / 2 + 2] = {0};
rc = oceanic_vtpro_transfer (device, command, sizeof (command), answer, sizeof (answer));
if (rc != DEVICE_STATUS_SUCCESS)
return rc;
// Verify the checksum of the answer.
unsigned char crc = answer[OCEANIC_VTPRO_PACKET_SIZE / 2];
unsigned char ccrc = checksum_add_uint4 (answer, OCEANIC_VTPRO_PACKET_SIZE / 2, 0x00);
unsigned char crc = answer[PAGESIZE / 2];
unsigned char ccrc = checksum_add_uint4 (answer, PAGESIZE / 2, 0x00);
if (crc != ccrc) {
WARNING ("Unexpected answer CRC.");
return DEVICE_STATUS_PROTOCOL;
}
// Verify the last byte of the answer.
if (answer[OCEANIC_VTPRO_PACKET_SIZE / 2 + 1] != END) {
if (answer[PAGESIZE / 2 + 1] != END) {
WARNING ("Unexpected answer byte.");
return DEVICE_STATUS_PROTOCOL;
}
// Append the answer to the output buffer.
memcpy (data + i * OCEANIC_VTPRO_PACKET_SIZE / 2, answer, OCEANIC_VTPRO_PACKET_SIZE / 2);
memcpy (data + i * PAGESIZE / 2, answer, PAGESIZE / 2);
#ifndef NDEBUG
answer[OCEANIC_VTPRO_PACKET_SIZE / 2] = 0;
answer[PAGESIZE / 2] = 0;
message ("VTPROVersion(%u)=\"%s\"\n", i, answer);
#endif
}
@ -446,17 +446,17 @@ oceanic_vtpro_device_read (device_t *abstract, unsigned int address, unsigned ch
if (! device_is_oceanic_vtpro (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
assert (address % OCEANIC_VTPRO_PACKET_SIZE == 0);
assert (size % OCEANIC_VTPRO_PACKET_SIZE == 0);
assert (address % PAGESIZE == 0);
assert (size % PAGESIZE == 0);
// The data transmission is split in packages
// of maximum $OCEANIC_VTPRO_PACKET_SIZE bytes.
// of maximum $PAGESIZE bytes.
unsigned int nbytes = 0;
while (nbytes < size) {
// Read the package.
unsigned int number = address / OCEANIC_VTPRO_PACKET_SIZE;
unsigned char answer[OCEANIC_VTPRO_PACKET_SIZE + 1] = {0};
unsigned int number = address / PAGESIZE;
unsigned char answer[PAGESIZE + 1] = {0};
unsigned char command[6] = {0x34,
(number >> 8) & 0xFF, // high
(number ) & 0xFF, // low
@ -468,26 +468,26 @@ oceanic_vtpro_device_read (device_t *abstract, unsigned int address, unsigned ch
return rc;
// Verify the checksum of the answer.
unsigned char crc = answer[OCEANIC_VTPRO_PACKET_SIZE];
unsigned char ccrc = checksum_add_uint8 (answer, OCEANIC_VTPRO_PACKET_SIZE, 0x00);
unsigned char crc = answer[PAGESIZE];
unsigned char ccrc = checksum_add_uint8 (answer, PAGESIZE, 0x00);
if (crc != ccrc) {
WARNING ("Unexpected answer CRC.");
return DEVICE_STATUS_PROTOCOL;
}
memcpy (data, answer, OCEANIC_VTPRO_PACKET_SIZE);
memcpy (data, answer, PAGESIZE);
#ifndef NDEBUG
message ("VTPRORead(0x%04x,%d)=\"", address, OCEANIC_VTPRO_PACKET_SIZE);
for (unsigned int i = 0; i < OCEANIC_VTPRO_PACKET_SIZE; ++i) {
message ("VTPRORead(0x%04x,%d)=\"", address, PAGESIZE);
for (unsigned int i = 0; i < PAGESIZE; ++i) {
message("%02x", data[i]);
}
message("\"\n");
#endif
nbytes += OCEANIC_VTPRO_PACKET_SIZE;
address += OCEANIC_VTPRO_PACKET_SIZE;
data += OCEANIC_VTPRO_PACKET_SIZE;
nbytes += PAGESIZE;
address += PAGESIZE;
data += PAGESIZE;
}
return DEVICE_STATUS_SUCCESS;
@ -508,7 +508,7 @@ oceanic_vtpro_device_dump (device_t *abstract, dc_buffer_t *buffer)
}
return device_dump_read (abstract, dc_buffer_get_data (buffer),
dc_buffer_get_size (buffer), OCEANIC_VTPRO_PACKET_SIZE);
dc_buffer_get_size (buffer), PAGESIZE);
}

View File

@ -22,15 +22,14 @@
#ifndef OCEANIC_VTPRO_H
#define OCEANIC_VTPRO_H
#include "device.h"
#include "parser.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "device.h"
#include "parser.h"
#define OCEANIC_VTPRO_MEMORY_SIZE 0x8000
#define OCEANIC_VTPRO_PACKET_SIZE 0x10
device_status_t
oceanic_vtpro_device_open (device_t **device, const char* name);

View File

@ -23,6 +23,7 @@
#include <assert.h>
#include "oceanic_vtpro.h"
#include "oceanic_common.h"
#include "parser-private.h"
#include "array.h"
#include "units.h"
@ -110,7 +111,7 @@ oceanic_vtpro_parser_samples_foreach (parser_t *abstract, sample_callback_t call
const unsigned char *data = abstract->data;
unsigned int size = abstract->size;
if (size < 7 * OCEANIC_VTPRO_PACKET_SIZE / 2)
if (size < 7 * PAGESIZE / 2)
return PARSER_STATUS_ERROR;
unsigned int time = 0;
@ -130,13 +131,13 @@ oceanic_vtpro_parser_samples_foreach (parser_t *abstract, sample_callback_t call
break;
}
unsigned int offset = 5 * OCEANIC_VTPRO_PACKET_SIZE / 2;
while (offset + OCEANIC_VTPRO_PACKET_SIZE / 2 <= size - OCEANIC_VTPRO_PACKET_SIZE) {
unsigned int offset = 5 * PAGESIZE / 2;
while (offset + PAGESIZE / 2 <= size - PAGESIZE) {
parser_sample_value_t sample = {0};
// Ignore empty samples.
if (array_isequal (data + offset, OCEANIC_VTPRO_PACKET_SIZE / 2, 0x00)) {
offset += OCEANIC_VTPRO_PACKET_SIZE / 2;
if (array_isequal (data + offset, PAGESIZE / 2, 0x00)) {
offset += PAGESIZE / 2;
continue;
}
@ -147,7 +148,7 @@ oceanic_vtpro_parser_samples_foreach (parser_t *abstract, sample_callback_t call
// Vendor specific data
sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VTPRO;
sample.vendor.size = OCEANIC_VTPRO_PACKET_SIZE / 2;
sample.vendor.size = PAGESIZE / 2;
sample.vendor.data = data + offset;
if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata);
@ -161,7 +162,7 @@ oceanic_vtpro_parser_samples_foreach (parser_t *abstract, sample_callback_t call
sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata);
offset += OCEANIC_VTPRO_PACKET_SIZE / 2;
offset += PAGESIZE / 2;
}
return PARSER_STATUS_SUCCESS;