2015-02-08 12:01:28 -05:00
|
|
|
/*
|
|
|
|
* Shinko/Sinfonia CHC-S1245 CUPS backend -- libusb-1.0 version
|
|
|
|
*
|
|
|
|
* (c) 2013-2015 Solomon Peachy <pizza@shaftnet.org>
|
|
|
|
*
|
2015-02-21 10:53:53 -05:00
|
|
|
* Low-level documentation was provided by Sinfonia, Inc. Thank you!
|
2015-02-08 12:01:28 -05:00
|
|
|
*
|
|
|
|
* The latest version of this program can be found at:
|
|
|
|
*
|
|
|
|
* http://git.shaftnet.org/cgit/selphy_print.git
|
|
|
|
*
|
|
|
|
* 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]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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 shinkos1245_backend
|
|
|
|
|
2015-02-08 12:01:28 -05:00
|
|
|
#include "backend_common.h"
|
|
|
|
|
|
|
|
/* Structure of printjob header. All fields are LITTLE ENDIAN */
|
|
|
|
struct s1245_printjob_hdr {
|
|
|
|
uint32_t len1; /* Fixed at 0x10 */
|
|
|
|
uint32_t model; /* Equal to the printer model (eg '1245' or '2145' decimal) */
|
|
|
|
uint32_t unk2; /* Null */
|
|
|
|
uint32_t unk3; /* Fixed at 0x01 */
|
|
|
|
|
|
|
|
uint32_t len2; /* Fixed at 0x64 */
|
|
|
|
uint32_t unk5; /* Null */
|
|
|
|
uint32_t media; /* Fixed at 0x10 */
|
|
|
|
uint32_t unk6; /* Null */
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 12:01:28 -05:00
|
|
|
uint32_t method; /* Print Method */
|
|
|
|
uint32_t mode; /* Print Mode */
|
|
|
|
uint32_t unk7; /* Null */
|
|
|
|
int32_t mattedepth; /* 0x7fffffff for glossy, 0x00 +- 25 for matte */
|
|
|
|
|
|
|
|
uint32_t dust; /* Dust control */
|
|
|
|
uint32_t columns;
|
|
|
|
uint32_t rows;
|
|
|
|
uint32_t copies;
|
|
|
|
|
|
|
|
uint32_t unk10; /* Null */
|
|
|
|
uint32_t unk11; /* Null */
|
|
|
|
uint32_t unk12; /* Null */
|
|
|
|
uint32_t unk13; /* 0xceffffff */
|
|
|
|
|
|
|
|
uint32_t unk14; /* Null */
|
|
|
|
uint32_t unk15; /* 0xceffffff */
|
|
|
|
uint32_t dpi; /* Fixed at '300' (decimal) */
|
|
|
|
uint32_t unk16; /* 0xceffffff */
|
|
|
|
|
|
|
|
uint32_t unk17; /* Null */
|
|
|
|
uint32_t unk18; /* 0xceffffff */
|
|
|
|
uint32_t unk19; /* Null */
|
|
|
|
uint32_t unk20; /* Null */
|
|
|
|
|
|
|
|
uint32_t unk21; /* Null */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 13:17:33 -05:00
|
|
|
/* Printer data structures */
|
|
|
|
struct shinkos1245_cmd_hdr {
|
|
|
|
uint8_t prefix; /* 0x03 */
|
|
|
|
uint8_t hdr[4]; /* 0x1b 0x43 0x48 0x43 */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
/* Get Printer ID */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_getid {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0x12 */
|
|
|
|
uint8_t pad[11];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct shinkos1245_resp_getid {
|
|
|
|
uint8_t id; /* 0x00 */
|
|
|
|
uint8_t data[23]; /* padded with 0x20 (space) */
|
2015-08-25 18:09:51 -04:00
|
|
|
uint8_t reserved[8]; // XXX actual serial number?
|
2015-02-08 13:17:33 -05:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
/* Set Printer ID -- Returns Status */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_setid {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[2]; /* 0x0a 0x22 */
|
|
|
|
uint8_t id; /* 0x00 */
|
|
|
|
uint8_t data[23]; /* pad with 0x20 (space) */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
/* Print -- Returns Status */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_print {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[2]; /* 0x0a 0x00 */
|
|
|
|
uint8_t id; /* 1-255 */
|
2015-02-09 21:43:55 -05:00
|
|
|
uint16_t count; /* # Copies in BCD, 1-9999 */
|
2015-08-20 23:13:09 -04:00
|
|
|
uint16_t columns; /* Fixed at 2446 */
|
2015-02-08 13:17:33 -05:00
|
|
|
uint16_t rows;
|
|
|
|
uint8_t media; /* Fixed at 0x10 */
|
|
|
|
uint8_t mode; /* dust removal and lamination mode */
|
2015-02-08 15:33:17 -05:00
|
|
|
uint8_t combo; /* aka "print method" in the spool file */
|
2015-02-08 13:17:33 -05:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
/* Get Status */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_getstatus {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0x03 */
|
|
|
|
uint8_t pad[10];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct shinkos1245_resp_status {
|
|
|
|
uint8_t code;
|
|
|
|
uint8_t print_status;
|
2015-02-08 15:33:17 -05:00
|
|
|
struct {
|
|
|
|
uint8_t status1;
|
2015-02-10 22:39:18 -05:00
|
|
|
uint32_t status2; /* BE */
|
2015-02-08 15:33:17 -05:00
|
|
|
uint8_t error;
|
|
|
|
} state;
|
2015-02-08 13:17:33 -05:00
|
|
|
struct {
|
|
|
|
uint32_t lifetime; /* BE */
|
|
|
|
uint32_t maint; /* BE */
|
|
|
|
uint32_t media; /* BE */
|
|
|
|
uint32_t cutter; /* BE */
|
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t ver_boot;
|
2015-02-08 18:59:26 -05:00
|
|
|
uint8_t ver_ctrl;
|
2015-02-08 15:33:17 -05:00
|
|
|
uint8_t control_flag; // 0x00 == epson, 0x01 == cypress
|
2015-02-08 13:17:33 -05:00
|
|
|
} counters;
|
|
|
|
struct {
|
|
|
|
uint16_t main_boot;
|
|
|
|
uint16_t main_control;
|
|
|
|
uint16_t dsp_boot;
|
2015-05-14 18:08:59 -04:00
|
|
|
uint16_t dsp_control;
|
2015-02-08 13:17:33 -05:00
|
|
|
} versions;
|
|
|
|
struct {
|
|
|
|
uint8_t bank1_id;
|
|
|
|
uint8_t bank2_id;
|
|
|
|
uint16_t bank1_remain; /* BE */
|
|
|
|
uint16_t bank1_complete; /* BE */
|
|
|
|
uint16_t bank1_spec; /* BE */
|
|
|
|
uint16_t bank2_remain; /* BE */
|
|
|
|
uint16_t bank2_complete; /* BE */
|
2015-05-14 18:08:59 -04:00
|
|
|
uint16_t bank2_spec; /* BE */
|
2015-02-08 13:17:33 -05:00
|
|
|
} counters2;
|
|
|
|
uint8_t curve_status;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
enum {
|
|
|
|
CMD_CODE_OK = 1,
|
|
|
|
CMD_CODE_BAD = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
STATUS_PRINTING = 1,
|
|
|
|
STATUS_IDLE = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
STATE_STATUS1_STANDBY = 1,
|
|
|
|
STATE_STATUS1_ERROR = 2,
|
|
|
|
STATE_STATUS1_WAIT = 3,
|
|
|
|
};
|
|
|
|
|
2015-02-08 18:59:26 -05:00
|
|
|
#define STATE_STANDBY_STATUS2 0x0
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
enum {
|
|
|
|
WAIT_STATUS2_INIT = 0,
|
|
|
|
WAIT_STATUS2_RIBBON = 1,
|
|
|
|
WAIT_STATUS2_THERMAL = 2,
|
|
|
|
WAIT_STATUS2_OPERATING = 3,
|
2015-05-14 18:08:59 -04:00
|
|
|
WAIT_STATUS2_BUSY = 4,
|
2015-02-08 15:33:17 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ERROR_STATUS2_CTRL_CIRCUIT (1<<31)
|
|
|
|
#define ERROR_STATUS2_MECHANISM_CTRL (1<<30)
|
|
|
|
#define ERROR_STATUS2_SENSOR (1<<13)
|
|
|
|
#define ERROR_STATUS2_COVER_OPEN (1<<12)
|
|
|
|
#define ERROR_STATUS2_TEMP_SENSOR (1<<9)
|
|
|
|
#define ERROR_STATUS2_PAPER_JAM (1<<8)
|
|
|
|
#define ERROR_STATUS2_PAPER_EMPTY (1<<6)
|
|
|
|
#define ERROR_STATUS2_RIBBON_ERR (1<<4)
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CTRL_CIR_ERROR_EEPROM1 = 0x01,
|
|
|
|
CTRL_CIR_ERROR_EEPROM2 = 0x02,
|
|
|
|
CTRL_CIR_ERROR_DSP = 0x04,
|
|
|
|
CTRL_CIR_ERROR_CRC_MAIN = 0x06,
|
|
|
|
CTRL_CIR_ERROR_DL_MAIN = 0x07,
|
|
|
|
CTRL_CIR_ERROR_CRC_DSP = 0x08,
|
|
|
|
CTRL_CIR_ERROR_DL_DSP = 0x09,
|
|
|
|
CTRL_CIR_ERROR_ASIC = 0x0a,
|
|
|
|
CTRL_CIR_ERROR_DRAM = 0x0b,
|
|
|
|
CTRL_CIR_ERROR_DSPCOMM = 0x29,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MECH_ERROR_HEAD_UP = 0x01,
|
|
|
|
MECH_ERROR_HEAD_DOWN = 0x02,
|
|
|
|
MECH_ERROR_MAIN_PINCH_UP = 0x03,
|
|
|
|
MECH_ERROR_MAIN_PINCH_DOWN = 0x04,
|
|
|
|
MECH_ERROR_SUB_PINCH_UP = 0x05,
|
|
|
|
MECH_ERROR_SUB_PINCH_DOWN = 0x06,
|
|
|
|
MECH_ERROR_FEEDIN_PINCH_UP = 0x07,
|
|
|
|
MECH_ERROR_FEEDIN_PINCH_DOWN = 0x08,
|
|
|
|
MECH_ERROR_FEEDOUT_PINCH_UP = 0x09,
|
|
|
|
MECH_ERROR_FEEDOUT_PINCH_DOWN = 0x0a,
|
|
|
|
MECH_ERROR_CUTTER_LR = 0x0b,
|
|
|
|
MECH_ERROR_CUTTER_RL = 0x0c,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
SENSOR_ERROR_CUTTER = 0x05,
|
|
|
|
SENSOR_ERROR_HEAD_DOWN = 0x09,
|
|
|
|
SENSOR_ERROR_HEAD_UP = 0x0a,
|
|
|
|
SENSOR_ERROR_MAIN_PINCH_DOWN = 0x0b,
|
|
|
|
SENSOR_ERROR_MAIN_PINCH_UP = 0x0c,
|
|
|
|
SENSOR_ERROR_FEED_PINCH_DOWN = 0x0d,
|
|
|
|
SENSOR_ERROR_FEED_PINCH_UP = 0x0e,
|
|
|
|
SENSOR_ERROR_EXIT_PINCH_DOWN = 0x0f,
|
|
|
|
SENSOR_ERROR_EXIT_PINCH_UP = 0x10,
|
|
|
|
SENSOR_ERROR_LEFT_CUTTER = 0x11,
|
|
|
|
SENSOR_ERROR_RIGHT_CUTTER = 0x12,
|
|
|
|
SENSOR_ERROR_CENTER_CUTTER = 0x13,
|
|
|
|
SENSOR_ERROR_UPPER_CUTTER = 0x14,
|
|
|
|
SENSOR_ERROR_PAPER_FEED_COVER = 0x15,
|
2015-05-14 18:08:59 -04:00
|
|
|
};
|
2015-02-08 15:33:17 -05:00
|
|
|
|
|
|
|
enum {
|
|
|
|
TEMP_SENSOR_ERROR_HEAD_HIGH = 0x01,
|
|
|
|
TEMP_SENSOR_ERROR_HEAD_LOW = 0x02,
|
|
|
|
TEMP_SENSOR_ERROR_ENV_HIGH = 0x03,
|
|
|
|
TEMP_SENSOR_ERROR_ENV_LOW = 0x04,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
COVER_OPEN_ERROR_UPPER = 0x01,
|
|
|
|
COVER_OPEN_ERROR_LOWER = 0x02,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PAPER_EMPTY_ERROR = 0x00,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RIBBON_ERROR = 0x00,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CURVE_TABLE_STATUS_INITIAL = 0x00,
|
|
|
|
CURVE_TABLE_STATUS_USERSET = 0x01,
|
|
|
|
CURVE_TABLE_STATUS_CURRENT = 0x02,
|
|
|
|
};
|
|
|
|
|
|
|
|
// XXX Paper jam has 0x01 -> 0xff as error codes
|
|
|
|
|
|
|
|
/* Query media info */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_getmedia {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0x1a/0x2a/0x3a for A/B/C */
|
2015-05-14 18:08:59 -04:00
|
|
|
uint8_t pad[10];
|
2015-02-08 13:17:33 -05:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 18:59:26 -05:00
|
|
|
struct shinkos1245_mediadesc {
|
|
|
|
uint8_t code; /* Fixed at 0x10 */
|
|
|
|
uint16_t columns; /* BE */
|
|
|
|
uint16_t rows; /* BE */
|
|
|
|
uint8_t type; /* MEDIA_TYPE_* */
|
|
|
|
uint8_t print_type; /* aka "print method" in the spool file */
|
|
|
|
uint8_t reserved[3];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-08-20 22:41:58 -04:00
|
|
|
#define NUM_MEDIAS 5 /* Maximum per message */
|
|
|
|
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_resp_media {
|
|
|
|
uint8_t code;
|
|
|
|
uint8_t reserved[5];
|
2015-02-08 18:59:26 -05:00
|
|
|
uint8_t count; /* 1-5? */
|
2015-08-20 22:41:58 -04:00
|
|
|
struct shinkos1245_mediadesc data[NUM_MEDIAS];
|
2015-02-08 13:17:33 -05:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
enum {
|
|
|
|
MEDIA_TYPE_UNKNOWN = 0x00,
|
|
|
|
MEDIA_TYPE_PAPER = 0x01,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PRINT_TYPE_STANDARD = 0x00,
|
|
|
|
PRINT_TYPE_8x5_2up = 0x01,
|
|
|
|
PRINT_TYPE_8x4_2up = 0x02,
|
|
|
|
PRINT_TYPE_8x6_8x4 = 0x03,
|
|
|
|
PRINT_TYPE_8x5 = 0x04,
|
|
|
|
PRINT_TYPE_8x4 = 0x05,
|
|
|
|
PRINT_TYPE_8x6 = 0x06,
|
|
|
|
PRINT_TYPE_8x6_2up = 0x07,
|
|
|
|
PRINT_TYPE_8x4_3up = 0x08,
|
|
|
|
PRINT_TYPE_8x8 = 0x09,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Cancel Job -- returns Status */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_canceljob {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0x13 */
|
|
|
|
uint8_t id; /* 1-255 */
|
|
|
|
uint8_t pad[9];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
/* Reset printer -- returns Status */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_reset {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0xc0 */
|
|
|
|
uint8_t pad[10];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
/* Tone curve manipulation -- returns Status */
|
2015-02-08 18:59:26 -05:00
|
|
|
struct shinkos1245_cmd_tone {
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0xc0 */
|
|
|
|
uint8_t tone[4]; /* 0x54 0x4f 0x4e 0x45 */
|
|
|
|
uint8_t cmd2[1]; /* 0x72/0x77/0x65/0x20 for read/write/end/data */
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint8_t tone_table;
|
|
|
|
uint8_t param_table;
|
|
|
|
uint8_t pad[3];
|
|
|
|
} read_write;
|
|
|
|
struct {
|
|
|
|
uint8_t pad[5];
|
|
|
|
} end_data;
|
|
|
|
};
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
enum {
|
|
|
|
TONE_TABLE_STANDARD = 0,
|
|
|
|
TONE_TABLE_USER = 1,
|
|
|
|
TONE_TABLE_CURRENT = 2,
|
|
|
|
};
|
|
|
|
enum {
|
|
|
|
PARAM_TABLE_STANDARD = 1,
|
|
|
|
PARAM_TABLE_FINE = 2,
|
|
|
|
};
|
2015-02-18 20:54:57 -05:00
|
|
|
|
|
|
|
#define TONE_CURVE_SIZE 1536
|
|
|
|
#define TONE_CURVE_DATA_BLOCK_SIZE 64
|
2015-02-08 15:33:17 -05:00
|
|
|
|
|
|
|
/* Query Model information */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_getmodel {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0x02 */
|
|
|
|
uint8_t pad[10];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct shinkos1245_resp_getmodel {
|
|
|
|
uint8_t vendor_id[4];
|
|
|
|
uint8_t product_id[4];
|
|
|
|
uint8_t strings[40];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
/* Query and Set Matte info, returns a Matte response */
|
2015-02-08 13:17:33 -05:00
|
|
|
struct shinkos1245_cmd_getmatte {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0x20 */
|
2015-05-14 18:08:59 -04:00
|
|
|
uint8_t mode; /* Fixed at 0x00 */
|
2015-02-08 13:17:33 -05:00
|
|
|
uint8_t pad[9];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct shinkos1245_cmd_setmatte {
|
|
|
|
struct shinkos1245_cmd_hdr hdr;
|
|
|
|
uint8_t cmd[1]; /* 0x21 */
|
|
|
|
uint8_t mode; /* Fixed at 0x00 */
|
2015-05-14 18:08:59 -04:00
|
|
|
int8_t level; /* -25->+25 */
|
2015-02-08 13:17:33 -05:00
|
|
|
uint8_t pad[8];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct shinkos1245_resp_matte {
|
|
|
|
uint8_t code;
|
|
|
|
uint8_t mode;
|
2015-02-18 21:20:59 -05:00
|
|
|
int8_t level;
|
2015-02-08 13:17:33 -05:00
|
|
|
uint8_t reserved[3];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-02-08 15:33:17 -05:00
|
|
|
#define MATTE_MODE_MATTE 0x00
|
2015-02-08 13:17:33 -05:00
|
|
|
|
2015-02-08 19:48:17 -05:00
|
|
|
/* Private data stucture */
|
|
|
|
struct shinkos1245_ctx {
|
|
|
|
struct libusb_device_handle *dev;
|
|
|
|
uint8_t endp_up;
|
|
|
|
uint8_t endp_down;
|
2015-08-12 22:56:29 -04:00
|
|
|
int type;
|
|
|
|
|
2015-02-08 19:48:17 -05:00
|
|
|
uint8_t jobid;
|
|
|
|
|
|
|
|
struct s1245_printjob_hdr hdr;
|
|
|
|
|
|
|
|
struct shinkos1245_mediadesc medias[15];
|
|
|
|
int num_medias;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 19:48:17 -05:00
|
|
|
uint8_t *databuf;
|
|
|
|
int datalen;
|
2015-02-18 20:54:57 -05:00
|
|
|
int tonecurve;
|
2015-02-08 19:48:17 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
S_IDLE = 0,
|
|
|
|
S_PRINTER_READY_CMD,
|
|
|
|
S_PRINTER_SENT_DATA,
|
|
|
|
S_FINISHED,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-02-08 18:59:26 -05:00
|
|
|
/* Basic printer I/O stuffs */
|
|
|
|
static void shinkos1245_fill_hdr(struct shinkos1245_cmd_hdr *hdr)
|
|
|
|
{
|
|
|
|
hdr->prefix = 0x03;
|
|
|
|
hdr->hdr[0] = 0x1b;
|
|
|
|
hdr->hdr[1] = 0x43;
|
|
|
|
hdr->hdr[2] = 0x48;
|
|
|
|
hdr->hdr[3] = 0x43;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int shinkos1245_do_cmd(struct shinkos1245_ctx *ctx,
|
|
|
|
void *cmd, int cmd_len,
|
|
|
|
void *resp, int resp_len,
|
|
|
|
int *actual_len)
|
|
|
|
{
|
|
|
|
int ret;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 18:59:26 -05:00
|
|
|
/* Write command */
|
|
|
|
if ((ret = send_data(ctx->dev, ctx->endp_down,
|
|
|
|
cmd, cmd_len)))
|
|
|
|
return (ret < 0) ? ret : -99;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 18:59:26 -05:00
|
|
|
/* Read response */
|
|
|
|
ret = read_data(ctx->dev, ctx->endp_up,
|
|
|
|
resp, resp_len, actual_len);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
if (*actual_len < resp_len) {
|
|
|
|
ERROR("Short read! (%d/%d))\n", *actual_len, resp_len);
|
|
|
|
return -99;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int shinkos1245_get_status(struct shinkos1245_ctx *ctx,
|
|
|
|
struct shinkos1245_resp_status *resp)
|
|
|
|
{
|
|
|
|
struct shinkos1245_cmd_getstatus cmd;
|
|
|
|
int ret, num;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 18:59:26 -05:00
|
|
|
shinkos1245_fill_hdr(&cmd.hdr);
|
|
|
|
cmd.cmd[0] = 0x03;
|
|
|
|
memset(cmd.pad, 0, sizeof(cmd.pad));
|
|
|
|
|
|
|
|
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
|
|
|
|
resp, sizeof(*resp), &num);
|
|
|
|
if (ret < 0) {
|
|
|
|
ERROR("Failed to execute GET_STATUS command\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (resp->code != CMD_CODE_OK) {
|
|
|
|
ERROR("Bad return code on GET_STATUS (%02x)\n",
|
|
|
|
resp->code);
|
|
|
|
return -99;
|
|
|
|
}
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 18:59:26 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-08 19:48:17 -05:00
|
|
|
static int shinkos1245_get_media(struct shinkos1245_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct shinkos1245_cmd_getmedia cmd;
|
|
|
|
struct shinkos1245_resp_media resp;
|
|
|
|
int i, j;
|
2015-07-04 09:38:59 -04:00
|
|
|
int ret = 0, num;
|
2015-02-08 19:48:17 -05:00
|
|
|
|
|
|
|
shinkos1245_fill_hdr(&cmd.hdr);
|
2015-05-14 18:08:59 -04:00
|
|
|
memset(cmd.pad, 0, sizeof(cmd.pad));
|
2015-02-08 19:48:17 -05:00
|
|
|
for (i = 1 ; i <= 3 ; i++) {
|
|
|
|
cmd.cmd[0] = 0x0a || (i << 4);
|
|
|
|
|
|
|
|
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
|
|
|
|
&resp, sizeof(resp), &num);
|
|
|
|
if (ret < 0) {
|
2015-02-08 20:19:44 -05:00
|
|
|
ERROR("Failed to execute GET_MEDIA command\n");
|
2015-02-08 19:48:17 -05:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (resp.code != CMD_CODE_OK) {
|
2015-02-08 20:19:44 -05:00
|
|
|
ERROR("Bad return code on GET_MEDIA (%02x)\n",
|
2015-02-08 19:48:17 -05:00
|
|
|
resp.code);
|
|
|
|
return -99;
|
|
|
|
}
|
|
|
|
|
2015-08-20 22:41:58 -04:00
|
|
|
if (resp.count > NUM_MEDIAS)
|
|
|
|
resp.count = NUM_MEDIAS;
|
|
|
|
|
2015-02-08 19:48:17 -05:00
|
|
|
/* Store media info */
|
|
|
|
for (j = 0; j < resp.count ; j++) {
|
|
|
|
ctx->medias[ctx->num_medias].code = resp.data[j].code;
|
|
|
|
ctx->medias[ctx->num_medias].columns = be16_to_cpu(resp.data[j].columns);
|
|
|
|
ctx->medias[ctx->num_medias].rows = be16_to_cpu(resp.data[j].rows);
|
|
|
|
ctx->medias[ctx->num_medias].type = resp.data[j].type;
|
|
|
|
ctx->medias[ctx->num_medias].print_type = resp.data[j].print_type;
|
|
|
|
ctx->num_medias++;
|
|
|
|
}
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 19:48:17 -05:00
|
|
|
if (resp.count < 5)
|
|
|
|
break;
|
2015-05-14 18:08:59 -04:00
|
|
|
}
|
2015-07-04 09:38:59 -04:00
|
|
|
return ret;
|
2015-02-08 19:48:17 -05:00
|
|
|
}
|
|
|
|
|
2015-02-08 20:19:44 -05:00
|
|
|
static int shinkos1245_get_printerid(struct shinkos1245_ctx *ctx,
|
|
|
|
struct shinkos1245_resp_getid *resp)
|
|
|
|
{
|
2015-08-25 18:09:51 -04:00
|
|
|
struct shinkos1245_cmd_getid cmd;
|
2015-02-08 20:19:44 -05:00
|
|
|
int ret, num;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 20:19:44 -05:00
|
|
|
shinkos1245_fill_hdr(&cmd.hdr);
|
|
|
|
cmd.cmd[0] = 0x12;
|
|
|
|
memset(cmd.pad, 0, sizeof(cmd.pad));
|
|
|
|
|
|
|
|
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
|
|
|
|
resp, sizeof(*resp), &num);
|
|
|
|
if (ret < 0) {
|
|
|
|
ERROR("Failed to execute GET_PRINTERID command\n");
|
|
|
|
return ret;
|
|
|
|
}
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 20:19:44 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int shinkos1245_set_printerid(struct shinkos1245_ctx *ctx,
|
|
|
|
char *id)
|
|
|
|
{
|
|
|
|
struct shinkos1245_cmd_setid cmd;
|
|
|
|
struct shinkos1245_resp_status sts;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 20:19:44 -05:00
|
|
|
int ret, num;
|
|
|
|
int i;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 20:19:44 -05:00
|
|
|
shinkos1245_fill_hdr(&cmd.hdr);
|
|
|
|
cmd.cmd[0] = 0x0a;
|
|
|
|
cmd.cmd[1] = 0x22;
|
|
|
|
|
|
|
|
for (i = 0 ; i < (int)sizeof(cmd.data) ; i++) {
|
|
|
|
if (*id)
|
|
|
|
cmd.data[i] = (uint8_t) *id;
|
|
|
|
else
|
|
|
|
cmd.data[i] = ' ';
|
|
|
|
}
|
|
|
|
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
|
|
|
|
&sts, sizeof(sts), &num);
|
|
|
|
if (ret < 0) {
|
|
|
|
ERROR("Failed to execute SET_PRINTERID command\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (sts.code != CMD_CODE_OK) {
|
|
|
|
ERROR("Bad return code on SET_PRINTERID command\n");
|
|
|
|
return -99;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-08 20:34:30 -05:00
|
|
|
static int shinkos1245_canceljob(struct shinkos1245_ctx *ctx,
|
|
|
|
int id)
|
|
|
|
{
|
|
|
|
struct shinkos1245_cmd_canceljob cmd;
|
|
|
|
struct shinkos1245_resp_status sts;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 20:34:30 -05:00
|
|
|
int ret, num;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-08 20:34:30 -05:00
|
|
|
shinkos1245_fill_hdr(&cmd.hdr);
|
|
|
|
cmd.cmd[0] = 0x13;
|
|
|
|
cmd.id = id;
|
|
|
|
|
|
|
|
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
|
|
|
|
&sts, sizeof(sts), &num);
|
|
|
|
if (ret < 0) {
|
|
|
|
ERROR("Failed to execute CANCELJOB command\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (sts.code != CMD_CODE_OK) {
|
|
|
|
ERROR("Bad return code on CANCELJOB command\n");
|
|
|
|
return -99;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-02-18 21:14:00 -05:00
|
|
|
|
2015-02-18 21:04:33 -05:00
|
|
|
static int shinkos1245_set_matte(struct shinkos1245_ctx *ctx,
|
|
|
|
int intensity)
|
|
|
|
{
|
|
|
|
struct shinkos1245_cmd_setmatte cmd;
|
2015-02-18 21:14:00 -05:00
|
|
|
struct shinkos1245_resp_matte sts;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-18 21:04:33 -05:00
|
|
|
int ret, num;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-18 21:04:33 -05:00
|
|
|
shinkos1245_fill_hdr(&cmd.hdr);
|
|
|
|
cmd.cmd[0] = 0x21;
|
|
|
|
cmd.mode = MATTE_MODE_MATTE;
|
|
|
|
cmd.level = intensity;
|
|
|
|
|
|
|
|
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
|
|
|
|
&sts, sizeof(sts), &num);
|
|
|
|
if (ret < 0) {
|
2015-02-18 21:14:00 -05:00
|
|
|
ERROR("Failed to execute SET_MATTE command\n");
|
2015-02-18 21:04:33 -05:00
|
|
|
return ret;
|
|
|
|
}
|
2015-02-18 21:14:00 -05:00
|
|
|
if (sts.code == CMD_CODE_OK)
|
|
|
|
return 0;
|
|
|
|
if (sts.code == CMD_CODE_BAD)
|
|
|
|
return 1;
|
2015-02-18 21:04:33 -05:00
|
|
|
|
2015-02-18 21:14:00 -05:00
|
|
|
ERROR("Bad return code (%02x) on SET_MATTE command\n", sts.code);
|
|
|
|
return -99;
|
2015-02-18 21:04:33 -05:00
|
|
|
}
|
2015-02-08 20:19:44 -05:00
|
|
|
|
2015-02-18 21:20:59 -05:00
|
|
|
static int shinkos1245_get_matte(struct shinkos1245_ctx *ctx,
|
|
|
|
int *intensity)
|
|
|
|
{
|
|
|
|
struct shinkos1245_cmd_getmatte cmd;
|
|
|
|
struct shinkos1245_resp_matte sts;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-18 21:20:59 -05:00
|
|
|
int ret, num;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-18 21:20:59 -05:00
|
|
|
shinkos1245_fill_hdr(&cmd.hdr);
|
|
|
|
cmd.cmd[0] = 0x20;
|
|
|
|
cmd.mode = MATTE_MODE_MATTE;
|
|
|
|
|
|
|
|
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
|
|
|
|
&sts, sizeof(sts), &num);
|
|
|
|
if (ret < 0) {
|
|
|
|
ERROR("Failed to execute GET_MATTE command\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (sts.code != CMD_CODE_OK) {
|
|
|
|
ERROR("Bad return code (%02x) on GET_MATTE command\n", sts.code);
|
|
|
|
return -99;
|
|
|
|
}
|
|
|
|
*intensity = sts.level;
|
2015-05-14 18:08:59 -04:00
|
|
|
|
2015-02-18 21:20:59 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-08 20:19:44 -05:00
|
|
|
/* Structure dumps */
|
2015-02-10 22:39:18 -05:00
|
|
|
static char *shinkos1245_status_str(struct shinkos1245_resp_status *resp)
|
2015-02-08 18:59:26 -05:00
|
|
|
{
|
2015-02-10 22:39:18 -05:00
|
|
|
switch(resp->state.status1) {
|
2015-02-08 18:59:26 -05:00
|
|
|
case STATE_STATUS1_STANDBY:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Standby (Ready)";
|
2015-02-08 18:59:26 -05:00
|
|
|
case STATE_STATUS1_WAIT:
|
2015-02-10 22:39:18 -05:00
|
|
|
switch (resp->state.status2) {
|
2015-02-08 18:59:26 -05:00
|
|
|
case WAIT_STATUS2_INIT:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Wait (Initializing)";
|
2015-02-08 18:59:26 -05:00
|
|
|
case WAIT_STATUS2_RIBBON:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Wait (Ribbon Winding)";
|
2015-02-08 18:59:26 -05:00
|
|
|
case WAIT_STATUS2_THERMAL:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Wait (Thermal Protection)";
|
2015-02-08 18:59:26 -05:00
|
|
|
case WAIT_STATUS2_OPERATING:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Wait (Operating)";
|
2015-02-08 18:59:26 -05:00
|
|
|
case WAIT_STATUS2_BUSY:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Wait (Busy)";
|
2015-02-08 18:59:26 -05:00
|
|
|
default:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Wait (Unknown)";
|
2015-02-08 18:59:26 -05:00
|
|
|
}
|
|
|
|
case STATE_STATUS1_ERROR:
|
2015-02-10 22:39:18 -05:00
|
|
|
switch (resp->state.status2) {
|
2015-02-08 18:59:26 -05:00
|
|
|
case ERROR_STATUS2_CTRL_CIRCUIT:
|
2015-02-10 22:39:18 -05:00
|
|
|
switch (resp->state.error) {
|
|
|
|
case CTRL_CIR_ERROR_EEPROM1:
|
|
|
|
return "Error (EEPROM1)";
|
|
|
|
case CTRL_CIR_ERROR_EEPROM2:
|
|
|
|
return "Error (EEPROM2)";
|
|
|
|
case CTRL_CIR_ERROR_DSP:
|
|
|
|
return "Error (DSP)";
|
|
|
|
case CTRL_CIR_ERROR_CRC_MAIN:
|
|
|
|
return "Error (Main CRC)";
|
|
|
|
case CTRL_CIR_ERROR_DL_MAIN:
|
|
|
|
return "Error (Main Download)";
|
|
|
|
case CTRL_CIR_ERROR_CRC_DSP:
|
|
|
|
return "Error (DSP CRC)";
|
|
|
|
case CTRL_CIR_ERROR_DL_DSP:
|
|
|
|
return "Error (DSP Download)";
|
|
|
|
case CTRL_CIR_ERROR_ASIC:
|
|
|
|
return "Error (ASIC)";
|
|
|
|
case CTRL_CIR_ERROR_DRAM:
|
|
|
|
return "Error (DRAM)";
|
|
|
|
case CTRL_CIR_ERROR_DSPCOMM:
|
|
|
|
return "Error (DSP Communincation)";
|
|
|
|
default:
|
|
|
|
return "Error (Unknown Circuit)";
|
|
|
|
}
|
2015-02-08 18:59:26 -05:00
|
|
|
case ERROR_STATUS2_MECHANISM_CTRL:
|
2015-02-10 22:39:18 -05:00
|
|
|
switch (resp->state.error) {
|
|
|
|
case MECH_ERROR_HEAD_UP:
|
|
|
|
return "Error (Head Up Mechanism)";
|
|
|
|
case MECH_ERROR_HEAD_DOWN:
|
|
|
|
return "Error (Head Down Mechanism)";
|
|
|
|
case MECH_ERROR_MAIN_PINCH_UP:
|
|
|
|
return "Error (Main Pinch Up Mechanism)";
|
|
|
|
case MECH_ERROR_MAIN_PINCH_DOWN:
|
|
|
|
return "Error (Main Pinch Down Mechanism)";
|
|
|
|
case MECH_ERROR_SUB_PINCH_UP:
|
|
|
|
return "Error (Sub Pinch Up Mechanism)";
|
|
|
|
case MECH_ERROR_SUB_PINCH_DOWN:
|
|
|
|
return "Error (Sub Pinch Down Mechanism)";
|
|
|
|
case MECH_ERROR_FEEDIN_PINCH_UP:
|
|
|
|
return "Error (Feed-in Pinch Up Mechanism)";
|
|
|
|
case MECH_ERROR_FEEDIN_PINCH_DOWN:
|
|
|
|
return "Error (Feed-in Pinch Down Mechanism)";
|
|
|
|
case MECH_ERROR_FEEDOUT_PINCH_UP:
|
|
|
|
return "Error (Feed-out Pinch Up Mechanism)";
|
|
|
|
case MECH_ERROR_FEEDOUT_PINCH_DOWN:
|
|
|
|
return "Error (Feed-out Pinch Down Mechanism)";
|
|
|
|
case MECH_ERROR_CUTTER_LR:
|
|
|
|
return "Error (Left->Right Cutter)";
|
|
|
|
case MECH_ERROR_CUTTER_RL:
|
|
|
|
return "Error (Right->Left Cutter)";
|
|
|
|
default:
|
|
|
|
return "Error (Unknown Mechanism)";
|
|
|
|
}
|
2015-02-08 18:59:26 -05:00
|
|
|
case ERROR_STATUS2_SENSOR:
|
2015-02-10 22:39:18 -05:00
|
|
|
switch (resp->state.error) {
|
|
|
|
case SENSOR_ERROR_CUTTER:
|
|
|
|
return "Error (Cutter Sensor)";
|
|
|
|
case SENSOR_ERROR_HEAD_DOWN:
|
|
|
|
return "Error (Head Down Sensor)";
|
|
|
|
case SENSOR_ERROR_HEAD_UP:
|
|
|
|
return "Error (Head Up Sensor)";
|
|
|
|
case SENSOR_ERROR_MAIN_PINCH_DOWN:
|
|
|
|
return "Error (Main Pinch Down Sensor)";
|
|
|
|
case SENSOR_ERROR_MAIN_PINCH_UP:
|
|
|
|
return "Error (Main Pinch Up Sensor)";
|
|
|
|
case SENSOR_ERROR_FEED_PINCH_DOWN:
|
|
|
|
return "Error (Feed Pinch Down Sensor)";
|
|
|
|
case SENSOR_ERROR_FEED_PINCH_UP:
|
|
|
|
return "Error (Feed Pinch Up Sensor)";
|
|
|
|
case SENSOR_ERROR_EXIT_PINCH_DOWN:
|
|
|
|
return "Error (Exit Pinch Up Sensor)";
|
|
|
|
case SENSOR_ERROR_EXIT_PINCH_UP:
|
|
|
|
return "Error (Exit Pinch Up Sensor)";
|
|
|
|
case SENSOR_ERROR_LEFT_CUTTER:
|
|
|
|
return "Error (Left Cutter Sensor)";
|
|
|
|
case SENSOR_ERROR_RIGHT_CUTTER:
|
|
|
|
return "Error (Right Cutter Sensor)";
|
|
|
|
case SENSOR_ERROR_CENTER_CUTTER:
|
|
|
|
return "Error (Center Cutter Sensor)";
|
|
|
|
case SENSOR_ERROR_UPPER_CUTTER:
|
|
|
|
return "Error (Upper Cutter Sensor)";
|
|
|
|
case SENSOR_ERROR_PAPER_FEED_COVER:
|
|
|
|
return "Error (Paper Feed Cover)";
|
|
|
|
default:
|
|
|
|
return "Error (Unknown Sensor)";
|
|
|
|
}
|
2015-02-08 18:59:26 -05:00
|
|
|
case ERROR_STATUS2_COVER_OPEN:
|
2015-02-10 22:39:18 -05:00
|
|
|
switch (resp->state.error) {
|
|
|
|
case COVER_OPEN_ERROR_UPPER:
|
|
|
|
return "Error (Upper Cover Open)";
|
|
|
|
case COVER_OPEN_ERROR_LOWER:
|
|
|
|
return "Error (Lower Cover Open)";
|
|
|
|
default:
|
|
|
|
return "Error (Unknown Cover Open)";
|
|
|
|
}
|
2015-02-08 18:59:26 -05:00
|
|
|
case ERROR_STATUS2_TEMP_SENSOR:
|
2015-02-10 22:39:18 -05:00
|
|
|
switch (resp->state.error) {
|
|
|
|
case TEMP_SENSOR_ERROR_HEAD_HIGH:
|
|
|
|
return "Error (Head Temperature High)";
|
|
|
|
case TEMP_SENSOR_ERROR_HEAD_LOW:
|
|
|
|
return "Error (Head Temperature Low)";
|
|
|
|
case TEMP_SENSOR_ERROR_ENV_HIGH:
|
|
|
|
return "Error (Environmental Temperature High)";
|
|
|
|
case TEMP_SENSOR_ERROR_ENV_LOW:
|
|
|
|
return "Error (Environmental Temperature Low)";
|
|
|
|
default:
|
|
|
|
return "Error (Unknown Temperature)";
|
|
|
|
}
|
2015-02-08 18:59:26 -05:00
|
|
|
case ERROR_STATUS2_PAPER_JAM:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Error (Paper Jam)";
|
2015-02-08 18:59:26 -05:00
|
|
|
case ERROR_STATUS2_PAPER_EMPTY:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Error (Paper Empty)";
|
2015-02-08 18:59:26 -05:00
|
|
|
case ERROR_STATUS2_RIBBON_ERR:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Error (Ribbon)";
|
2015-02-08 18:59:26 -05:00
|
|
|
default:
|
2015-02-10 22:39:18 -05:00
|
|
|
return "Error (Unknown)";
|
2015-02-08 18:59:26 -05:00
|
|
|
}
|
2015-02-10 22:39:18 -05:00
|
|
|
default:
|
|
|
|
return "Unknown!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-19 21:32:43 -05:00
|
|
|
static char* shinkos1245_tonecurves(int type, int table)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case TONE_TABLE_STANDARD:
|
|
|
|
switch (table) {
|
|
|
|
case PARAM_TABLE_STANDARD:
|
|
|
|
return "Standard/Standard";
|
|
|
|
case PARAM_TABLE_FINE:
|
|
|
|
return "Standard/Fine";
|
|
|
|
default:
|
|
|
|
return "Standard/Unknown";
|
|
|
|
}
|
|
|
|
case TONE_TABLE_USER:
|
|
|
|
switch (table) {
|
|
|
|
case PARAM_TABLE_STANDARD:
|
|
|
|
return "User/Standard";
|
|
|
|
case PARAM_TABLE_FINE:
|
|
|
|
return "User/Fine";
|
|
|
|
default:
|
|
|
|
return "User/Unknown";
|
|
|
|
}
|
|
|
|
case TONE_TABLE_CURRENT:
|
|
|
|
switch (table) {
|
|
|
|
case PARAM_TABLE_STANDARD:
|
|
|
|
return "Current/Standard";
|
|
|
|
case PARAM_TABLE_FINE:
|
|
|
|
return "Current/Fine";
|
|
|
|
default:
|
|
|
|
return "Current/Unknown";
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-10 22:39:18 -05:00
|
|
|
static void shinkos1245_dump_status(struct shinkos1245_resp_status *sts)
|
|
|
|
{
|
|
|
|
char *detail;
|
|
|
|
switch (sts->print_status) {
|
|
|
|
case STATUS_PRINTING:
|
|
|
|
detail = "Printing";
|
|
|
|
break;
|
|
|
|
case STATUS_IDLE:
|
|
|
|
detail = "Idle";
|
2015-02-08 18:59:26 -05:00
|
|
|
break;
|
|
|
|
default:
|
2015-02-10 22:39:18 -05:00
|
|
|
detail |