[misc] Full support for SELPHY CP780 printer

Also, fixed long-standing bug in parsing paper type.
This commit is contained in:
Solomon Peachy 2012-11-07 19:00:29 -05:00
parent f3f30a65d6
commit 9fb2c5ac4e
4 changed files with 28 additions and 19 deletions

View File

@ -208,18 +208,20 @@
'Card' paper pgcode 0x03 plane length 698880 bytes.
'Wide' paper pgcode 0x04 plane length 2976512 bytes.
Known readback values (From a SELPHY CP760/CP720)
Known readback values (From a SELPHY CP760/CP720/CP780)
01 00 00 00 00 00 [pg] 00 00 00 00 00 [idle, waiting for init]
02 00 00 00 70 00 [pg] 00 00 00 00 00 [waiting for Y data]
04 00 00 00 00 00 [pg] 00 00 00 00 00 [waiting for M data]
08 00 00 00 00 00 [pg] 00 00 00 00 00 [waiting for C data]
10 00 00 00 00 00 [pg] 00 00 00 00 00 [C done, waiting]
20 00 00 00 00 00 [pg] 00 00 00 00 00 [All done]
01 00 00 00 00 00 [pg] 00 00 00 00 [xx] [idle, waiting for init]
02 00 00 00 70 00 [pg] 00 00 00 00 [xx] [waiting for Y data]
04 00 00 00 00 00 [pg] 00 00 00 00 [xx] [waiting for M data]
08 00 00 00 00 00 [pg] 00 00 00 00 [xx] [waiting for C data]
10 00 00 00 00 00 [pg] 00 00 00 00 [xx] [C done, waiting]
20 00 00 00 00 00 [pg] 00 00 00 00 [xx] [All done]
'P' paper has a code of 0x11
'CP_L' paper has a code of 0x22
[xx] is 0x01 on the CP780, 0x00 on all others.
When 'P' ribbon is present, but no paper, code is '0x01'
Readback codes for other paper types are unknown.

View File

@ -47,7 +47,7 @@
struct printer_data {
int type; /* P_??? */
char *model; /* "SELPHY ES1" */
char *model; /* eg "SELPHY ES1" */
int init_length;
int foot_length;
int16_t init_readback[READBACK_LEN];
@ -56,7 +56,8 @@ struct printer_data {
int16_t ready_c_readback[READBACK_LEN];
int16_t done_c_readback[READBACK_LEN];
int16_t paper_codes[256];
int16_t paper_code_offset;
int16_t pgcode_offset; /* Offset into printjob for paper type */
int16_t paper_code_offset; /* Offset in readback for paper type */
};
/* printer types */
@ -81,6 +82,7 @@ struct printer_data printers[P_END] = {
.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 },
// .paper_codes
.pgcode_offset = 3,
.paper_code_offset = 6,
},
{ .type = P_ES2_20,
@ -93,6 +95,7 @@ struct printer_data printers[P_END] = {
.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 },
// .paper_codes
.pgcode_offset = 2,
.paper_code_offset = 4,
},
{ .type = P_ES3_30,
@ -105,6 +108,7 @@ struct printer_data printers[P_END] = {
.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 },
// .paper_codes
.pgcode_offset = -1,
.paper_code_offset = -1,
},
{ .type = P_ES40_CP790,
@ -117,6 +121,7 @@ struct printer_data printers[P_END] = {
// .ready_c_readback =
// .done_c_readback =
// .paper_codes
.pgcode_offset = 2,
// .paper_code_offset = -1,
},
{ .type = P_CP900,
@ -129,18 +134,20 @@ struct printer_data printers[P_END] = {
// .ready_c_readback =
// .done_c_readback =
// .paper_codes
.pgcode_offset = 3,
// .paper_code_offset = -1,
},
{ .type = P_CP_XXX,
.model = "SELPHY CP Series (!CP790/CP900)",
.init_length = 12,
.foot_length = 0,
.init_readback = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, 0x00 },
.ready_y_readback = { 0x02, 0x00, 0x00, 0x00, 0x70, 0x00, -1, 0x00, 0x00, 0x00, 0x00, 0x00 },
.ready_m_readback = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, 0x00 },
.ready_c_readback = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, 0x00 },
.done_c_readback = { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, 0x00 },
.init_readback = { 0x01, 0x00, 0x00, 0x00, 0x00, 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 },
// .paper_codes
.pgcode_offset = 3,
.paper_code_offset = 6,
},
};

View File

@ -220,7 +220,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
libusb_get_string_descriptor_ascii(dev, desc.iSerialNumber, serial, STR_LEN_MAX);
}
DEBUG("%s%sPID: %04x Product: '%s' Serial: '%s'\n",
DEBUG("%s%sPID: %04X Product: '%s' Serial: '%s'\n",
(!valid) ? "UNRECOGNIZED: " : "",
(found == i) ? "MATCH: " : "",
desc.idProduct, product, serial);
@ -228,7 +228,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
// XXX MATCH based on passed-in serial number?
if (valid && scan_only) {
fprintf(stdout, "direct selphy://%04x/%s \"%s\" \"%s\" \"MFG:Canon;CMD:SelphyRaster;CLS:PRINTER;MDL:%s;DES:%s;SN:%s\" \"\"\n",
fprintf(stdout, "direct selphy://%04X/%s \"%s\" \"%s\" \"MFG:Canon;CMD:SelphyRaster;CLS:PRINTER;MDL:%s;DES:%s;SN:%s\" \"\"\n",
desc.idProduct, serial, product, product,
product + strlen("Canon "), product, serial);
}
@ -309,8 +309,8 @@ int main (int argc, char **argv)
plane_len += 12; /* Add in plane header */
paper_code_offset = printers[printer_type].paper_code_offset;
if (paper_code_offset != -1)
paper_code = printers[printer_type].paper_codes[paper_code_offset];
if (printers[printer_type].pgcode_offset != -1)
paper_code = printers[printer_type].paper_codes[buffer[printers[printer_type].pgcode_offset]];
/* Libusb setup */
libusb_init(&ctx);

View File

@ -152,7 +152,7 @@ int main(int argc, char **argv)
plane_len += 12; /* Add in plane header */
paper_code_offset = printers[printer_type].paper_code_offset;
if (paper_code_offset != -1)
paper_code = printers[printer_type].paper_codes[paper_code_offset];
paper_code = printers[printer_type].paper_codes[buffer[printers[printer_type].pgcode_offset]];
top: