From 6bf06ad805dcccc089a7ea981641d2a61bfecb76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20P=C4=99kala?= Date: Mon, 3 Feb 2025 12:33:25 +0100 Subject: [PATCH] Add support for Toshiba TEC e-STUDIO2323AM With few subtle magicolor network protocol modifications this device seems to work pretty good. --- backend/magicolor.c | 59 ++++++++++++++++++++++++++++----- doc/descriptions/magicolor.desc | 10 ++++++ doc/sane-magicolor.man | 8 +++-- 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/backend/magicolor.c b/backend/magicolor.c index 527893769..a9ebea7da 100644 --- a/backend/magicolor.c +++ b/backend/magicolor.c @@ -105,11 +105,14 @@ static struct MagicolorCmd magicolor_cmd[] = { {"mc1690mf", CMD, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x12, NET, 0x00, 0x01, 0x02, 0x03}, {"mc4690mf", CMD, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x12, NET, 0x00, 0x01, 0x02, 0x03}, + {"es2323am", CMD, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x12, NET, 0x00, 0x01, 0x02, 0x03}, }; static SANE_Int magicolor_default_resolutions[] = {150, 300, 600}; static SANE_Int magicolor_default_depths[] = {1,8}; +static SANE_Int estudio_default_resolutions[] = {150, 200, 300, 400, 600}; + static struct MagicolorCap magicolor_cap[] = { /* KONICA MINOLTA magicolor 1690MF, USB ID 0x123b:2089 */ @@ -137,13 +140,25 @@ static struct MagicolorCap magicolor_cap[] = { {0, SANE_FIX(0x1390 * MM_PER_INCH / 600), 0}, {0, SANE_FIX(0x20dc * MM_PER_INCH / 600), 0}, }, + /* TOSHIBA e-STUDIO2323AM, USB ID 0x08a6:8056 */ + { + 0x8056, "es2323am", "e-STUDIO2323AM", ".1.3.6.1.4.1.1129.2.3.72.1", + 0x03, 0x85, + 600, {150, 600, 0}, estudio_default_resolutions, 5, + 8, magicolor_default_depths, + {-100, 100, 0}, + {0, SANE_FIX(0x13f8 * MM_PER_INCH / 600), 0}, {0, SANE_FIX(0x1b9c * MM_PER_INCH / 600), 0}, + SANE_TRUE, SANE_TRUE, + {0, SANE_FIX(0x1390 * MM_PER_INCH / 600), 0}, {0, SANE_FIX(0x20dc * MM_PER_INCH / 600), 0}, + }, + }; static int MC_SNMP_Timeout = 2500; static int MC_Scan_Data_Timeout = 15000; static int MC_Request_Timeout = 5000; - +#define ESTUDIO_DEVICE(s) ((s)->hw->cap->id == 0x8056) /**************************************************************************** * General configuration parameter definitions @@ -235,7 +250,7 @@ print_params(const SANE_Parameters params) #define MAGICOLOR_SNMP_SYSOBJECT_OID ".1.3.6.1.2.1.1.2.0" #define MAGICOLOR_SNMP_MAC_OID ".1.3.6.1.2.1.2.2.1.6.1" #define MAGICOLOR_SNMP_DEVICE_TREE ".1.3.6.1.4.1.18334.1.1.1.1.1" - +#define ESTUDIO_SNMP_DEVICE_TREE ".1.3.6.1.4.1.1129.2.3.72.1" /* We don't have a packet wrapper, which holds packet size etc., so we don't have to use a *read_raw and a *_read function... */ @@ -342,8 +357,13 @@ sanei_magicolor_net_open(struct Magicolor_Scanner *s) buf[1] = cmd->net_lock; buf[2] = 0x00; /* Copy the device's USB id to bytes 3-4: */ - buf[3] = s->hw->cap->id & 0xff; - buf[4] = (s->hw->cap->id >> 8) & 0xff; + if (ESTUDIO_DEVICE(s)) { + buf[3] = (s->hw->cap->id >> 8) & 0xff; + buf[4] = s->hw->cap->id & 0xff; + } else { + buf[3] = s->hw->cap->id & 0xff; + buf[4] = (s->hw->cap->id >> 8) & 0xff; + } DBG(32, "Proper welcome message received, locking the scanner...\n"); sanei_magicolor_net_write_raw(s, buf, 5, &status); @@ -777,8 +797,8 @@ cmd_finish_scan (SANE_Handle handle) return status; } memset (&returned[0], 0x00, 0x0b); - - status = mc_txrx (s, buf, buflen, returned, 0x0b); + /* e-STUDIO device returns 1 byte ack, while Magicolor 11 bytes */ + status = mc_txrx (s, buf, buflen, returned, ESTUDIO_DEVICE(s) ? 1 : 0x0b); free (buf); if (status != SANE_STATUS_GOOD) DBG(8, "%s: Data NOT successfully sent\n", __func__); @@ -995,7 +1015,20 @@ cmd_read_data (SANE_Handle handle, unsigned char *buf, size_t len) /* Temporarily set the poll timeout to 10 seconds instead of 2, * because a color scan needs >5 seconds to initialize. */ MC_Request_Timeout = MC_Scan_Data_Timeout; - status = mc_txrx (s, txbuf, txbuflen, buf, len); + + if (ESTUDIO_DEVICE(s)) { + /* e-STUDIO device returns 5-bytes of ack data here + * ignore it to not mess up image buffer */ + unsigned char ack[5]; + + status = mc_txrx (s, txbuf, txbuflen, ack, sizeof(ack)); + if (status == SANE_STATUS_GOOD) { + mc_recv (s, buf, len, &status); + } + } else { + status = mc_txrx (s, txbuf, txbuflen, buf, len); + } + MC_Request_Timeout = oldtimeout; free (txbuf); if (status != SANE_STATUS_GOOD) @@ -1922,8 +1955,16 @@ mc_network_discovery_handle (struct snmp_pdu *pdu, snmp_discovery_data *magic) vp->val.objid, value_len) == 0) { DBG (5, "%s: Device appears to be a magicolor device (OID=%s)\n", __func__, device); } else { - DBG (5, "%s: Device is not a Magicolor device\n", __func__); - return 0; + anOID_len = MAX_OID_LEN; + read_objid(ESTUDIO_SNMP_DEVICE_TREE, anOID, &anOID_len); + + if (netsnmp_oid_is_subtree (anOID, anOID_len, + vp->val.objid, value_len) == 0) { + DBG (5, "%s: Device appears to be a estudio device (OID=%s)\n", __func__, device); + } else { + DBG (5, "%s: Device is not a e-STUDIO / Magicolor device\n", __func__); + return 0; + } } } diff --git a/doc/descriptions/magicolor.desc b/doc/descriptions/magicolor.desc index f650c9090..9195a9a38 100644 --- a/doc/descriptions/magicolor.desc +++ b/doc/descriptions/magicolor.desc @@ -39,3 +39,13 @@ :usbid "ignore" :status :unsupported :comment "Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov." + +:mfg "Toshiba TEC" +:url "https://toshibatec.com/" + +:model "e-STUDIO2323AM" +:interface "Network" +:usbid "0x08a6" "0x8056" +:status :good +:comment "Multi-function laser printer, scanner and network interface" +:url "https://www.toshibatec.eu/products/multifunctional-systems-and-printers/e-studio2323am/" diff --git a/doc/sane-magicolor.man b/doc/sane-magicolor.man index 19716e0f8..3766f5008 100644 --- a/doc/sane-magicolor.man +++ b/doc/sane-magicolor.man @@ -1,11 +1,11 @@ .\" .IX sane-magicolor .TH "sane-magicolor" "5" "10 Jan 2011" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .SH "NAME" -sane\-magicolor \- SANE backend for KONICA MINOLTA magicolor scanners +sane\-magicolor \- SANE backend for KONICA MINOLTA magicolor and Toshiba TEC e-STUDIO scanners .SH "DESCRIPTION" The .B sane\-magicolor -backend supports KONICA MINOLTA magicolor scanners connected via USB or LAN. Currently, only the magicolor 1690MF device is supported, no other devices with the same scanning protocol are known. +backend supports KONICA MINOLTA magicolor and Toshiba TEC e-STUDIO scanners connected via USB or LAN. .SH "SUPPORTED DEVICES" The following scanner should work with this backend: @@ -16,6 +16,10 @@ Device Details Vendor: KONICA MINOLTA .br Model: magicolor 1690MF +.br +Vendor: Toshiba TEC +.br +Model: e-STUDIO2323AM .SH "CONFIGURATION" .PP