Added a new function for the keepalive command.
This commit is contained in:
parent
2a7e4fdc7d
commit
3c36f9d166
@ -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
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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 */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user