This is an updated version of the patch from the version -16 sources changed 
to make the second button work as mentioned above.

Also I noticed this patch is still not applied, have any problems occurred 
with it?

Regards,
Christoph Schloen
--- a/backends/snapscan.c
+++ b/backends/snapscan.c
@@ -29,13 +29,14 @@
 
 static char* backend_name = "Snapscan USB";
 
-#define NUM_SUPPORTED_USB_DEVICES 4
+#define NUM_SUPPORTED_USB_DEVICES 5
 
 static int supported_usb_devices[NUM_SUPPORTED_USB_DEVICES][3] = {
 	{ 0x04b8, 0x0121, 4 },	// Epson Perfection 2480
 	{ 0x04b8, 0x011f, 4 },	// Epson Perfection 1670
 	{ 0x04b8, 0x0122, 4 },	// Epson Perfection 3490
-	{ 0x04b8, 0x0120, 4 }   // Epson Perfection 1270
+	{ 0x04b8, 0x0120, 4 },  // Epson Perfection 1270
+	{ 0x04c5, 0x11a2, 1 },
 };
 
 // TODO: check if this backend really works on the Epson 2580 too...
@@ -43,7 +44,8 @@
 	   { "Epson", "Perfection 2480 / 2580" },
 	   { "Epson", "Perfection 1670" },
 	   { "Epson", "Perfection 3490 / 3590" },
-	   { "Epson", "Perfection 1270" }
+	   { "Epson", "Perfection 1270" },
+	   { "Fujitsu", "ScanSnap S1500" },
 };
 
 
@@ -227,7 +229,16 @@
 	}
 }
 
-
+static unsigned char CMD[] = {
+	0x43, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0xc2, 
+	0x00, 0x00, 0x00, 0x00, 
+	0x00, 0x00, 0x00, 0x0a, 
+	0x00, 0x00, 0x00,
+	};
 
 int scanbtnd_get_button(scanner_t* scanner)
 {
@@ -235,59 +246,36 @@
 	int num_bytes;
 	int button = 0;
 
-	bytes[0] = 0x03;
-	bytes[1] = 0x00;
-	bytes[2] = 0x00;
-	bytes[3] = 0x00;
-	bytes[4] = 0x14;
-	bytes[5] = 0x00;
-
 	if (!scanner->is_open)
 		return -EINVAL;
 
-	num_bytes = snapscan_write(scanner, (void*)bytes, 6);
-	if (num_bytes != 6) {
+	num_bytes = snapscan_write(scanner, (void*)CMD, sizeof CMD);
+	if (num_bytes != (sizeof CMD)) {
 		syslog(LOG_WARNING, "snapscan-backend: communication error: "
-			"write length:%d (expected:%d)", num_bytes, 6);
+			"write length:%d (expected:%d)", num_bytes, sizeof CMD);
 		snapscan_flush(scanner);
 		return 0;
 	}
 
-	num_bytes = snapscan_read(scanner, (void*)bytes, 8);
-	if (num_bytes != 8 || bytes[0] != 0xF9) {
+	num_bytes = snapscan_read(scanner, (void*)bytes, 10);
+	if (num_bytes != 10) {
 		syslog(LOG_WARNING, "snapscan-backend: communication error: "
-			"read length:%d (expected:%d), "
-			"byte[0]:%x (expected:%x)", 
-			num_bytes, 8, bytes[0], 0xF9);
+			"read length:%d (expected:%d)",
+			num_bytes, sizeof CMD);
 		snapscan_flush(scanner);
 		return 0;
 	}
-
-	num_bytes = snapscan_read(scanner, (void*)bytes, 20);
-	if (num_bytes != 20 || bytes[0] != 0xF0) {
-		syslog(LOG_WARNING, "snapscan-backend: communication error: "
-			"read length:%d (expected:%d), "
-			"byte[0]:%x (expected:%x)", 
-			num_bytes, 20, bytes[0], 0xF0);
-		snapscan_flush(scanner); 
-		return 0;
+	if (bytes[4] == 0x01) {
+		button = 1;
 	}
-	if (bytes[2] == 0x06) {
-		switch (bytes[18] & 0xF0) {
-			case 0x10: button = 1; break;
-			case 0x20: button = 2; break;
-			case 0x40: button = 3; break;
-			case 0x80: button = 4; break;
-			default: button = 0; break;
-		}
+	if (bytes[4] == 0x20) {
+		button = 2;
 	}
-
-	num_bytes = snapscan_read(scanner, (void*)bytes, 8);
-	if (num_bytes != 8 || bytes[0] != 0xFB) {
+	num_bytes = snapscan_read(scanner, (void*)bytes, 13);
+	if (num_bytes != 13) {
 		syslog(LOG_WARNING, "snapscan-backend: communication error: "
-			"read length:%d (expected:%d), "
-			"byte[0]:%x (expected:%x)", 
-			num_bytes, 8, bytes[0], 0xFB);
+			"read length:%d (expected:%d)",
+			num_bytes, 13);
 		snapscan_flush(scanner);
 		return 0;
 	}

Reply via email to