diff --git a/examples/suunto_d9_test.c b/examples/suunto_d9_test.c index 978740f..e227e71 100644 --- a/examples/suunto_d9_test.c +++ b/examples/suunto_d9_test.c @@ -20,7 +20,7 @@ int test_dump_sdm (const char* name) } message ("suunto_d9_read_version\n"); - unsigned char version[4] = {0}; + unsigned char version[SUUNTO_D9_VERSION_SIZE] = {0}; rc = suunto_d9_read_version (device, version, sizeof (version)); if (rc != SUUNTO_SUCCESS) { WARNING ("Cannot identify computer."); @@ -59,7 +59,7 @@ int test_dump_memory (const char* name, const char* filename) } message ("suunto_d9_read_version\n"); - unsigned char version[4] = {0}; + unsigned char version[SUUNTO_D9_VERSION_SIZE] = {0}; rc = suunto_d9_read_version (device, version, sizeof (version)); if (rc != SUUNTO_SUCCESS) { WARNING ("Cannot identify computer."); diff --git a/examples/suunto_vyper2_test.c b/examples/suunto_vyper2_test.c index 0b53e6f..9f0bc70 100644 --- a/examples/suunto_vyper2_test.c +++ b/examples/suunto_vyper2_test.c @@ -20,7 +20,7 @@ int test_dump_sdm (const char* name) } message ("suunto_vyper2_read_version\n"); - unsigned char version[4] = {0}; + unsigned char version[SUUNTO_VYPER2_VERSION_SIZE] = {0}; rc = suunto_vyper2_read_version (device, version, sizeof (version)); if (rc != SUUNTO_SUCCESS) { WARNING ("Cannot identify computer."); @@ -59,7 +59,7 @@ int test_dump_memory (const char* name, const char* filename) } message ("suunto_vyper2_read_version\n"); - unsigned char version[4] = {0}; + unsigned char version[SUUNTO_VYPER2_VERSION_SIZE] = {0}; rc = suunto_vyper2_read_version (device, version, sizeof (version)); if (rc != SUUNTO_SUCCESS) { WARNING ("Cannot identify computer."); diff --git a/src/suunto_d9.c b/src/suunto_d9.c index 75adb77..d6b4149 100644 --- a/src/suunto_d9.c +++ b/src/suunto_d9.c @@ -208,16 +208,16 @@ suunto_d9_read_version (d9 *device, unsigned char data[], unsigned int size) if (device == NULL) return SUUNTO_ERROR; - if (size < 4) + if (size < SUUNTO_D9_VERSION_SIZE) return SUUNTO_ERROR_MEMORY; - unsigned char answer[4 + 4] = {0}; + unsigned char answer[SUUNTO_D9_VERSION_SIZE + 4] = {0}; unsigned char command[4] = {0x0F, 0x00, 0x00, 0x0F}; int rc = suunto_d9_transfer (device, command, sizeof (command), answer, sizeof (answer), 4); if (rc != SUUNTO_SUCCESS) return rc; - memcpy (data, answer + 3, 4); + memcpy (data, answer + 3, SUUNTO_D9_VERSION_SIZE); #ifndef NDEBUG message ("D9ReadVersion()=\"%02x %02x %02x %02x\"\n", data[0], data[1], data[2], data[3]); diff --git a/src/suunto_d9.h b/src/suunto_d9.h index 0586f93..eaf69b2 100644 --- a/src/suunto_d9.h +++ b/src/suunto_d9.h @@ -9,6 +9,7 @@ typedef struct d9 d9; #define SUUNTO_D9_MEMORY_SIZE 0x8000 #define SUUNTO_D9_PACKET_SIZE 0x78 +#define SUUNTO_D9_VERSION_SIZE 0x04 int suunto_d9_open (d9 **device, const char* name); diff --git a/src/suunto_vyper2.c b/src/suunto_vyper2.c index c11c080..202e496 100644 --- a/src/suunto_vyper2.c +++ b/src/suunto_vyper2.c @@ -195,16 +195,16 @@ suunto_vyper2_read_version (vyper2 *device, unsigned char data[], unsigned int s if (device == NULL) return SUUNTO_ERROR; - if (size < 4) + if (size < SUUNTO_VYPER2_VERSION_SIZE) return SUUNTO_ERROR_MEMORY; - unsigned char answer[4 + 4] = {0}; + unsigned char answer[SUUNTO_VYPER2_VERSION_SIZE + 4] = {0}; unsigned char command[4] = {0x0F, 0x00, 0x00, 0x0F}; int rc = suunto_vyper2_transfer (device, command, sizeof (command), answer, sizeof (answer), 4); if (rc != SUUNTO_SUCCESS) return rc; - memcpy (data, answer + 3, 4); + memcpy (data, answer + 3, SUUNTO_VYPER2_VERSION_SIZE); #ifndef NDEBUG message ("Vyper2ReadVersion()=\"%02x %02x %02x %02x\"\n", data[0], data[1], data[2], data[3]); diff --git a/src/suunto_vyper2.h b/src/suunto_vyper2.h index 4adc7d3..c174685 100644 --- a/src/suunto_vyper2.h +++ b/src/suunto_vyper2.h @@ -9,6 +9,7 @@ typedef struct vyper2 vyper2; #define SUUNTO_VYPER2_MEMORY_SIZE 0x8000 #define SUUNTO_VYPER2_PACKET_SIZE 0x78 +#define SUUNTO_VYPER2_VERSION_SIZE 0x04 int suunto_vyper2_open (vyper2 **device, const char* name);