diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index d6183ae..b18791a 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -165,7 +165,7 @@ oceanic_atom2_init (oceanic_atom2_device_t *device) } // Receive the answer of the dive computer. - unsigned char answer[3] = {0}; + unsigned char answer[1] = {0}; n = serial_read (device->port, answer, sizeof (answer)); if (n != sizeof (answer)) { WARNING ("Failed to receive the answer."); @@ -173,7 +173,7 @@ oceanic_atom2_init (oceanic_atom2_device_t *device) } // Verify the answer. - if (answer[0] != NAK || answer[1] != NAK || answer[2] != NAK) { + if (answer[0] != NAK) { WARNING ("Unexpected answer byte(s)."); return DEVICE_STATUS_PROTOCOL; } @@ -273,6 +273,9 @@ oceanic_atom2_device_open (device_t **out, const char* name) return status; } + // Make sure everything is in a sane state. + serial_flush (device->port, SERIAL_QUEUE_BOTH); + // 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.