Removed the suunto_vyper2_recv and suunto_d9_recv functions.
This commit is contained in:
parent
6f4d863498
commit
f74e17068f
39
suunto_d9.c
39
suunto_d9.c
@ -14,13 +14,6 @@
|
|||||||
message ("%s:%d: %s\n", __FILE__, __LINE__, expr); \
|
message ("%s:%d: %s\n", __FILE__, __LINE__, expr); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EXITCODE(rc, n) \
|
|
||||||
( \
|
|
||||||
rc == -1 ? \
|
|
||||||
SUUNTO_ERROR_IO : \
|
|
||||||
(rc != n ? SUUNTO_ERROR_TIMEOUT : SUUNTO_ERROR_PROTOCOL) \
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
struct d9 {
|
struct d9 {
|
||||||
struct serial *port;
|
struct serial *port;
|
||||||
@ -133,9 +126,17 @@ suunto_d9_send (d9 *device, const unsigned char command[], unsigned int csize)
|
|||||||
unsigned char echo[128] = {0};
|
unsigned char echo[128] = {0};
|
||||||
assert (sizeof (echo) >= csize);
|
assert (sizeof (echo) >= csize);
|
||||||
int rc = serial_read (device->port, echo, csize);
|
int rc = serial_read (device->port, echo, csize);
|
||||||
if (rc != csize || memcmp (command, echo, csize) != 0) {
|
if (rc != csize) {
|
||||||
|
WARNING ("Failed to receive the echo.");
|
||||||
|
if (rc == -1)
|
||||||
|
return SUUNTO_ERROR_IO;
|
||||||
|
return SUUNTO_ERROR_TIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the echo.
|
||||||
|
if (memcmp (command, echo, csize) != 0) {
|
||||||
WARNING ("Unexpected echo.");
|
WARNING ("Unexpected echo.");
|
||||||
return EXITCODE (rc, csize);
|
return SUUNTO_ERROR_PROTOCOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set RTS to receive the reply.
|
// Set RTS to receive the reply.
|
||||||
@ -145,18 +146,6 @@ suunto_d9_send (d9 *device, const unsigned char command[], unsigned int csize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
suunto_d9_recv (d9 *device, unsigned char data[], unsigned int size)
|
|
||||||
{
|
|
||||||
int rc = serial_read (device->port, data, size);
|
|
||||||
if (rc != size) {
|
|
||||||
return EXITCODE (rc, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SUUNTO_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
suunto_d9_transfer (d9 *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size)
|
suunto_d9_transfer (d9 *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size)
|
||||||
{
|
{
|
||||||
@ -170,10 +159,12 @@ suunto_d9_transfer (d9 *device, const unsigned char command[], unsigned int csiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Receive the answer of the dive computer.
|
// Receive the answer of the dive computer.
|
||||||
rc = suunto_d9_recv (device, answer, asize);
|
rc = serial_read (device->port, answer, asize);
|
||||||
if (rc != SUUNTO_SUCCESS) {
|
if (rc != asize) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return rc;
|
if (rc == -1)
|
||||||
|
return SUUNTO_ERROR_IO;
|
||||||
|
return SUUNTO_ERROR_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the header of the package.
|
// Verify the header of the package.
|
||||||
|
|||||||
@ -14,13 +14,6 @@
|
|||||||
message ("%s:%d: %s\n", __FILE__, __LINE__, expr); \
|
message ("%s:%d: %s\n", __FILE__, __LINE__, expr); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EXITCODE(rc, n) \
|
|
||||||
( \
|
|
||||||
rc == -1 ? \
|
|
||||||
SUUNTO_ERROR_IO : \
|
|
||||||
(rc != n ? SUUNTO_ERROR_TIMEOUT : SUUNTO_ERROR_PROTOCOL) \
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
struct vyper2 {
|
struct vyper2 {
|
||||||
struct serial *port;
|
struct serial *port;
|
||||||
@ -140,18 +133,6 @@ suunto_vyper2_send (vyper2 *device, const unsigned char command[], unsigned int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
suunto_vyper2_recv (vyper2 *device, unsigned char data[], unsigned int size)
|
|
||||||
{
|
|
||||||
int rc = serial_read (device->port, data, size);
|
|
||||||
if (rc != size) {
|
|
||||||
return EXITCODE (rc, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SUUNTO_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
suunto_vyper2_transfer (vyper2 *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size)
|
suunto_vyper2_transfer (vyper2 *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize, unsigned int size)
|
||||||
{
|
{
|
||||||
@ -165,10 +146,12 @@ suunto_vyper2_transfer (vyper2 *device, const unsigned char command[], unsigned
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Receive the answer of the dive computer.
|
// Receive the answer of the dive computer.
|
||||||
rc = suunto_vyper2_recv (device, answer, asize);
|
rc = serial_read (device->port, answer, asize);
|
||||||
if (rc != SUUNTO_SUCCESS) {
|
if (rc != asize) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return rc;
|
if (rc == -1)
|
||||||
|
return SUUNTO_ERROR_IO;
|
||||||
|
return SUUNTO_ERROR_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the header of the package.
|
// Verify the header of the package.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user