diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index d1189c7..ede2658 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -197,6 +197,15 @@ mares_iconhd_packet (mares_iconhd_device_t *device, return status; } + // Send the command payload to the dive computer. + if (size) { + status = dc_iostream_write (device->iostream, data, size, NULL); + if (status != DC_STATUS_SUCCESS) { + ERROR (abstract->context, "Failed to send the command."); + return status; + } + } + // Receive the header byte. unsigned char header[1] = {0}; status = dc_iostream_read (device->iostream, header, sizeof (header), NULL); @@ -211,15 +220,6 @@ mares_iconhd_packet (mares_iconhd_device_t *device, return DC_STATUS_PROTOCOL; } - // Send the command payload to the dive computer. - if (size) { - status = dc_iostream_write (device->iostream, data, size, NULL); - if (status != DC_STATUS_SUCCESS) { - ERROR (abstract->context, "Failed to send the command."); - return status; - } - } - // Read the packet. status = dc_iostream_read (device->iostream, answer, asize, NULL); if (status != DC_STATUS_SUCCESS) {