From 30ff9e667ac6c07e6f5ed98abe6bf2c7d8e14cec Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 16 Apr 2008 17:48:50 +0000 Subject: [PATCH] Fixed a mistake in the transfer protocol. The device sends the size of the data stream before the actual data. --- uwatec_smart.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) {