Added a function to calibrate the interface.
This commit is contained in:
parent
c322b2cb29
commit
9f13949bd4
@ -51,6 +51,15 @@ test_dump_memory (const char* name, const char* filename)
|
||||
return rc;
|
||||
}
|
||||
|
||||
message ("oceanic_vtpro_device_calibrate\n");
|
||||
unsigned char calibration = 0;
|
||||
rc = oceanic_vtpro_device_calibrate (device, &calibration, 1);
|
||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
||||
WARNING ("Cannot calibrate computer.");
|
||||
device_close (device);
|
||||
return rc;
|
||||
}
|
||||
|
||||
message ("device_read\n");
|
||||
rc = device_read (device, 0x00, data, sizeof (data));
|
||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
||||
|
||||
@ -34,6 +34,7 @@ oceanic_veo250_device_open
|
||||
oceanic_veo250_device_keepalive
|
||||
oceanic_vtpro_device_open
|
||||
oceanic_vtpro_device_keepalive
|
||||
oceanic_vtpro_device_calibrate
|
||||
reefnet_sensuspro_device_open
|
||||
reefnet_sensuspro_device_set_timestamp
|
||||
reefnet_sensuspro_device_write_interval
|
||||
|
||||
@ -332,6 +332,49 @@ oceanic_vtpro_device_keepalive (device_t *abstract)
|
||||
}
|
||||
|
||||
|
||||
device_status_t
|
||||
oceanic_vtpro_device_calibrate (device_t *abstract, unsigned char data[], unsigned int size)
|
||||
{
|
||||
oceanic_vtpro_device_t *device = (oceanic_vtpro_device_t*) abstract;
|
||||
|
||||
if (! device_is_oceanic_vtpro (abstract))
|
||||
return DEVICE_STATUS_TYPE_MISMATCH;
|
||||
|
||||
if (size < 1)
|
||||
return DEVICE_STATUS_MEMORY;
|
||||
|
||||
// Send the command to the dive computer.
|
||||
unsigned char command[2] = {0x18, 0x00};
|
||||
device_status_t rc = oceanic_vtpro_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. The timeout
|
||||
// is temporary increased, because the device needs
|
||||
// approximately 6 seconds to respond.
|
||||
unsigned char answer[3] = {0};
|
||||
serial_set_timeout (device->port, 9000);
|
||||
int n = serial_read (device->port, answer, sizeof (answer));
|
||||
serial_set_timeout (device->port, 3000);
|
||||
if (n != sizeof (answer)) {
|
||||
WARNING ("Failed to receive the answer.");
|
||||
return EXITCODE (n);
|
||||
}
|
||||
|
||||
// Verify the answer.
|
||||
if (answer[0] != 0x5A || answer[2] != 0x00) {
|
||||
WARNING ("Unexpected answer byte(s).");
|
||||
return DEVICE_STATUS_PROTOCOL;
|
||||
}
|
||||
|
||||
memcpy (data, answer + 1, 1);
|
||||
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static device_status_t
|
||||
oceanic_vtpro_device_version (device_t *abstract, unsigned char data[], unsigned int size)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user