diff --git a/uwatec_smart.c b/uwatec_smart.c index b0ed1e8..0c53697 100644 --- a/uwatec_smart.c +++ b/uwatec_smart.c @@ -1,6 +1,7 @@ #include // malloc, free #include // strncmp, strstr #include // time, strftime +#include // assert #include "uwatec.h" #include "irda.h" @@ -297,6 +298,17 @@ uwatec_smart_read (smart *device, unsigned char data[], unsigned int msize) free (package); return EXITCODE (rc); } + rc = irda_socket_read (device->socket, answer, 4); + if (rc != 4) { + WARNING ("Failed to receive the answer."); + return EXITCODE (rc); + } + + unsigned int length = answer[0] + (answer[1] << 8) + + (answer[2] << 16) + (answer[3] << 24); + message ("handshake: size=%u\n", length); + + assert (length == size + 4); unsigned int nbytes = 0; while (nbytes < size) {