Added a new function for the keepalive command.

This commit is contained in:
Jef Driesen 2008-11-21 08:40:19 +00:00
parent 2a7e4fdc7d
commit 3c36f9d166
3 changed files with 38 additions and 0 deletions

View File

@ -31,6 +31,7 @@ oceanic_atom2_device_handshake
oceanic_atom2_device_open
oceanic_atom2_device_quit
oceanic_veo250_device_open
oceanic_veo250_device_keepalive
reefnet_sensuspro_device_open
reefnet_sensuspro_device_set_timestamp
reefnet_sensuspro_device_write_interval

View File

@ -303,6 +303,40 @@ oceanic_veo250_device_close (device_t *abstract)
}
device_status_t
oceanic_veo250_device_keepalive (device_t *abstract)
{
oceanic_veo250_device_t *device = (oceanic_veo250_device_t*) abstract;
if (! device_is_oceanic_veo250 (abstract))
return DEVICE_STATUS_TYPE_MISMATCH;
// Send the command to the dive computer.
unsigned char command[4] = {0x91, 0x00, 0x00, 0x00};
device_status_t rc = oceanic_veo250_send (device, command, sizeof (command));
if (rc != DEVICE_STATUS_SUCCESS) {
WARNING ("Failed to send the command.");
return rc;
}
// Receive the answer of the dive computer.
unsigned char answer[3] = {0};
int n = serial_read (device->port, answer, sizeof (answer));
if (n != sizeof (answer)) {
WARNING ("Failed to receive the answer.");
return EXITCODE (n);
}
// Verify the answer.
if (answer[0] != ACK || answer[1] != NAK || answer[2] != NAK) {
WARNING ("Unexpected answer byte(s).");
return DEVICE_STATUS_PROTOCOL;
}
return DEVICE_STATUS_SUCCESS;
}
static device_status_t
oceanic_veo250_device_version (device_t *abstract, unsigned char data[], unsigned int size)
{

View File

@ -34,6 +34,9 @@ extern "C" {
device_status_t
oceanic_veo250_device_open (device_t **device, const char* name);
device_status_t
oceanic_veo250_device_keepalive (device_t *device);
#ifdef __cplusplus
}
#endif /* __cplusplus */