From: Antonio Ospite <ao2@ao2.it>
Date: Thu, 14 Jan 2016 14:06:42 +0000 (+0100)
Subject: visomat-data-downloader: increase the eeprom buffer size
X-Git-Url: https://git.ao2.it/visomat-utils.git/commitdiff_plain/e1d3986c78a172b4120056f03d4e2140bba0315b?ds=inline

visomat-data-downloader: increase the eeprom buffer size

Apparently the device can store up to 60 records per user, for 2 users,
and each record is 20 bytes.

Considering that the data has some header info like:

  M160...M260...

the buffer must be at least:

 (20 * 60 * 2) + 8 + 2  = 2410 bytes

Finally, the extra 2 bytes are the STX and ETX bytes.

Increase the buffer size to 4096 bytes to be safe.

Thanks-to: Cornelis Broeders <cornelis.broeders@web.de>
---

diff --git a/src/visomat-data-downloader.c b/src/visomat-data-downloader.c
index a5405a4..b471dc9 100644
--- a/src/visomat-data-downloader.c
+++ b/src/visomat-data-downloader.c
@@ -315,8 +315,8 @@ static int get_response(libusb_device_handle *dev,
 #define visomat_device libusb_device_handle
 static int visomat_dump_eeprom(visomat_device *dev, unsigned int user_mask)
 {
-	/* Assuming an EEPROM of 1 KiB  */
-	uint8_t buffer[1024] = { 0 };
+	/* Assuming an EEPROM of 4 KiB  */
+	uint8_t buffer[4096] = { 0 };
 	int ret;
 
 	ret = send_command(dev, VISOMAT_CMD_DUMP_EEPROM);