|
|
|
@ -103,6 +103,9 @@ struct shinkos6245_ctx {
|
|
|
|
|
|
|
|
|
|
uint8_t *databuf;
|
|
|
|
|
int datalen;
|
|
|
|
|
|
|
|
|
|
uint16_t last_donor;
|
|
|
|
|
uint16_t last_remain;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Structs for printer */
|
|
|
|
@ -1481,6 +1484,9 @@ static void shinkos6245_attach(void *vctx, struct libusb_device_handle *dev,
|
|
|
|
|
ctx->jobid = jobid & 0x7f;
|
|
|
|
|
if (!ctx->jobid)
|
|
|
|
|
ctx->jobid++;
|
|
|
|
|
|
|
|
|
|
/* Initialize donor */
|
|
|
|
|
ctx->last_donor = ctx->last_remain = 65535;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void shinkos6245_teardown(void *vctx) {
|
|
|
|
@ -1666,6 +1672,13 @@ static int shinkos6245_main_loop(void *vctx, int copies) {
|
|
|
|
|
goto printer_error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Tell CUPS about the consumables we report */
|
|
|
|
|
ATTR("marker-colors=#00FFFF#FF00FF#FFFF00\n");
|
|
|
|
|
ATTR("marker-high-levels=100\n");
|
|
|
|
|
ATTR("marker-low-levels=10\n");
|
|
|
|
|
ATTR("marker-names=Ribbon\n");
|
|
|
|
|
ATTR("marker-types=ribbon\n");
|
|
|
|
|
|
|
|
|
|
// XXX check copies against remaining media!
|
|
|
|
|
|
|
|
|
|
top:
|
|
|
|
@ -1688,10 +1701,25 @@ top:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
|
|
|
|
|
uint16_t donor, remain;
|
|
|
|
|
|
|
|
|
|
memcpy(rdbuf2, rdbuf, READBACK_LEN);
|
|
|
|
|
|
|
|
|
|
INFO("Printer Status: 0x%02x (%s)\n",
|
|
|
|
|
sts->hdr.status, status_str(sts->hdr.status));
|
|
|
|
|
|
|
|
|
|
/* Guessimate a percentage for the remaining media */
|
|
|
|
|
donor = le32_to_cpu(sts->count_ribbon_left) * 100 / (le32_to_cpu(sts->count_ribbon_left)+le32_to_cpu(sts->count_paper));
|
|
|
|
|
if (donor != ctx->last_donor) {
|
|
|
|
|
ctx->last_donor = donor;
|
|
|
|
|
ATTR("marker-levels=%d\n", donor);
|
|
|
|
|
}
|
|
|
|
|
remain = le32_to_cpu(sts->count_ribbon_left);
|
|
|
|
|
if (remain != ctx->last_remain) {
|
|
|
|
|
ctx->last_remain = remain;
|
|
|
|
|
ATTR("marker-message=\"%d prints remaining on ribbon\"\n", remain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sts->hdr.result != RESULT_SUCCESS)
|
|
|
|
|
goto printer_error;
|
|
|
|
|
if (sts->hdr.error == ERROR_PRINTER)
|
|
|
|
@ -1838,7 +1866,7 @@ static int shinkos6245_query_serno(struct libusb_device_handle *dev, uint8_t end
|
|
|
|
|
|
|
|
|
|
struct dyesub_backend shinkos6245_backend = {
|
|
|
|
|
.name = "Shinko/Sinfonia CHC-S6245",
|
|
|
|
|
.version = "0.05WIP",
|
|
|
|
|
.version = "0.06WIP",
|
|
|
|
|
.uri_prefix = "shinkos6245",
|
|
|
|
|
.cmdline_usage = shinkos6245_cmdline,
|
|
|
|
|
.cmdline_arg = shinkos6245_cmdline_arg,
|
|
|
|
|