Added a constant for the size of the version data.
This commit is contained in:
parent
c938a89359
commit
3ec8bb025c
@ -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.");
|
||||
|
||||
@ -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.");
|
||||
|
||||
@ -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]);
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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]);
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user