From c4f62d9410dc8e7b68a0c93a21a86cc22d7eb027 Mon Sep 17 00:00:00 2001 From: Denny Page Date: Thu, 17 Nov 2011 20:35:52 +0100 Subject: [PATCH] Remove the init command from the initialization sequence. The init command appears to behave more like a hard reset. If the command is sent during the communication, the device immediately closes the connection and no further communication is possible without disconnecting and reconnecting the device. Sending the command at the start of the communication seems to require a long delay before sending the next command. However the communication works equally well without sending this command. For some devices it even improves the success rate of the initialization sequence, and thus there is no reason to keep it. --- src/oceanic_atom2.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index 0650a2b..68d904c 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -253,25 +253,6 @@ oceanic_atom2_transfer (oceanic_atom2_device_t *device, const unsigned char comm } -static device_status_t -oceanic_atom2_init (oceanic_atom2_device_t *device) -{ - // Send the command to the dive computer. - unsigned char command[3] = {0xA8, 0x99, 0x00}; - device_status_t rc = oceanic_atom2_send (device, command, sizeof (command), NAK); - if (rc != DEVICE_STATUS_SUCCESS) - return rc; - - // Wait before sending the next command. - serial_sleep (1000); - - // Discard all additional bytes (if there are any) - serial_flush (device->port, SERIAL_QUEUE_INPUT); - - return DEVICE_STATUS_SUCCESS; -} - - static device_status_t oceanic_atom2_quit (oceanic_atom2_device_t *device) { @@ -336,18 +317,10 @@ oceanic_atom2_device_open (device_t **out, const char* name) // Make sure everything is in a sane state. serial_flush (device->port, SERIAL_QUEUE_BOTH); - // Send the init command. - 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. - status = oceanic_atom2_device_version ((device_t *) device, device->version, sizeof (device->version)); + device_status_t status = oceanic_atom2_device_version ((device_t *) device, device->version, sizeof (device->version)); if (status != DEVICE_STATUS_SUCCESS) { serial_close (device->port); free (device);