Do not ignore errors during initialization.

This commit is contained in:
Jef Driesen 2010-01-25 14:08:01 +00:00
parent 898f27ad2e
commit a14b0b7b98
3 changed files with 42 additions and 7 deletions

View File

@ -273,12 +273,22 @@ oceanic_atom2_device_open (device_t **out, const char* name)
serial_flush (device->port, SERIAL_QUEUE_BOTH);
// Send the init command.
oceanic_atom2_init (device);
device_status_t status = oceanic_atom2_init (device);
if (status != DEVICE_STATUS_SUCCESS) {
serial_close (device->port);
free (device);
return status;
}
// Switch the device from surface mode into download mode. Before sending
// this command, the device needs to be in PC mode (automatically activated
// by connecting the device), or already in download mode.
oceanic_atom2_device_version ((device_t *) device, device->version, sizeof (device->version));
status = oceanic_atom2_device_version ((device_t *) device, device->version, sizeof (device->version));
if (status != DEVICE_STATUS_SUCCESS) {
serial_close (device->port);
free (device);
return status;
}
*out = (device_t*) device;

View File

@ -273,7 +273,12 @@ oceanic_veo250_device_open (device_t **out, const char* name)
serial_flush (device->port, SERIAL_QUEUE_BOTH);
// Initialize the data cable (PPS mode).
oceanic_veo250_init (device);
device_status_t status = oceanic_veo250_init (device);
if (status != DEVICE_STATUS_SUCCESS) {
serial_close (device->port);
free (device);
return status;
}
// Delay the sending of the version command.
serial_sleep (100);
@ -281,7 +286,12 @@ oceanic_veo250_device_open (device_t **out, const char* name)
// Switch the device from surface mode into download mode. Before sending
// this command, the device needs to be in PC mode (manually activated by
// the user), or already in download mode.
oceanic_veo250_device_version ((device_t *) device, device->version, sizeof (device->version));
status = oceanic_veo250_device_version ((device_t *) device, device->version, sizeof (device->version));
if (status != DEVICE_STATUS_SUCCESS) {
serial_close (device->port);
free (device);
return status;
}
*out = (device_t*) device;

View File

@ -292,17 +292,32 @@ oceanic_vtpro_device_open (device_t **out, const char* name)
serial_flush (device->port, SERIAL_QUEUE_BOTH);
// Initialize the data cable (MOD mode).
oceanic_vtpro_init (device);
device_status_t status = oceanic_vtpro_init (device);
if (status != DEVICE_STATUS_SUCCESS) {
serial_close (device->port);
free (device);
return status;
}
// Switch the device from surface mode into download mode. Before sending
// this command, the device needs to be in PC mode (manually activated by
// the user), or already in download mode.
oceanic_vtpro_device_version ((device_t *) device, device->version, sizeof (device->version));
status = oceanic_vtpro_device_version ((device_t *) device, device->version, sizeof (device->version));
if (status != DEVICE_STATUS_SUCCESS) {
serial_close (device->port);
free (device);
return status;
}
// Calibrate the device. Although calibration is optional, it's highly
// recommended because it reduces the transfer time considerably, even
// when processing the command itself is quite slow.
oceanic_vtpro_calibrate (device);
status = oceanic_vtpro_calibrate (device);
if (status != DEVICE_STATUS_SUCCESS) {
serial_close (device->port);
free (device);
return status;
}
*out = (device_t*) device;