2013-07-06 10:14:06 -04:00
|
|
|
/*
|
|
|
|
* Shinko/Sinfonia CHC-S2145 CUPS backend -- libusb-1.0 version
|
|
|
|
*
|
2019-02-17 21:51:40 -05:00
|
|
|
* (c) 2013-2019 Solomon Peachy <pizza@shaftnet.org>
|
2013-07-06 10:14:06 -04:00
|
|
|
*
|
2013-07-06 19:08:17 -04:00
|
|
|
* Development of this backend was sponsored by:
|
2013-12-17 08:30:37 -05:00
|
|
|
*
|
2013-07-06 19:08:17 -04:00
|
|
|
* LiveLink Technology [ www.livelinktechnology.net ]
|
2013-12-17 08:30:37 -05:00
|
|
|
*
|
2013-07-06 10:14:06 -04:00
|
|
|
* The latest version of this program can be found at:
|
|
|
|
*
|
2013-08-20 20:10:21 -04:00
|
|
|
* http://git.shaftnet.org/cgit/selphy_print.git
|
2013-07-06 10:14:06 -04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 3 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* [http://www.gnu.org/licenses/gpl-3.0.html]
|
|
|
|
*
|
2017-11-17 13:34:26 -05:00
|
|
|
* SPDX-License-Identifier: GPL-3.0+
|
|
|
|
*
|
2013-07-06 10:14:06 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
2015-08-13 21:09:56 -04:00
|
|
|
#define BACKEND shinkos2145_backend
|
2013-07-06 10:14:06 -04:00
|
|
|
|
2015-08-13 21:09:56 -04:00
|
|
|
#include "backend_common.h"
|
2013-07-06 10:14:06 -04:00
|
|
|
|
|
|
|
enum {
|
|
|
|
S_IDLE = 0,
|
|
|
|
S_PRINTER_READY_CMD,
|
|
|
|
S_PRINTER_SENT_DATA,
|
|
|
|
S_FINISHED,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Structure of printjob header. All fields are LITTLE ENDIAN */
|
|
|
|
struct s2145_printjob_hdr {
|
|
|
|
uint32_t len1; /* Fixed at 0x10 */
|
2014-10-19 09:10:10 -04:00
|
|
|
uint32_t model; /* Equal to the printer model (eg '2145' or '1245' decimal) */
|
2015-08-16 21:58:14 -04:00
|
|
|
uint32_t unk2;
|
2014-10-19 09:10:10 -04:00
|
|
|
uint32_t unk3; /* Fixed at 0x01 */
|
2013-07-06 10:14:06 -04:00
|
|
|
|
|
|
|
uint32_t len2; /* Fixed at 0x64 */
|
|
|
|
uint32_t unk5;
|
2015-02-08 12:01:28 -05:00
|
|
|
uint32_t media;
|
2013-07-06 10:14:06 -04:00
|
|
|
uint32_t unk6;
|
|
|
|
|
2015-08-16 21:58:14 -04:00
|
|
|
uint32_t method;
|
|
|
|
uint32_t mode;
|
|
|
|
uint32_t unk7;
|
2015-02-08 12:01:28 -05:00
|
|
|
uint32_t unk8;
|
2013-07-06 10:14:06 -04:00
|
|
|
|
|
|
|
uint32_t unk9;
|
|
|
|
uint32_t columns;
|
|
|
|
uint32_t rows;
|
|
|
|
uint32_t copies;
|
|
|
|
|
|
|
|
uint32_t unk10;
|
|
|
|
uint32_t unk11;
|
|
|
|
uint32_t unk12;
|
|
|
|
uint32_t unk13;
|
|
|
|
|
|
|
|
uint32_t unk14;
|
|
|
|
uint32_t unk15;
|
|
|
|
uint32_t dpi; /* Fixed at '300' (decimal) */
|
|
|
|
uint32_t unk16;
|
|
|
|
|
|
|
|
uint32_t unk17;
|
|
|
|
uint32_t unk18;
|
|
|
|
uint32_t unk19;
|
|
|
|
uint32_t unk20;
|
|
|
|
|
|
|
|
uint32_t unk21;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
/* Structs for printer */
|
|
|
|
struct s2145_cmd_hdr {
|
|
|
|
uint16_t cmd;
|
|
|
|
uint16_t len; /* Not including this header */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define S2145_CMD_STATUS 0x0001
|
|
|
|
#define S2145_CMD_MEDIAINFO 0x0002
|
|
|
|
#define S2145_CMD_MODELNAME 0x0003
|
|
|
|
#define S2145_CMD_ERRORLOG 0x0004
|
|
|
|
#define S2145_CMD_PRINTJOB 0x4001
|
|
|
|
#define S2145_CMD_CANCELJOB 0x4002
|
|
|
|
#define S2145_CMD_FLASHLED 0x4003
|
|
|
|
#define S2145_CMD_RESET 0x4004
|
|
|
|
#define S2145_CMD_READTONE 0x4005
|
|
|
|
#define S2145_CMD_BUTTON 0x4006
|
|
|
|
#define S2145_CMD_GETUNIQUE 0x8003
|
|
|
|
#define S2145_CMD_FWINFO 0xC003
|
|
|
|
#define S2145_CMD_UPDATE 0xC004
|
|
|
|
#define S2145_CMD_SETUNIQUE 0xC007
|
|
|
|
|
2013-07-16 23:33:09 -04:00
|
|
|
static char *cmd_names(uint16_t v) {
|
|
|
|
switch (le16_to_cpu(v)) {
|
|
|
|
case S2145_CMD_STATUS:
|
|
|
|
return "Get Status";
|
|
|
|
case S2145_CMD_MEDIAINFO:
|
|
|
|
return "Get Media Info";
|
|
|
|
case S2145_CMD_MODELNAME:
|
|
|
|
return "Get Model Name";
|
|
|
|
case S2145_CMD_ERRORLOG:
|
|
|
|
return "Get Error Log";
|
|
|
|
case S2145_CMD_PRINTJOB:
|
|
|
|
return "Print";
|
|
|
|
case S2145_CMD_CANCELJOB:
|
|
|
|
return "Cancel Print";
|
|
|
|
case S2145_CMD_FLASHLED:
|
|
|
|
return "Flash LEDs";
|
|
|
|
case S2145_CMD_RESET:
|
|
|
|
return "Reset";
|
|
|
|
case S2145_CMD_READTONE:
|
|
|
|
return "Read Tone Curve";
|
|
|
|
case S2145_CMD_BUTTON:
|
|
|
|
return "Button Enable";
|
|
|
|
case S2145_CMD_GETUNIQUE:
|
|
|
|
return "Get Unique String";
|
|
|
|
case S2145_CMD_FWINFO:
|
|
|
|
return "Get Firmware Info";
|
|
|
|
case S2145_CMD_UPDATE:
|
|
|
|
return "Update";
|
|
|
|
case S2145_CMD_SETUNIQUE:
|
|
|
|
return "Set Unique String";
|
|
|
|
default:
|
|
|
|
return "Unknown Command";
|
|
|
|
}
|
2016-12-15 09:37:31 -05:00
|
|
|
}
|
2013-07-16 23:33:09 -04:00
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_print_cmd {
|
|
|
|
struct s2145_cmd_hdr hdr;
|
|
|
|
uint8_t id;
|
|
|
|
uint16_t count;
|
|
|
|
uint16_t columns;
|
|
|
|
uint16_t rows;
|
|
|
|
uint8_t media;
|
|
|
|
uint8_t mode;
|
|
|
|
uint8_t method;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 18:56:19 -04:00
|
|
|
#define PRINT_MEDIA_4x6 0x00
|
|
|
|
#define PRINT_MEDIA_5x3_5 0x01
|
|
|
|
#define PRINT_MEDIA_5x7 0x03
|
|
|
|
#define PRINT_MEDIA_6x9 0x05
|
|
|
|
#define PRINT_MEDIA_6x8 0x06
|
|
|
|
#define PRINT_MEDIA_2x6 0x07
|
|
|
|
|
2016-08-19 17:40:12 -04:00
|
|
|
static char *print_sizes (uint8_t v) {
|
2013-07-16 23:00:50 -04:00
|
|
|
switch (v) {
|
|
|
|
case PRINT_MEDIA_4x6:
|
|
|
|
return "4x6";
|
|
|
|
case PRINT_MEDIA_5x3_5:
|
|
|
|
return "5x3.5";
|
|
|
|
case PRINT_MEDIA_5x7:
|
|
|
|
return "5x7";
|
|
|
|
case PRINT_MEDIA_6x9:
|
|
|
|
return "6x9";
|
|
|
|
case PRINT_MEDIA_6x8:
|
|
|
|
return "6x8";
|
|
|
|
case PRINT_MEDIA_2x6:
|
|
|
|
return "2x6";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2016-08-19 18:00:23 -04:00
|
|
|
static int print_counts (uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case PRINT_MEDIA_4x6:
|
|
|
|
return 700;
|
|
|
|
case PRINT_MEDIA_5x3_5:
|
|
|
|
return 800;
|
|
|
|
case PRINT_MEDIA_5x7:
|
|
|
|
return 400;
|
|
|
|
case PRINT_MEDIA_6x9:
|
|
|
|
return 310;
|
|
|
|
case PRINT_MEDIA_6x8:
|
|
|
|
return 350;
|
|
|
|
default:
|
|
|
|
return 700;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-06 18:56:19 -04:00
|
|
|
#define PRINT_MODE_DEFAULT 0x01
|
|
|
|
#define PRINT_MODE_STD_GLOSSY 0x02
|
|
|
|
#define PRINT_MODE_FINE_GLOSSY 0x03
|
|
|
|
#define PRINT_MODE_STD_MATTE 0x04
|
|
|
|
#define PRINT_MODE_FINE_MATTE 0x05
|
|
|
|
#define PRINT_MODE_STD_EGLOSSY 0x06
|
|
|
|
#define PRINT_MODE_FINE_EGLOSSY 0x07
|
|
|
|
|
2013-07-18 22:10:56 -04:00
|
|
|
#if 0
|
2013-07-16 23:00:50 -04:00
|
|
|
static char *print_modes(uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case PRINT_MODE_DEFAULT:
|
|
|
|
return "Default";
|
|
|
|
case PRINT_MODE_STD_GLOSSY:
|
|
|
|
return "Std Glossy";
|
|
|
|
case PRINT_MODE_FINE_GLOSSY:
|
|
|
|
return "Fine Glossy";
|
|
|
|
case PRINT_MODE_STD_MATTE:
|
|
|
|
return "Std Matte";
|
|
|
|
case PRINT_MODE_FINE_MATTE:
|
|
|
|
return "Fine Matte";
|
|
|
|
case PRINT_MODE_STD_EGLOSSY:
|
|
|
|
return "Std ExGlossy";
|
|
|
|
case PRINT_MODE_FINE_EGLOSSY:
|
|
|
|
return "Fine ExGlossy";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2013-07-18 22:10:56 -04:00
|
|
|
#endif
|
2013-07-06 18:56:19 -04:00
|
|
|
|
|
|
|
#define PRINT_METHOD_STD 0x00
|
|
|
|
#define PRINT_METHOD_4x6_2UP 0x02
|
|
|
|
#define PRINT_METHOD_2x6_2UP 0x04
|
|
|
|
|
2017-07-10 20:15:56 -04:00
|
|
|
static char *print_methods (uint8_t v) {
|
2013-07-16 23:00:50 -04:00
|
|
|
switch (v) {
|
|
|
|
case PRINT_METHOD_STD:
|
|
|
|
return "Standard";
|
|
|
|
case PRINT_METHOD_4x6_2UP:
|
|
|
|
return "4x6 2up";
|
|
|
|
case PRINT_METHOD_2x6_2UP:
|
|
|
|
return "2x6 2up";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_cancel_cmd {
|
|
|
|
struct s2145_cmd_hdr hdr;
|
|
|
|
uint8_t id;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_reset_cmd {
|
|
|
|
struct s2145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 15:12:45 -04:00
|
|
|
#define RESET_PRINTER 0x03
|
|
|
|
#define RESET_USER_CURVE 0x04
|
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_readtone_cmd {
|
|
|
|
struct s2145_cmd_hdr hdr;
|
|
|
|
uint8_t curveid;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_button_cmd {
|
|
|
|
struct s2145_cmd_hdr hdr;
|
|
|
|
uint8_t enabled;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 15:12:45 -04:00
|
|
|
#define BUTTON_ENABLED 0x01
|
|
|
|
#define BUTTON_DISABLED 0x00
|
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_fwinfo_cmd {
|
|
|
|
struct s2145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 15:12:45 -04:00
|
|
|
#define FWINFO_TARGET_MAIN_BOOT 0x01
|
|
|
|
#define FWINFO_TARGET_MAIN_APP 0x02
|
|
|
|
#define FWINFO_TARGET_DSP_BOOT 0x03
|
|
|
|
#define FWINFO_TARGET_DSP_APP 0x04
|
|
|
|
#define FWINFO_TARGET_USB_BOOT 0x05
|
|
|
|
#define FWINFO_TARGET_USB_APP 0x06
|
|
|
|
#define FWINFO_TARGET_TABLES 0x07
|
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
static char *fwinfo_targets (uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case FWINFO_TARGET_MAIN_BOOT:
|
|
|
|
return "Main Boot";
|
|
|
|
case FWINFO_TARGET_MAIN_APP:
|
|
|
|
return "Main App ";
|
|
|
|
case FWINFO_TARGET_DSP_BOOT:
|
|
|
|
return "DSP Boot ";
|
|
|
|
case FWINFO_TARGET_DSP_APP:
|
|
|
|
return "DSP App ";
|
|
|
|
case FWINFO_TARGET_USB_BOOT:
|
|
|
|
return "USB Boot ";
|
|
|
|
case FWINFO_TARGET_USB_APP:
|
|
|
|
return "USB App ";
|
2017-07-10 20:15:56 -04:00
|
|
|
case FWINFO_TARGET_TABLES:
|
2013-07-16 23:00:50 -04:00
|
|
|
return "Tables ";
|
|
|
|
default:
|
|
|
|
return "Unknown ";
|
|
|
|
}
|
|
|
|
}
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_update_cmd {
|
|
|
|
struct s2145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
uint32_t reserved;
|
|
|
|
uint32_t size;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 22:44:51 -04:00
|
|
|
#define UPDATE_TARGET_USER 0x03
|
|
|
|
#define UPDATE_TARGET_CURRENT 0x04
|
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
static char *update_targets (uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case UPDATE_TARGET_USER:
|
|
|
|
return "User";
|
|
|
|
case UPDATE_TARGET_CURRENT:
|
|
|
|
return "Current";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2013-07-08 20:15:39 -04:00
|
|
|
|
2013-07-06 22:44:51 -04:00
|
|
|
#define UPDATE_SIZE 0x600
|
|
|
|
/* Update is three channels, Y, M, C;
|
|
|
|
each is 256 entries of 11-bit data padded to 16-bits.
|
|
|
|
Printer expects LE data. We use BE data on disk.
|
|
|
|
*/
|
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_setunique_cmd {
|
|
|
|
struct s2145_cmd_hdr hdr;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t data[23]; /* Not necessarily all used. */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_status_hdr {
|
|
|
|
uint8_t result;
|
|
|
|
uint8_t error;
|
|
|
|
uint8_t printer_major;
|
|
|
|
uint8_t printer_minor;
|
|
|
|
uint8_t reserved[3];
|
|
|
|
uint8_t status;
|
|
|
|
uint16_t payload_len;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define RESULT_SUCCESS 0x01
|
|
|
|
#define RESULT_FAIL 0x02
|
|
|
|
|
|
|
|
#define ERROR_NONE 0x00
|
|
|
|
#define ERROR_INVALID_PARAM 0x01
|
|
|
|
#define ERROR_MAIN_APP_INACTIVE 0x02
|
|
|
|
#define ERROR_COMMS_TIMEOUT 0x03
|
|
|
|
#define ERROR_MAINT_NEEDED 0x04
|
|
|
|
#define ERROR_BAD_COMMAND 0x05
|
|
|
|
#define ERROR_PRINTER 0x11
|
|
|
|
#define ERROR_BUFFER_FULL 0x21
|
|
|
|
|
2013-07-24 21:52:16 -04:00
|
|
|
static char *error_codes(uint8_t major, uint8_t minor)
|
|
|
|
{
|
|
|
|
switch(major) {
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x01: /* "Controller Error" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch(minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: EEPROM Write Timeout";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: EEPROM Verify";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP Inactive";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP Application Inactive";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x06:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Main FW Data";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x07:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Main FW Write";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x08:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP FW Data";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x09:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP FW Write";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x0A:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: 0A ASIC??";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x0B:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: 0B FPGA??";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x0D:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Tone Curve Write";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x16:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Invalid Parameter Table";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x17:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Parameter Table Data";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x18:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Parameter Table Write";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x29:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP Communication";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x2A:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP DMA Failure";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Controller: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x02: /* "Mechanical Error" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Thermal Head (Upper Up)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Thermal Head (Head Up)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x03:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Thermal Head (Head Down)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Initialize)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Mode1)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x06:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Mode2)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x07:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Mode3)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x08:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Mode4)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x09:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Cutter (Right)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x0A:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Cutter (Left)";
|
|
|
|
case 0x0B:
|
|
|
|
return "Mechanical: Thermal Head (Head Down Recovery)";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Mechanical: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x03: /* "Sensor Error" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Thermal Head";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Pinch Roller";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x03:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Cutter Left";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Cutter Right";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Cutter Unknown";
|
|
|
|
case 0x08:
|
|
|
|
return "Sensor: Ribbon Encoder (Supply)";
|
|
|
|
case 0x09:
|
|
|
|
return "Sensor: Ribbon Encoder (Takeup)";
|
|
|
|
case 0x13:
|
|
|
|
return "Sensor: Thermal Head";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Sensor: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x04: /* "Temperature Sensor Error" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Thermal Head High";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Thermal Head Low";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x03:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Environment High";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Environment Low";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Warmup Timed Out";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Temp Sensor: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x5: /* "Paper Jam" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Leading Edge Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x03:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Leading Edge On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x11:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x12:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x13:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Leading Edge On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x14:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x15:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x16:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x21:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x22:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Rewinding Print Position On";
|
|
|
|
case 0x40:
|
|
|
|
return "Paper Jam: Pre-Printing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x41:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Pre-Printing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x42:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Printing Leading Edge Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x43:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Returning Lead Edge Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x44:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Printing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x45:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Printing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x46:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Printing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x47:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Printing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x49:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Printing Lost Ribbon Mark";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x4A:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Printing Ribbon Cut";
|
|
|
|
case 0x4D:
|
|
|
|
return "Paper Jam: Printing Lost M Mark";
|
|
|
|
case 0x4E:
|
|
|
|
return "Paper Jam: Printing Lost C Mark";
|
|
|
|
case 0x4F:
|
|
|
|
return "Paper Jam: Printing Lost OP Mark";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x61:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Lead Edge On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x62:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initizlizing Print Position On";
|
|
|
|
case 0x64:
|
|
|
|
return "Paper Jam: Initizlizing Paper Size On";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Paper Jam: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x06: /* User Error */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x01:
|
|
|
|
return "Front Cover Open";
|
|
|
|
case 0x02:
|
|
|
|
return "Incorrect Ribbon";
|
|
|
|
case 0x03:
|
|
|
|
return "No Ribbon";
|
|
|
|
case 0x04:
|
|
|
|
return "Mismatched Ribbon";
|
|
|
|
case 0x05:
|
|
|
|
return "Mismatched Paper";
|
|
|
|
case 0x06:
|
|
|
|
return "Paper Empty";
|
|
|
|
case 0x08:
|
|
|
|
return "No Paper";
|
|
|
|
case 0x09:
|
|
|
|
return "Take Out Paper";
|
|
|
|
case 0x0A:
|
|
|
|
return "Cover Open Error";
|
|
|
|
case 0x0B:
|
|
|
|
return "Thermal Head Damaged";
|
|
|
|
case 0x0C:
|
|
|
|
return "Thermal Head Recovery";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Unknown";
|
2013-07-24 21:52:16 -04:00
|
|
|
}
|
|
|
|
default:
|
2013-07-25 18:19:24 -04:00
|
|
|
return "Unknown";
|
2013-07-24 21:52:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
static char *error_str(uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case ERROR_NONE:
|
|
|
|
return "None";
|
|
|
|
case ERROR_INVALID_PARAM:
|
|
|
|
return "Invalid Command Parameter";
|
|
|
|
case ERROR_MAIN_APP_INACTIVE:
|
|
|
|
return "Main App Inactive";
|
|
|
|
case ERROR_COMMS_TIMEOUT:
|
|
|
|
return "Main Communication Timeout";
|
|
|
|
case ERROR_MAINT_NEEDED:
|
2017-05-05 08:06:28 -04:00
|
|
|
return "Maintenance Needed";
|
2013-07-16 23:00:50 -04:00
|
|
|
case ERROR_BAD_COMMAND:
|
|
|
|
return "Inappropriate Command";
|
|
|
|
case ERROR_PRINTER:
|
|
|
|
return "Printer Error";
|
|
|
|
case ERROR_BUFFER_FULL:
|
|
|
|
return "Buffer Full";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
#define STATUS_READY 0x00
|
|
|
|
#define STATUS_INIT_CPU 0x31
|
|
|
|
#define STATUS_INIT_RIBBON 0x32
|
|
|
|
#define STATUS_INIT_PAPER 0x33
|
|
|
|
#define STATUS_THERMAL_PROTECT 0x34
|
|
|
|
#define STATUS_USING_PANEL 0x35
|
|
|
|
#define STATUS_SELF_DIAG 0x36
|
|
|
|
#define STATUS_DOWNLOADING 0x37
|
|
|
|
|
|
|
|
#define STATUS_FEEDING_PAPER 0x61
|
|
|
|
#define STATUS_PRE_HEAT 0x62
|
|
|
|
#define STATUS_PRINT_Y 0x63
|
|
|
|
#define STATUS_BACK_FEED_Y 0x64
|
|
|
|
#define STATUS_PRINT_M 0x65
|
|
|
|
#define STATUS_BACK_FEED_M 0x66
|
|
|
|
#define STATUS_PRINT_C 0x67
|
|
|
|
#define STATUS_BACK_FEED_C 0x68
|
2013-07-16 23:00:50 -04:00
|
|
|
#define STATUS_PRINT_OP 0x69
|
2013-07-06 10:14:06 -04:00
|
|
|
#define STATUS_PAPER_CUT 0x6A
|
|
|
|
#define STATUS_PAPER_EJECT 0x6B
|
|
|
|
#define STATUS_BACK_FEED_E 0x6C
|
|
|
|
#define STATUS_FINISHED 0x6D
|
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
static char *status_str(uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case STATUS_READY:
|
|
|
|
return "Ready";
|
|
|
|
case STATUS_INIT_CPU:
|
|
|
|
return "Initializing CPU";
|
|
|
|
case STATUS_INIT_RIBBON:
|
|
|
|
return "Initializing Ribbon";
|
|
|
|
case STATUS_INIT_PAPER:
|
|
|
|
return "Loading Paper";
|
|
|
|
case STATUS_THERMAL_PROTECT:
|
|
|
|
return "Thermal Protection";
|
|
|
|
case STATUS_USING_PANEL:
|
|
|
|
return "Using Operation Panel";
|
|
|
|
case STATUS_SELF_DIAG:
|
|
|
|
return "Processing Self Diagnosis";
|
|
|
|
case STATUS_DOWNLOADING:
|
|
|
|
return "Processing Download";
|
|
|
|
case STATUS_FEEDING_PAPER:
|
|
|
|
return "Feeding Paper";
|
|
|
|
case STATUS_PRE_HEAT:
|
|
|
|
return "Pre-Heating";
|
|
|
|
case STATUS_PRINT_Y:
|
|
|
|
return "Printing Yellow";
|
|
|
|
case STATUS_BACK_FEED_Y:
|
2013-07-16 23:35:34 -04:00
|
|
|
return "Back-Feeding - Yellow Complete";
|
2013-07-16 23:00:50 -04:00
|
|
|
case STATUS_PRINT_M:
|
|
|
|
return "Printing Magenta";
|
|
|
|
case STATUS_BACK_FEED_M:
|
2013-07-16 23:35:34 -04:00
|
|
|
return "Back-Feeding - Magenta Complete";
|
2013-07-16 23:00:50 -04:00
|
|
|
case STATUS_PRINT_C:
|
|
|
|
return "Printing Cyan";
|
|
|
|
case STATUS_BACK_FEED_C:
|
2013-07-16 23:35:34 -04:00
|
|
|
return "Back-Feeding - Cyan Complete";
|
2013-07-16 23:00:50 -04:00
|
|
|
case STATUS_PRINT_OP:
|
|
|
|
return "Laminating";
|
|
|
|
case STATUS_PAPER_CUT:
|
|
|
|
return "Cutting Paper";
|
|
|
|
case STATUS_PAPER_EJECT:
|
|
|
|
return "Ejecting Paper";
|
|
|
|
case STATUS_BACK_FEED_E:
|
2013-07-16 23:35:34 -04:00
|
|
|
return "Back-Feeding - Ejected";
|
2013-07-16 23:00:50 -04:00
|
|
|
case STATUS_FINISHED:
|
2013-07-16 23:35:34 -04:00
|
|
|
return "Print Finished";
|
2013-07-25 18:17:49 -04:00
|
|
|
case ERROR_PRINTER:
|
|
|
|
return "Printer Error";
|
2013-07-16 23:00:50 -04:00
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_status_resp {
|
|
|
|
struct s2145_status_hdr hdr;
|
|
|
|
uint32_t count_lifetime;
|
|
|
|
uint32_t count_maint;
|
|
|
|
uint32_t count_paper;
|
|
|
|
uint32_t count_cutter;
|
|
|
|
uint32_t count_head;
|
|
|
|
uint32_t count_ribbon_left;
|
|
|
|
uint8_t bank1_printid;
|
|
|
|
uint8_t bank2_printid;
|
|
|
|
uint16_t bank1_remaining;
|
|
|
|
uint16_t bank1_finished;
|
|
|
|
uint16_t bank1_specified;
|
|
|
|
uint8_t bank1_status;
|
|
|
|
uint16_t bank2_remaining;
|
|
|
|
uint16_t bank2_finished;
|
|
|
|
uint16_t bank2_specified;
|
|
|
|
uint8_t bank2_status;
|
|
|
|
uint8_t tonecurve_status;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define BANK_STATUS_FREE 0x00
|
|
|
|
#define BANK_STATUS_XFER 0x01
|
|
|
|
#define BANK_STATUS_FULL 0x02
|
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
static char *bank_statuses(uint8_t v)
|
|
|
|
{
|
|
|
|
switch (v) {
|
2015-07-02 22:43:43 -04:00
|
|
|
case BANK_STATUS_FREE:
|
2013-07-16 23:00:50 -04:00
|
|
|
return "Free";
|
2015-07-02 22:43:43 -04:00
|
|
|
case BANK_STATUS_XFER:
|
2013-07-16 23:00:50 -04:00
|
|
|
return "Xfer";
|
2015-07-02 22:43:43 -04:00
|
|
|
case BANK_STATUS_FULL:
|
2013-07-16 23:00:50 -04:00
|
|
|
return "Full";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2013-07-06 20:29:30 -04:00
|
|
|
#define TONECURVE_INIT 0x00
|
|
|
|
#define TONECURVE_USER 0x01
|
|
|
|
#define TONECURVE_CURRENT 0x02
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
static char *tonecurve_statuses (uint8_t v)
|
|
|
|
{
|
|
|
|
switch(v) {
|
|
|
|
case 0:
|
|
|
|
return "Initial";
|
|
|
|
case 1:
|
|
|
|
return "UserSet";
|
|
|
|
case 2:
|
|
|
|
return "Current";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_readtone_resp {
|
|
|
|
struct s2145_status_hdr hdr;
|
2013-07-06 20:29:30 -04:00
|
|
|
uint16_t total_size;
|
2013-07-06 10:14:06 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_mediainfo_item {
|
|
|
|
uint8_t code;
|
|
|
|
uint16_t columns;
|
|
|
|
uint16_t rows;
|
|
|
|
uint8_t media_type;
|
2015-08-16 21:58:14 -04:00
|
|
|
uint8_t print_type; /* The same as the "print method" */
|
2013-07-06 10:14:06 -04:00
|
|
|
uint8_t reserved[3];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 18:56:19 -04:00
|
|
|
#define MEDIA_TYPE_UNKNOWN 0x00
|
|
|
|
#define MEDIA_TYPE_PAPER 0x01
|
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
static char *media_types(uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case MEDIA_TYPE_UNKNOWN:
|
|
|
|
return "Unknown";
|
|
|
|
case MEDIA_TYPE_PAPER:
|
|
|
|
return "Paper";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_mediainfo_resp {
|
|
|
|
struct s2145_status_hdr hdr;
|
|
|
|
uint8_t count;
|
|
|
|
struct s2145_mediainfo_item items[10]; /* Not all necessarily used */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_modelname_resp {
|
|
|
|
struct s2145_status_hdr hdr;
|
|
|
|
uint8_t vendor[4];
|
|
|
|
uint8_t product[4];
|
|
|
|
uint8_t modelname[40];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_error_item {
|
|
|
|
uint8_t major;
|
|
|
|
uint8_t minor;
|
|
|
|
uint32_t print_counter;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 13:39:00 -04:00
|
|
|
struct s2145_errorlog_resp {
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_status_hdr hdr;
|
|
|
|
uint8_t count;
|
|
|
|
struct s2145_error_item items[10]; /* Not all necessarily used */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|