2012-10-26 22:06:47 -04:00
|
|
|
/*
|
2012-11-03 09:37:12 -04:00
|
|
|
* Canon SELPHY ES/CP series print assister -- libusb-1.0 version
|
2012-10-26 22:06:47 -04:00
|
|
|
*
|
2013-02-01 21:45:25 -05:00
|
|
|
* (c) 2007-2013 Solomon Peachy <pizza@shaftnet.org>
|
2012-10-26 22:06:47 -04:00
|
|
|
*
|
|
|
|
* The latest version of this program can be found at:
|
2013-05-02 11:32:15 -04:00
|
|
|
*
|
2012-10-27 10:27:31 -04:00
|
|
|
* http://git.shaftnet.org/git/gitweb.cgi?p=selphy_print.git
|
2013-05-02 11:32:15 -04:00
|
|
|
*
|
2012-10-26 22:06:47 -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]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2012-10-26 23:21:33 -04:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
2013-05-02 20:27:32 -04:00
|
|
|
#include <signal.h>
|
2012-10-26 23:21:33 -04:00
|
|
|
|
2013-07-17 22:43:49 -04:00
|
|
|
#define VERSION "0.56"
|
2013-07-14 20:18:04 -04:00
|
|
|
#define URI_PREFIX "canonselphy://"
|
2012-10-27 10:38:36 -04:00
|
|
|
|
2013-06-27 23:02:34 -04:00
|
|
|
#include "backend_common.c"
|
|
|
|
|
2013-05-02 20:34:01 -04:00
|
|
|
#define READBACK_LEN 12
|
|
|
|
|
|
|
|
struct printer_data {
|
|
|
|
int type; /* P_??? */
|
|
|
|
char *model; /* eg "SELPHY ES1" */
|
|
|
|
int init_length;
|
|
|
|
int foot_length;
|
|
|
|
int16_t init_readback[READBACK_LEN];
|
|
|
|
int16_t ready_y_readback[READBACK_LEN];
|
|
|
|
int16_t ready_m_readback[READBACK_LEN];
|
|
|
|
int16_t ready_c_readback[READBACK_LEN];
|
|
|
|
int16_t done_c_readback[READBACK_LEN];
|
2013-05-03 07:24:58 -04:00
|
|
|
int16_t clear_error[READBACK_LEN];
|
2013-05-02 20:34:01 -04:00
|
|
|
int16_t paper_codes[256];
|
|
|
|
int16_t pgcode_offset; /* Offset into printjob for paper type */
|
|
|
|
int16_t paper_code_offset; /* Offset in readback for paper type */
|
|
|
|
int16_t error_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct printer_data printers[P_END] = {
|
|
|
|
{ .type = P_ES1,
|
|
|
|
.model = "SELPHY ES1",
|
|
|
|
.init_length = 12,
|
|
|
|
.foot_length = 0,
|
|
|
|
.init_readback = { 0x02, 0x00, 0x00, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_y_readback = { 0x04, 0x00, 0x01, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_m_readback = { 0x04, 0x00, 0x03, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_c_readback = { 0x04, 0x00, 0x07, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.done_c_readback = { 0x04, 0x00, 0x00, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },
|
2013-05-03 07:24:58 -04:00
|
|
|
// .clear_error
|
2013-05-02 20:34:01 -04:00
|
|
|
// .paper_codes
|
|
|
|
.pgcode_offset = 3,
|
|
|
|
.paper_code_offset = 6,
|
|
|
|
.error_offset = 1,
|
|
|
|
},
|
|
|
|
{ .type = P_ES2_20,
|
|
|
|
.model = "SELPHY ES2/ES20",
|
|
|
|
.init_length = 16,
|
|
|
|
.foot_length = 0,
|
|
|
|
.init_readback = { 0x02, 0x00, 0x00, 0x00, -1, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_y_readback = { 0x03, 0x00, 0x01, 0x00, -1, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_m_readback = { 0x06, 0x00, 0x03, 0x00, -1, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_c_readback = { 0x09, 0x00, 0x07, 0x00, -1, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.done_c_readback = { 0x09, 0x00, 0x00, 0x00, -1, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00 },
|
2013-05-03 07:24:58 -04:00
|
|
|
// .clear_error
|
2013-05-02 20:34:01 -04:00
|
|
|
// .paper_codes
|
|
|
|
.pgcode_offset = 2,
|
|
|
|
.paper_code_offset = 4,
|
|
|
|
.error_offset = 1, // XXX insufficient
|
|
|
|
},
|
|
|
|
{ .type = P_ES3_30,
|
|
|
|
.model = "SELPHY ES3/ES30",
|
|
|
|
.init_length = 16,
|
|
|
|
.foot_length = 12,
|
|
|
|
.init_readback = { 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_y_readback = { 0x01, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_m_readback = { 0x03, 0xff, 0x02, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_c_readback = { 0x05, 0xff, 0x03, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.done_c_readback = { 0x00, 0xff, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
|
2013-05-03 07:24:58 -04:00
|
|
|
// .clear_error
|
2013-05-02 20:34:01 -04:00
|
|
|
// .paper_codes
|
|
|
|
.pgcode_offset = 2,
|
|
|
|
.paper_code_offset = -1,
|
|
|
|
.error_offset = 8, // or 10
|
|
|
|
},
|
|
|
|
{ .type = P_ES40_CP790,
|
|
|
|
.model = "SELPHY ES40/CP790",
|
|
|
|
.init_length = 16,
|
|
|
|
.foot_length = 12,
|
|
|
|
.init_readback = { 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
|
|
|
|
.ready_y_readback = { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
|
|
|
|
.ready_m_readback = { 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
|
|
|
|
.ready_c_readback = { 0x00, 0x05, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
|
|
|
|
.done_c_readback = { 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
|
2013-05-03 07:24:58 -04:00
|
|
|
// .clear_error
|
2013-05-02 20:34:01 -04:00
|
|
|
// .paper_codes
|
|
|
|
.pgcode_offset = 2,
|
|
|
|
.paper_code_offset = 11,
|
|
|
|
.error_offset = 3,
|
|
|
|
},
|
|
|
|
{ .type = P_CP_XXX,
|
|
|
|
.model = "SELPHY CP Series (!CP-10/CP790)",
|
|
|
|
.init_length = 12,
|
|
|
|
.foot_length = 0, /* CP900 has four-byte NULL footer that can be safely ignored */
|
|
|
|
.init_readback = { 0x01, 0x00, 0x00, 0x00, -1, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
|
|
|
|
.ready_y_readback = { 0x02, 0x00, 0x00, 0x00, 0x70, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
|
|
|
|
.ready_m_readback = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
|
|
|
|
.ready_c_readback = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
|
|
|
|
.done_c_readback = { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
|
2013-05-03 07:24:58 -04:00
|
|
|
.clear_error = { 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
2013-05-02 20:34:01 -04:00
|
|
|
// .paper_codes
|
|
|
|
.pgcode_offset = 3,
|
|
|
|
.paper_code_offset = 6,
|
|
|
|
.error_offset = 2,
|
|
|
|
},
|
|
|
|
{ .type = P_CP10,
|
|
|
|
.model = "SELPHY CP-10",
|
|
|
|
.init_length = 12,
|
|
|
|
.foot_length = 0,
|
|
|
|
.init_readback = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_y_readback = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_m_readback = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.ready_c_readback = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
.done_c_readback = { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
|
|
|
// .paper_codes
|
2013-05-03 07:24:58 -04:00
|
|
|
// .clear_error
|
2013-05-02 20:34:01 -04:00
|
|
|
.pgcode_offset = -1,
|
|
|
|
.paper_code_offset = -1,
|
|
|
|
.error_offset = 2,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_HEADER 28
|
|
|
|
#define BUF_LEN 4096
|
|
|
|
|
|
|
|
static const int es40_cp790_plane_lengths[4] = { 2227456, 1601600, 698880, 2976512 };
|
|
|
|
|
|
|
|
static void setup_paper_codes(void)
|
|
|
|
{
|
|
|
|
/* Default all to IGNORE */
|
|
|
|
int i, j;
|
|
|
|
for (i = 0; i < P_END ; i++)
|
|
|
|
for (j = 0 ; j < 256 ; j++)
|
|
|
|
printers[i].paper_codes[j] = -1;
|
|
|
|
|
|
|
|
/* SELPHY ES1 paper codes */
|
|
|
|
printers[P_ES1].paper_codes[0x11] = 0x01;
|
|
|
|
printers[P_ES1].paper_codes[0x12] = 0x02; // ? guess
|
|
|
|
printers[P_ES1].paper_codes[0x13] = 0x03;
|
|
|
|
|
|
|
|
/* SELPHY ES2/20 paper codes */
|
|
|
|
printers[P_ES2_20].paper_codes[0x01] = 0x01;
|
|
|
|
printers[P_ES2_20].paper_codes[0x02] = 0x02; // ? guess
|
|
|
|
printers[P_ES2_20].paper_codes[0x03] = 0x03;
|
|
|
|
|
|
|
|
/* SELPHY ES3/30 paper codes -- N/A, printer does not report paper type */
|
|
|
|
/* SELPHY ES40/CP790 paper codes -- ? guess */
|
|
|
|
printers[P_ES40_CP790].paper_codes[0x00] = 0x11;
|
|
|
|
printers[P_ES40_CP790].paper_codes[0x01] = 0x22;
|
|
|
|
printers[P_ES40_CP790].paper_codes[0x02] = 0x33;
|
|
|
|
printers[P_ES40_CP790].paper_codes[0x03] = 0x44;
|
|
|
|
|
|
|
|
/* SELPHY CP-series (except CP790) paper codes */
|
|
|
|
printers[P_CP_XXX].paper_codes[0x01] = 0x11;
|
|
|
|
printers[P_CP_XXX].paper_codes[0x02] = 0x22;
|
|
|
|
printers[P_CP_XXX].paper_codes[0x03] = 0x33;
|
|
|
|
printers[P_CP_XXX].paper_codes[0x04] = 0x44;
|
|
|
|
|
|
|
|
/* SELPHY CP-10 paper codes -- N/A, only one type */
|
|
|
|
}
|
|
|
|
|
|
|
|
#define INCORRECT_PAPER -999
|
|
|
|
|
|
|
|
/* Program states */
|
|
|
|
enum {
|
|
|
|
S_IDLE = 0,
|
|
|
|
S_PRINTER_READY,
|
|
|
|
S_PRINTER_INIT_SENT,
|
|
|
|
S_PRINTER_READY_Y,
|
|
|
|
S_PRINTER_Y_SENT,
|
|
|
|
S_PRINTER_READY_M,
|
|
|
|
S_PRINTER_M_SENT,
|
|
|
|
S_PRINTER_READY_C,
|
|
|
|
S_PRINTER_C_SENT,
|
|
|
|
S_PRINTER_DONE,
|
|
|
|
S_FINISHED,
|
|
|
|
};
|
|
|
|
|
2012-12-11 19:52:03 -05:00
|
|
|
static int fancy_memcmp(const uint8_t *buf_a, const int16_t *buf_b, uint len, int16_t papercode_offset, int16_t papercode_val)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < len ; i++) {
|
|
|
|
if (papercode_offset != -1 && i == papercode_offset) {
|
|
|
|
if (papercode_val == -1)
|
|
|
|
continue;
|
|
|
|
else if (buf_a[i] != papercode_val)
|
|
|
|
return INCORRECT_PAPER;
|
|
|
|
} else if (buf_b[i] == -1)
|
|
|
|
continue;
|
|
|
|
else if (buf_a[i] > buf_b[i])
|
|
|
|
return 1;
|
|
|
|
else if (buf_a[i] < buf_b[i])
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_printjob(uint8_t *buffer, int *bw_mode, int *plane_len)
|
|
|
|
{
|
|
|
|
int printer_type = -1;
|
|
|
|
|
|
|
|
if (buffer[0] != 0x40 &&
|
|
|
|
buffer[1] != 0x00) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer[12] == 0x40 &&
|
|
|
|
buffer[13] == 0x01) {
|
2013-01-29 17:51:43 -05:00
|
|
|
*plane_len = *(uint32_t*)(&buffer[16]);
|
|
|
|
*plane_len = le32_to_cpu(*plane_len);
|
|
|
|
|
2012-12-11 19:52:03 -05:00
|
|
|
if (buffer[2] == 0x00) {
|
2013-01-29 17:51:43 -05:00
|
|
|
if (*plane_len == 688480)
|
2012-12-12 19:00:45 -05:00
|
|
|
printer_type = P_CP10;
|
|
|
|
else
|
|
|
|
printer_type = P_CP_XXX;
|
2012-12-11 19:52:03 -05:00
|
|
|
} else {
|
|
|
|
printer_type = P_ES1;
|
|
|
|
*bw_mode = (buffer[2] == 0x20);
|
|
|
|
}
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
*plane_len = *(uint32_t*)(&buffer[12]);
|
|
|
|
*plane_len = le32_to_cpu(*plane_len);
|
|
|
|
|
|
|
|
if (buffer[16] == 0x40 &&
|
|
|
|
buffer[17] == 0x01) {
|
|
|
|
|
|
|
|
if (buffer[4] == 0x02) {
|
|
|
|
printer_type = P_ES2_20;
|
|
|
|
*bw_mode = (buffer[7] == 0x01);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (es40_cp790_plane_lengths[buffer[2]] == *plane_len) {
|
|
|
|
printer_type = P_ES40_CP790;
|
|
|
|
*bw_mode = (buffer[3] == 0x01);
|
|
|
|
goto done;
|
|
|
|
} else {
|
|
|
|
printer_type = P_ES3_30;
|
|
|
|
*bw_mode = (buffer[3] == 0x01);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
return printer_type;
|
|
|
|
}
|
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
static int read_data(int remaining, int present, int data_fd, uint8_t *target,
|
|
|
|
uint8_t *buf, uint16_t buflen) {
|
2012-10-26 23:21:33 -04:00
|
|
|
int cnt;
|
2012-11-21 17:03:41 -05:00
|
|
|
int wrote = 0;
|
2012-10-26 23:21:33 -04:00
|
|
|
|
2012-10-27 09:56:47 -04:00
|
|
|
while (remaining > 0) {
|
2012-10-26 23:21:33 -04:00
|
|
|
cnt = read(data_fd, buf + present, (remaining < (buflen-present)) ? remaining : (buflen-present));
|
|
|
|
|
|
|
|
if (cnt < 0)
|
|
|
|
return -1;
|
|
|
|
|
2012-10-27 10:21:47 -04:00
|
|
|
if (present) {
|
|
|
|
cnt += present;
|
|
|
|
present = 0;
|
|
|
|
}
|
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
memcpy(target + wrote, buf, cnt);
|
2012-10-26 23:21:33 -04:00
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
wrote += cnt;
|
|
|
|
remaining -= cnt;
|
2012-10-26 23:21:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return wrote;
|
|
|
|
}
|
2012-10-26 22:06:47 -04:00
|
|
|
|
2012-11-06 22:20:42 -05:00
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct libusb_context *ctx;
|
|
|
|
struct libusb_device **list;
|
|
|
|
struct libusb_device_handle *dev;
|
|
|
|
struct libusb_config_descriptor *config;
|
|
|
|
|
|
|
|
uint8_t endp_up = 0;
|
|
|
|
uint8_t endp_down = 0;
|
|
|
|
|
|
|
|
int printer_type = P_END;
|
|
|
|
|
|
|
|
int iface = 0;
|
|
|
|
|
|
|
|
int num, i;
|
|
|
|
int ret = 0;
|
|
|
|
int claimed;
|
|
|
|
int found = -1;
|
|
|
|
|
|
|
|
uint8_t rdbuf[READBACK_LEN], rdbuf2[READBACK_LEN];
|
|
|
|
int last_state = -1, state = S_IDLE;
|
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
int plane_len = 0, header_len = 0, footer_len = 0;
|
2012-11-06 22:20:42 -05:00
|
|
|
|
|
|
|
int bw_mode = 0;
|
|
|
|
int16_t paper_code_offset = -1;
|
|
|
|
int16_t paper_code = -1;
|
|
|
|
|
|
|
|
uint8_t buffer[BUF_LEN];
|
|
|
|
|
|
|
|
int data_fd = fileno(stdin);
|
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
int copies = 1;
|
2012-11-13 07:15:19 -05:00
|
|
|
char *uri = getenv("DEVICE_URI");;
|
|
|
|
char *use_serno = NULL;
|
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
uint8_t *plane_y, *plane_m, *plane_c, *footer, *header;
|
|
|
|
|
2012-11-06 22:20:42 -05:00
|
|
|
/* Static initialization */
|
|
|
|
setup_paper_codes();
|
|
|
|
|
2013-06-30 13:01:17 -04:00
|
|
|
DEBUG("Canon SELPHY ES/CP CUPS backend version " VERSION "/" BACKEND_VERSION " \n");
|
2013-06-30 07:28:51 -04:00
|
|
|
|
2012-11-06 22:20:42 -05:00
|
|
|
/* Cmdline help */
|
|
|
|
if (argc < 2) {
|
2013-06-30 07:28:51 -04:00
|
|
|
DEBUG("Usage:\n\t%s [ infile | - ]\n\t%s job user title num-copies options [ filename ] \n\n",
|
2012-11-13 07:15:19 -05:00
|
|
|
argv[0], argv[0]);
|
2012-11-06 22:20:42 -05:00
|
|
|
libusb_init(&ctx);
|
2012-12-13 07:03:51 -05:00
|
|
|
find_and_enumerate(ctx, &list, NULL, printer_type, 1);
|
2012-11-06 22:20:42 -05:00
|
|
|
libusb_free_device_list(list, 1);
|
|
|
|
libusb_exit(ctx);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-11-13 07:15:19 -05:00
|
|
|
/* Are we running as a CUPS backend? */
|
|
|
|
if (uri) {
|
2013-05-02 20:27:32 -04:00
|
|
|
if (argv[4])
|
|
|
|
copies = atoi(argv[4]);
|
2012-11-13 07:15:19 -05:00
|
|
|
if (argv[6]) { /* IOW, is it specified? */
|
|
|
|
data_fd = open(argv[6], O_RDONLY);
|
|
|
|
if (data_fd < 0) {
|
|
|
|
perror("ERROR:Can't open input file");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-02 11:34:39 -05:00
|
|
|
/* Ensure we're using BLOCKING I/O */
|
|
|
|
i = fcntl(data_fd, F_GETFL, 0);
|
|
|
|
if (i < 0) {
|
|
|
|
perror("ERROR:Can't open input");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
i &= ~O_NONBLOCK;
|
|
|
|
i = fcntl(data_fd, F_SETFL, 0);
|
|
|
|
if (i < 0) {
|
|
|
|
perror("ERROR:Can't open input");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-11-13 07:15:19 -05:00
|
|
|
/* Start parsing URI 'selphy://PID/SERIAL' */
|
2012-11-13 18:26:31 -05:00
|
|
|
if (strncmp(URI_PREFIX, uri, strlen(URI_PREFIX))) {
|
|
|
|
ERROR("Invalid URI prefix (%s)\n", uri);
|
2012-11-06 22:20:42 -05:00
|
|
|
exit(1);
|
|
|
|
}
|
2012-11-13 18:26:31 -05:00
|
|
|
use_serno = strchr(uri, '=');
|
|
|
|
if (!use_serno || !*(use_serno+1)) {
|
2012-11-13 07:15:19 -05:00
|
|
|
ERROR("Invalid URI (%s)\n", uri);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
use_serno++;
|
|
|
|
} else {
|
2013-07-17 19:47:47 -04:00
|
|
|
use_serno = getenv("DEVICE");
|
|
|
|
|
2012-11-13 07:15:19 -05:00
|
|
|
/* Open Input File */
|
|
|
|
if (strcmp("-", argv[1])) {
|
|
|
|
data_fd = open(argv[1], O_RDONLY);
|
|
|
|
if (data_fd < 0) {
|
|
|
|
perror("ERROR:Can't open input file");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2012-11-06 22:20:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Figure out printer this file is intended for */
|
|
|
|
read(data_fd, buffer, MAX_HEADER);
|
|
|
|
|
|
|
|
printer_type = parse_printjob(buffer, &bw_mode, &plane_len);
|
2013-06-30 12:27:43 -04:00
|
|
|
plane_len += 12; /* Add in plane header length! */
|
2012-11-06 22:20:42 -05:00
|
|
|
if (printer_type < 0) {
|
2012-11-13 07:15:19 -05:00
|
|
|
ERROR("Unrecognized printjob file format!\n");
|
2012-11-06 22:20:42 -05:00
|
|
|
exit(1);
|
|
|
|
}
|
2013-05-02 20:27:32 -04:00
|
|
|
footer_len = printers[printer_type].foot_length;
|
|
|
|
header_len = printers[printer_type].init_length;
|
2012-11-06 22:34:23 -05:00
|
|
|
DEBUG("%sFile intended for a '%s' printer\n", bw_mode? "B/W " : "", printers[printer_type].model);
|
2012-11-06 22:20:42 -05:00
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
/* Set up buffers */
|
|
|
|
plane_y = malloc(plane_len);
|
|
|
|
plane_m = malloc(plane_len);
|
|
|
|
plane_c = malloc(plane_len);
|
|
|
|
header = malloc(header_len);
|
|
|
|
footer = malloc(footer_len);
|
|
|
|
if (!plane_y || !plane_m || !plane_c || !header ||
|
|
|
|
(footer_len && !footer)) {
|
|
|
|
ERROR("Memory allocation failure!\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ignore SIGPIPE */
|
|
|
|
signal(SIGPIPE, SIG_IGN);
|
2013-05-03 07:42:23 -04:00
|
|
|
signal(SIGTERM, sigterm_handler);
|
2013-05-02 20:27:32 -04:00
|
|
|
|
|
|
|
/* Read in entire print job */
|
|
|
|
memcpy(header, buffer, header_len);
|
|
|
|
memmove(buffer, buffer+header_len,
|
|
|
|
MAX_HEADER-header_len);
|
|
|
|
read_data(plane_len, MAX_HEADER-header_len, data_fd, plane_y, buffer, BUF_LEN);
|
|
|
|
read_data(plane_len, 0, data_fd, plane_m, buffer, BUF_LEN);
|
|
|
|
read_data(plane_len, 0, data_fd, plane_c, buffer, BUF_LEN);
|
|
|
|
read_data(footer_len, 0, data_fd, footer, buffer, BUF_LEN);
|
|
|
|
close(data_fd); /* We're done */
|
|
|
|
|
2012-12-11 14:05:38 -05:00
|
|
|
/* Libusb setup */
|
|
|
|
libusb_init(&ctx);
|
2012-12-13 07:03:51 -05:00
|
|
|
found = find_and_enumerate(ctx, &list, use_serno, printer_type, 0);
|
2012-12-11 14:05:38 -05:00
|
|
|
|
|
|
|
/* Compute offsets and other such things */
|
2012-11-06 22:20:42 -05:00
|
|
|
paper_code_offset = printers[printer_type].paper_code_offset;
|
2012-11-07 19:00:29 -05:00
|
|
|
if (printers[printer_type].pgcode_offset != -1)
|
|
|
|
paper_code = printers[printer_type].paper_codes[buffer[printers[printer_type].pgcode_offset]];
|
2012-11-06 22:20:42 -05:00
|
|
|
|
2012-11-06 21:31:04 -05:00
|
|
|
if (found == -1) {
|
2012-11-13 07:15:19 -05:00
|
|
|
ERROR("No suitable printers found!\n");
|
2012-11-06 22:20:42 -05:00
|
|
|
ret = 3;
|
2012-10-26 22:06:47 -04:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2012-11-06 21:31:04 -05:00
|
|
|
ret = libusb_open(list[found], &dev);
|
2012-10-27 08:32:37 -04:00
|
|
|
if (ret) {
|
2013-05-04 07:52:22 -04:00
|
|
|
ERROR("Printer open failure (Need to be root?) (%d)\n", ret);
|
2012-11-06 22:20:42 -05:00
|
|
|
ret = 4;
|
2012-11-06 21:31:04 -05:00
|
|
|
goto done;
|
2012-11-05 20:33:10 -05:00
|
|
|
}
|
2012-10-26 22:06:47 -04:00
|
|
|
|
2012-10-27 09:56:47 -04:00
|
|
|
claimed = libusb_kernel_driver_active(dev, iface);
|
2012-10-27 08:32:37 -04:00
|
|
|
if (claimed) {
|
2012-10-27 09:56:47 -04:00
|
|
|
ret = libusb_detach_kernel_driver(dev, iface);
|
2012-10-27 08:32:37 -04:00
|
|
|
if (ret) {
|
2013-05-04 07:52:22 -04:00
|
|
|
ERROR("Printer open failure (Could not detach printer)\n");
|
2012-11-06 22:20:42 -05:00
|
|
|
ret = 4;
|
2012-11-05 18:51:32 -05:00
|
|
|
goto done_close;
|
2012-10-27 08:32:37 -04:00
|
|
|
}
|
|
|
|
}
|
2012-10-26 22:06:47 -04:00
|
|
|
|
2012-10-27 09:56:47 -04:00
|
|
|
ret = libusb_claim_interface(dev, iface);
|
2012-10-27 08:32:37 -04:00
|
|
|
if (ret) {
|
2013-05-04 07:52:22 -04:00
|
|
|
ERROR("Printer open failure (Could not claim printer interface)\n");
|
2012-11-06 22:20:42 -05:00
|
|
|
ret = 4;
|
2012-11-05 18:51:32 -05:00
|
|
|
goto done_close;
|
2012-10-27 08:32:37 -04:00
|
|
|
}
|
2012-10-26 22:06:47 -04:00
|
|
|
|
2012-11-06 21:31:04 -05:00
|
|
|
ret = libusb_get_active_config_descriptor(list[found], &config);
|
2012-11-05 19:23:02 -05:00
|
|
|
if (ret) {
|
2013-05-04 07:52:22 -04:00
|
|
|
ERROR("Printer open failire (Could not fetch config descriptor)\n");
|
2012-11-06 22:20:42 -05:00
|
|
|
ret = 4;
|
2012-11-05 19:23:02 -05:00
|
|
|
goto done_close;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0 ; i < config->interface[0].altsetting[0].bNumEndpoints ; i++) {
|
2012-11-07 18:29:47 -05:00
|
|
|
if ((config->interface[0].altsetting[0].endpoint[i].bmAttributes & 3) == LIBUSB_TRANSFER_TYPE_BULK) {
|
|
|
|
if (config->interface[0].altsetting[0].endpoint[i].bEndpointAddress & LIBUSB_ENDPOINT_IN)
|
|
|
|
endp_up = config->interface[0].altsetting[0].endpoint[i].bEndpointAddress;
|
2012-11-05 19:23:02 -05:00
|
|
|
else
|
2012-11-07 18:29:47 -05:00
|
|
|
endp_down = config->interface[0].altsetting[0].endpoint[i].bEndpointAddress;
|
2012-11-05 19:23:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
/* Read in the printer status */
|
2012-11-05 19:23:02 -05:00
|
|
|
ret = libusb_bulk_transfer(dev, endp_up,
|
2012-10-26 23:21:33 -04:00
|
|
|
rdbuf,
|
2012-10-28 12:19:17 -04:00
|
|
|
READBACK_LEN,
|
2012-10-26 23:21:33 -04:00
|
|
|
&num,
|
|
|
|
2000);
|
2012-11-22 07:40:32 -05:00
|
|
|
top:
|
|
|
|
|
2013-07-16 23:19:04 -04:00
|
|
|
if (state != last_state) {
|
|
|
|
DEBUG("last_state %d new %d\n", last_state, state);
|
|
|
|
}
|
|
|
|
|
2012-11-22 07:40:32 -05:00
|
|
|
/* Do it twice to clear initial state */
|
|
|
|
ret = libusb_bulk_transfer(dev, endp_up,
|
|
|
|
rdbuf,
|
|
|
|
READBACK_LEN,
|
|
|
|
&num,
|
|
|
|
2000);
|
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
if (ret < 0) {
|
2013-05-04 07:52:22 -04:00
|
|
|
ERROR("Failure to receive data from printer (libusb error %d: (%d/%d from 0x%02x))\n", ret, num, READBACK_LEN, endp_up);
|
2012-11-06 22:20:42 -05:00
|
|
|
ret = 4;
|
2012-11-05 18:51:32 -05:00
|
|
|
goto done_claimed;
|
2012-10-26 23:21:33 -04:00
|
|
|
}
|
|
|
|
|
2012-10-28 12:19:17 -04:00
|
|
|
if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
|
2012-11-06 22:34:23 -05:00
|
|
|
DEBUG("readback: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
|
2012-10-26 23:21:33 -04:00
|
|
|
rdbuf[0], rdbuf[1], rdbuf[2], rdbuf[3],
|
|
|
|
rdbuf[4], rdbuf[5], rdbuf[6], rdbuf[7],
|
|
|
|
rdbuf[8], rdbuf[9], rdbuf[10], rdbuf[11]);
|
2012-10-28 12:19:17 -04:00
|
|
|
memcpy(rdbuf2, rdbuf, READBACK_LEN);
|
2013-07-16 23:19:04 -04:00
|
|
|
} else if (state == last_state) {
|
2012-10-26 23:21:33 -04:00
|
|
|
sleep(1);
|
|
|
|
}
|
2013-07-16 23:19:04 -04:00
|
|
|
last_state = state;
|
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
fflush(stderr);
|
|
|
|
|
2012-11-21 23:36:18 -05:00
|
|
|
/* Error detection */
|
2012-11-21 23:18:56 -05:00
|
|
|
if (printers[printer_type].error_offset != -1 &&
|
|
|
|
rdbuf[printers[printer_type].error_offset]) {
|
2013-05-04 07:52:22 -04:00
|
|
|
ERROR("Printer reported error condition %02x; aborting. (Out of ribbon/paper?)\n", rdbuf[printers[printer_type].error_offset]);
|
2012-11-19 21:45:49 -05:00
|
|
|
ret = 4;
|
|
|
|
goto done_claimed;
|
|
|
|
}
|
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
switch(state) {
|
|
|
|
case S_IDLE:
|
2013-07-01 07:26:34 -04:00
|
|
|
INFO("Waiting for printer idle\n");
|
2012-10-28 12:19:17 -04:00
|
|
|
if (!fancy_memcmp(rdbuf, printers[printer_type].init_readback, READBACK_LEN, paper_code_offset, paper_code)) {
|
2012-10-26 23:21:33 -04:00
|
|
|
state = S_PRINTER_READY;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case S_PRINTER_READY:
|
2013-07-01 07:26:34 -04:00
|
|
|
INFO("Printing started; Sending init sequence\n");
|
2012-10-26 23:21:33 -04:00
|
|
|
/* Send printer init */
|
2013-06-27 23:02:34 -04:00
|
|
|
if ((ret = send_data(dev, endp_down, header, header_len)))
|
2012-11-05 18:51:32 -05:00
|
|
|
goto done_claimed;
|
2012-10-26 22:06:47 -04:00
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
state = S_PRINTER_INIT_SENT;
|
|
|
|
break;
|
|
|
|
case S_PRINTER_INIT_SENT:
|
2012-10-28 12:19:17 -04:00
|
|
|
if (!fancy_memcmp(rdbuf, printers[printer_type].ready_y_readback, READBACK_LEN, paper_code_offset, paper_code)) {
|
2012-10-26 23:21:33 -04:00
|
|
|
state = S_PRINTER_READY_Y;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case S_PRINTER_READY_Y:
|
|
|
|
if (bw_mode)
|
2013-07-01 07:21:44 -04:00
|
|
|
INFO("Sending BLACK plane\n");
|
2012-10-26 23:21:33 -04:00
|
|
|
else
|
2013-07-01 07:21:44 -04:00
|
|
|
INFO("Sending YELLOW plane\n");
|
2013-06-27 23:02:34 -04:00
|
|
|
|
|
|
|
if ((ret = send_data(dev, endp_down, plane_y, plane_len)))
|
2012-11-06 22:44:56 -05:00
|
|
|
goto done_claimed;
|
2013-06-27 23:02:34 -04:00
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
state = S_PRINTER_Y_SENT;
|
|
|
|
break;
|
|
|
|
case S_PRINTER_Y_SENT:
|
2012-10-28 12:19:17 -04:00
|
|
|
if (!fancy_memcmp(rdbuf, printers[printer_type].ready_m_readback, READBACK_LEN, paper_code_offset, paper_code)) {
|
2012-10-26 23:35:48 -04:00
|
|
|
if (bw_mode)
|
|
|
|
state = S_PRINTER_DONE;
|
|
|
|
else
|
|
|
|
state = S_PRINTER_READY_M;
|
2012-10-26 23:21:33 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case S_PRINTER_READY_M:
|
2013-07-01 07:21:44 -04:00
|
|
|
INFO("Sending MAGENTA plane\n");
|
2013-06-27 23:02:34 -04:00
|
|
|
|
|
|
|
if ((ret = send_data(dev, endp_down, plane_m, plane_len)))
|
2012-11-06 22:44:56 -05:00
|
|
|
goto done_claimed;
|
2013-06-27 23:02:34 -04:00
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
state = S_PRINTER_M_SENT;
|
|
|
|
break;
|
|
|
|
case S_PRINTER_M_SENT:
|
2012-10-28 12:19:17 -04:00
|
|
|
if (!fancy_memcmp(rdbuf, printers[printer_type].ready_c_readback, READBACK_LEN, paper_code_offset, paper_code)) {
|
2012-10-26 23:21:33 -04:00
|
|
|
state = S_PRINTER_READY_C;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case S_PRINTER_READY_C:
|
2013-07-01 07:21:44 -04:00
|
|
|
INFO("Sending CYAN plane\n");
|
2013-06-27 23:02:34 -04:00
|
|
|
|
|
|
|
if ((ret = send_data(dev, endp_down, plane_c, plane_len)))
|
2012-11-06 22:44:56 -05:00
|
|
|
goto done_claimed;
|
2013-06-27 23:02:34 -04:00
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
state = S_PRINTER_C_SENT;
|
|
|
|
break;
|
|
|
|
case S_PRINTER_C_SENT:
|
2012-10-28 12:19:17 -04:00
|
|
|
if (!fancy_memcmp(rdbuf, printers[printer_type].done_c_readback, READBACK_LEN, paper_code_offset, paper_code)) {
|
2012-10-26 23:21:33 -04:00
|
|
|
state = S_PRINTER_DONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case S_PRINTER_DONE:
|
2013-05-02 20:27:32 -04:00
|
|
|
if (footer_len) {
|
2013-07-01 07:21:44 -04:00
|
|
|
INFO("Cleaning up\n");
|
2013-05-02 20:27:32 -04:00
|
|
|
|
2013-06-27 23:02:34 -04:00
|
|
|
if ((ret = send_data(dev, endp_down, footer, footer_len)))
|
2012-11-06 22:44:56 -05:00
|
|
|
goto done_claimed;
|
2012-10-26 23:21:33 -04:00
|
|
|
}
|
|
|
|
state = S_FINISHED;
|
2012-11-13 19:30:43 -05:00
|
|
|
/* Intentional Fallthrough */
|
2012-10-26 23:21:33 -04:00
|
|
|
case S_FINISHED:
|
2012-11-13 19:30:43 -05:00
|
|
|
DEBUG("All data sent to printer!\n");
|
2012-10-26 23:21:33 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (state != S_FINISHED)
|
|
|
|
goto top;
|
2012-10-26 22:06:47 -04:00
|
|
|
|
2013-05-03 07:42:23 -04:00
|
|
|
/* Clean up */
|
|
|
|
if (terminate)
|
|
|
|
copies = 1;
|
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
INFO("Print complete (%d remaining)\n", copies - 1);
|
|
|
|
|
|
|
|
if (copies && --copies) {
|
|
|
|
state = S_IDLE;
|
|
|
|
goto top;
|
|
|
|
}
|
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
/* Done printing */
|
2013-05-02 20:27:32 -04:00
|
|
|
INFO("All printing done\n");
|
2013-02-02 12:49:02 -05:00
|
|
|
ret = 0;
|
2012-11-05 18:51:32 -05:00
|
|
|
|
|
|
|
done_claimed:
|
2012-10-27 09:56:47 -04:00
|
|
|
libusb_release_interface(dev, iface);
|
2012-10-26 22:06:47 -04:00
|
|
|
|
2012-11-05 20:33:10 -05:00
|
|
|
done_close:
|
2013-07-16 18:34:48 -04:00
|
|
|
#if 0
|
2012-10-26 22:06:47 -04:00
|
|
|
if (claimed)
|
2012-10-27 09:56:47 -04:00
|
|
|
libusb_attach_kernel_driver(dev, iface);
|
2013-07-16 18:34:48 -04:00
|
|
|
#endif
|
2012-10-26 22:06:47 -04:00
|
|
|
libusb_close(dev);
|
|
|
|
done:
|
|
|
|
libusb_free_device_list(list, 1);
|
|
|
|
libusb_exit(ctx);
|
2012-10-26 23:21:33 -04:00
|
|
|
|
2013-05-02 20:27:32 -04:00
|
|
|
if (plane_y)
|
|
|
|
free(plane_y);
|
|
|
|
if (plane_m)
|
|
|
|
free(plane_m);
|
|
|
|
if (plane_c)
|
|
|
|
free(plane_c);
|
|
|
|
if (header)
|
|
|
|
free(header);
|
|
|
|
if (footer)
|
|
|
|
free(footer);
|
|
|
|
|
2012-10-26 23:21:33 -04:00
|
|
|
|
2012-10-26 22:06:47 -04:00
|
|
|
return ret;
|
|
|
|
}
|
2013-06-30 12:31:04 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
***************************************************************************
|
|
|
|
|
|
|
|
Stream formats and readback codes for supported printers
|
|
|
|
|
|
|
|
***************************************************************************
|
|
|
|
Selphy ES1:
|
|
|
|
|
|
|
|
Init func: 40 00 [typeA] [pgcode] 00 00 00 00 00 00 00 00
|
|
|
|
Plane func: 40 01 [typeB] [plane] [length, 32-bit LE] 00 00 00 00
|
|
|
|
|
|
|
|
TypeA codes are 0x10 for Color papers, 0x20 for B&W papers.
|
|
|
|
TypeB codes are 0x01 for Color papers, 0x02 for B&W papers.
|
|
|
|
|
|
|
|
Plane codes are 0x01, 0x03, 0x07 for Y, M, and C, respectively.
|
|
|
|
B&W Jobs have a single plane code of 0x01.
|
|
|
|
|
|
|
|
'P' papers pgcode of 0x11 and a plane length of 2227456 bytes
|
|
|
|
'L' pgcode of 0x12 and a plane length of 1601600 bytes.
|
|
|
|
'C' pgcode of 0x13 and a plane length of 698880 bytes.
|
|
|
|
|
|
|
|
Readback values seen:
|
|
|
|
|
|
|
|
02 00 00 00 02 01 [pg] 01 00 00 00 00 [idle, waiting for init seq]
|
|
|
|
04 00 00 00 02 01 [pg] 01 00 00 00 00 [init received, not ready..]
|
|
|
|
04 00 01 00 02 01 [pg] 01 00 00 00 00 [waiting for Y data]
|
|
|
|
04 00 03 00 02 01 [pg] 01 00 00 00 00 [waiting for M data]
|
|
|
|
04 00 07 00 02 01 [pg] 01 00 00 00 00 [waiting for C data]
|
|
|
|
04 00 00 00 02 01 [pg] 01 00 00 00 00 [all data sent; not ready..]
|
|
|
|
05 00 00 00 02 01 [pg] 01 00 00 00 00 [?? transitions to this]
|
|
|
|
06 00 00 00 02 01 [pg] 01 00 00 00 00 [?? transitions to this]
|
|
|
|
02 00 00 00 02 01 [pg] 01 00 00 00 00 [..transitions back to idle]
|
|
|
|
|
|
|
|
02 01 00 00 01 ff ff ff 00 80 00 00 [error, no media]
|
|
|
|
02 01 00 00 01 ff ff ff 00 00 00 00 [error, cover open]
|
|
|
|
|
|
|
|
Known paper types for all ES printers: P, Pbw, L, C, Cl
|
|
|
|
Additional types for ES3/30/40: Pg, Ps
|
|
|
|
|
|
|
|
[pg] is: 0x01 for P-papers
|
|
|
|
0x02 for L-papers
|
|
|
|
0x03 for C-papers
|
|
|
|
|
|
|
|
***************************************************************************
|
|
|
|
Selphy ES2/20:
|
|
|
|
|
|
|
|
Init func: 40 00 [pgcode] 00 02 00 00 [type] 00 00 00 [pg2] [length, 32-bit LE]
|
|
|
|
Plane func: 40 01 [plane] 00 00 00 00 00 00 00 00 00
|
|
|
|
|
|
|
|
Type codes are 0x00 for Color papers, 0x01 for B&W papers.
|
|
|
|
|
|
|
|
Plane codes are 0x01, 0x02, 0x03 for Y, M, and C, respectively.
|
|
|
|
B&W Jobs have a single plane code of 0x01.
|
|
|
|
|
|
|
|
'P' papers pgcode of 0x01 and a plane length of 2227456 bytes
|
|
|
|
'L' pgcode of 0x02 and a plane length of 1601600 bytes.
|
|
|
|
'C' pgcode of 0x03 and a plane length of 698880 bytes.
|
|