hiti: Rework paper/ribbon queries a little
* Read the paper type from the correct offset of CMD_RDS_RSUS * Use structs instead of byte arrays for RIS and RSUS queries Unable to test for regressions at the moment.
This commit is contained in:
parent
04d85d4887
commit
9c93ee1091
|
@ -391,6 +391,27 @@ struct hiti_matrix {
|
||||||
/* @100 */
|
/* @100 */
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
struct hiti_ribbon {
|
||||||
|
uint16_t unk;
|
||||||
|
uint8_t type; /* RIBBON_TYPE_XXX */
|
||||||
|
uint16_t unk2;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
#define RIBBON_TYPE_4x6 0x01
|
||||||
|
#define RIBBON_TYPE_5x7 0x02
|
||||||
|
#define RIBBON_TYPE_6x9 0x03
|
||||||
|
#define RIBBON_TYPE_6x8 0x04
|
||||||
|
|
||||||
|
struct hiti_paper {
|
||||||
|
uint8_t unk;
|
||||||
|
uint8_t type; /* PAPER_TYPE_XXX */
|
||||||
|
uint16_t unk2;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
#define PAPER_TYPE_5INCH 0x02
|
||||||
|
#define PAPER_TYPE_6INCH 0x01
|
||||||
|
#define PAPER_TYPE_NONE 0x00
|
||||||
|
|
||||||
/* Private data structure */
|
/* Private data structure */
|
||||||
struct hiti_printjob {
|
struct hiti_printjob {
|
||||||
struct dyesub_job_common common;
|
struct dyesub_job_common common;
|
||||||
|
@ -416,8 +437,8 @@ struct hiti_ctx {
|
||||||
char version[256];
|
char version[256];
|
||||||
char id[256];
|
char id[256];
|
||||||
uint8_t matrix[256]; // XXX convert to struct matrix */
|
uint8_t matrix[256]; // XXX convert to struct matrix */
|
||||||
uint8_t supplies[5]; /* Ribbon */ // XXX convert to struct
|
struct hiti_ribbon ribbon;
|
||||||
uint8_t supplies2[4]; /* Paper */ // XXX convert to struct
|
struct hiti_paper paper;
|
||||||
struct hiti_calibration calibration;
|
struct hiti_calibration calibration;
|
||||||
uint8_t led_calibration[10]; // XXX convert to struct
|
uint8_t led_calibration[10]; // XXX convert to struct
|
||||||
uint8_t unk_8010[15]; // XXX
|
uint8_t unk_8010[15]; // XXX
|
||||||
|
@ -634,11 +655,6 @@ static const char *hiti_jobstatuses(uint8_t code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RIBBON_TYPE_4x6 0x01
|
|
||||||
#define RIBBON_TYPE_5x7 0x02
|
|
||||||
#define RIBBON_TYPE_6x9 0x03
|
|
||||||
#define RIBBON_TYPE_6x8 0x04
|
|
||||||
|
|
||||||
static const char* hiti_ribbontypes(uint8_t code)
|
static const char* hiti_ribbontypes(uint8_t code)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
@ -661,10 +677,6 @@ static unsigned int hiti_ribboncounts(uint8_t code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PAPER_TYPE_5INCH 0x02
|
|
||||||
#define PAPER_TYPE_6INCH 0x01
|
|
||||||
#define PAPER_TYPE_NONE 0x00
|
|
||||||
|
|
||||||
static const char* hiti_papers(uint8_t code)
|
static const char* hiti_papers(uint8_t code)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
@ -929,13 +941,13 @@ static int hiti_get_status(struct hiti_ctx *ctx)
|
||||||
hiti_errors(err), err);
|
hiti_errors(err), err);
|
||||||
|
|
||||||
INFO("Media: %s (%02x / %04x) : %03u/%03u\n",
|
INFO("Media: %s (%02x / %04x) : %03u/%03u\n",
|
||||||
hiti_ribbontypes(ctx->supplies[2]),
|
hiti_ribbontypes(ctx->ribbon.type),
|
||||||
ctx->supplies[2],
|
ctx->ribbon.type,
|
||||||
ctx->ribbonvendor,
|
ctx->ribbonvendor,
|
||||||
ctx->media_remain, hiti_ribboncounts(ctx->supplies[2]));
|
ctx->media_remain, hiti_ribboncounts(ctx->ribbon.type));
|
||||||
INFO("Paper: %s (%02x)\n",
|
INFO("Paper: %s (%02x)\n",
|
||||||
hiti_papers(ctx->supplies2[0]),
|
hiti_papers(ctx->paper.type),
|
||||||
ctx->supplies2[0]);
|
ctx->paper.type);
|
||||||
|
|
||||||
/* Find out if we have any jobs outstanding */
|
/* Find out if we have any jobs outstanding */
|
||||||
struct hiti_job job = { 0 };
|
struct hiti_job job = { 0 };
|
||||||
|
@ -1031,21 +1043,21 @@ static int hiti_attach(void *vctx, struct dyesub_connection *conn, uint8_t jobid
|
||||||
}
|
}
|
||||||
// do real stuff
|
// do real stuff
|
||||||
} else {
|
} else {
|
||||||
ctx->supplies2[0] = PAPER_TYPE_6INCH;
|
ctx->paper.type = PAPER_TYPE_6INCH;
|
||||||
ctx->supplies[2] = RIBBON_TYPE_4x6;
|
ctx->ribbon.type = RIBBON_TYPE_4x6;
|
||||||
|
|
||||||
if (getenv("MEDIA_CODE")) {
|
if (getenv("MEDIA_CODE")) {
|
||||||
// set fake fw version?
|
// set fake fw version?
|
||||||
ctx->supplies[2] = atoi(getenv("MEDIA_CODE"));
|
ctx->ribbon.type = atoi(getenv("MEDIA_CODE"));
|
||||||
if (ctx->supplies[2] == RIBBON_TYPE_5x7)
|
if (ctx->ribbon.type == RIBBON_TYPE_5x7)
|
||||||
ctx->supplies2[0] = PAPER_TYPE_5INCH;
|
ctx->paper.type = PAPER_TYPE_5INCH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
|
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
|
||||||
ctx->marker.name = hiti_ribbontypes(ctx->supplies[2]);
|
ctx->marker.name = hiti_ribbontypes(ctx->ribbon.type);
|
||||||
ctx->marker.numtype = ctx->supplies[2];
|
ctx->marker.numtype = ctx->ribbon.type;
|
||||||
ctx->marker.levelmax = hiti_ribboncounts(ctx->supplies[2]);
|
ctx->marker.levelmax = hiti_ribboncounts(ctx->ribbon.type);
|
||||||
ctx->marker.levelnow = 0;
|
ctx->marker.levelnow = 0;
|
||||||
|
|
||||||
return CUPS_BACKEND_OK;
|
return CUPS_BACKEND_OK;
|
||||||
|
@ -1852,7 +1864,7 @@ static int hiti_read_parse(void *vctx, const void **vjob, int data_fd, int copie
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity check against paper */
|
/* Sanity check against paper */
|
||||||
switch (ctx->supplies2[0]) {
|
switch (ctx->paper.type) {
|
||||||
case PAPER_TYPE_5INCH:
|
case PAPER_TYPE_5INCH:
|
||||||
if (job->hdr.cols != 1548) {
|
if (job->hdr.cols != 1548) {
|
||||||
ERROR("Illegal job on 5-inch paper!\n");
|
ERROR("Illegal job on 5-inch paper!\n");
|
||||||
|
@ -1868,19 +1880,19 @@ static int hiti_read_parse(void *vctx, const void **vjob, int data_fd, int copie
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR("Unknown paper type (%d)!\n", ctx->supplies2[0]);
|
ERROR("Unknown paper type (%d)!\n", ctx->paper.type);
|
||||||
hiti_cleanup_job(job);
|
hiti_cleanup_job(job);
|
||||||
return CUPS_BACKEND_CANCEL;
|
return CUPS_BACKEND_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity check against ribbon type */
|
/* Sanity check against ribbon type */
|
||||||
switch (ctx->supplies[2]) {
|
switch (ctx->ribbon.type) {
|
||||||
case RIBBON_TYPE_4x6:
|
case RIBBON_TYPE_4x6:
|
||||||
if (job->hdr.code != PRINT_TYPE_6x4 &&
|
if (job->hdr.code != PRINT_TYPE_6x4 &&
|
||||||
job->hdr.code != PRINT_TYPE_6x4_2UP &&
|
job->hdr.code != PRINT_TYPE_6x4_2UP &&
|
||||||
job->hdr.code != PRINT_TYPE_6x2) {
|
job->hdr.code != PRINT_TYPE_6x2) {
|
||||||
ERROR("Invalid ribbon type vs job (%02x/%02x)\n",
|
ERROR("Invalid ribbon type vs job (%02x/%02x)\n",
|
||||||
ctx->supplies[2], job->hdr.code);
|
ctx->ribbon.type, job->hdr.code);
|
||||||
hiti_cleanup_job(job);
|
hiti_cleanup_job(job);
|
||||||
return CUPS_BACKEND_CANCEL;
|
return CUPS_BACKEND_CANCEL;
|
||||||
}
|
}
|
||||||
|
@ -1890,7 +1902,7 @@ static int hiti_read_parse(void *vctx, const void **vjob, int data_fd, int copie
|
||||||
job->hdr.code != PRINT_TYPE_5x3_5 &&
|
job->hdr.code != PRINT_TYPE_5x3_5 &&
|
||||||
job->hdr.code != PRINT_TYPE_5x7_2UP) {
|
job->hdr.code != PRINT_TYPE_5x7_2UP) {
|
||||||
ERROR("Invalid ribbon type vs job (%02x/%02x)\n",
|
ERROR("Invalid ribbon type vs job (%02x/%02x)\n",
|
||||||
ctx->supplies[2], job->hdr.code);
|
ctx->ribbon.type, job->hdr.code);
|
||||||
hiti_cleanup_job(job);
|
hiti_cleanup_job(job);
|
||||||
return CUPS_BACKEND_CANCEL;
|
return CUPS_BACKEND_CANCEL;
|
||||||
}
|
}
|
||||||
|
@ -1901,7 +1913,7 @@ static int hiti_read_parse(void *vctx, const void **vjob, int data_fd, int copie
|
||||||
job->hdr.code != PRINT_TYPE_6x8 &&
|
job->hdr.code != PRINT_TYPE_6x8 &&
|
||||||
job->hdr.code != PRINT_TYPE_6x2) {
|
job->hdr.code != PRINT_TYPE_6x2) {
|
||||||
ERROR("Invalid ribbon type vs job (%02x/%02x)\n",
|
ERROR("Invalid ribbon type vs job (%02x/%02x)\n",
|
||||||
ctx->supplies[2], job->hdr.code);
|
ctx->ribbon.type, job->hdr.code);
|
||||||
hiti_cleanup_job(job);
|
hiti_cleanup_job(job);
|
||||||
return CUPS_BACKEND_CANCEL;
|
return CUPS_BACKEND_CANCEL;
|
||||||
}
|
}
|
||||||
|
@ -1914,7 +1926,7 @@ static int hiti_read_parse(void *vctx, const void **vjob, int data_fd, int copie
|
||||||
job->hdr.code != PRINT_TYPE_6x9 &&
|
job->hdr.code != PRINT_TYPE_6x9 &&
|
||||||
job->hdr.code != PRINT_TYPE_6x9_2UP) {
|
job->hdr.code != PRINT_TYPE_6x9_2UP) {
|
||||||
ERROR("Invalid ribbon type vs job (%02x/%02x)\n",
|
ERROR("Invalid ribbon type vs job (%02x/%02x)\n",
|
||||||
ctx->supplies[2], job->hdr.code);
|
ctx->ribbon.type, job->hdr.code);
|
||||||
hiti_cleanup_job(job);
|
hiti_cleanup_job(job);
|
||||||
return CUPS_BACKEND_CANCEL;
|
return CUPS_BACKEND_CANCEL;
|
||||||
}
|
}
|
||||||
|
@ -2471,15 +2483,15 @@ static int hiti_query_tphv(struct hiti_ctx *ctx)
|
||||||
static int hiti_query_supplies(struct hiti_ctx *ctx)
|
static int hiti_query_supplies(struct hiti_ctx *ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint16_t len = 5;
|
uint16_t len = sizeof(ctx->ribbon);
|
||||||
uint8_t arg = 0;
|
uint8_t arg = 0;
|
||||||
|
|
||||||
ret = hiti_docmd_resp(ctx, CMD_RDS_RSUS, &arg, sizeof(arg), ctx->supplies, &len);
|
ret = hiti_docmd_resp(ctx, CMD_RDS_RSUS, &arg, sizeof(arg), (uint8_t*)&ctx->ribbon, &len);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
len = 4;
|
len = sizeof(ctx->paper);
|
||||||
ret = hiti_docmd_resp(ctx, CMD_RDS_RIS, NULL, 0, ctx->supplies2, &len);
|
ret = hiti_docmd_resp(ctx, CMD_RDS_RIS, NULL, 0, (uint8_t*)&ctx->paper, &len);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -2698,7 +2710,7 @@ static const char *hiti_prefixes[] = {
|
||||||
|
|
||||||
const struct dyesub_backend hiti_backend = {
|
const struct dyesub_backend hiti_backend = {
|
||||||
.name = "HiTi Photo Printers",
|
.name = "HiTi Photo Printers",
|
||||||
.version = "0.41",
|
.version = "0.42",
|
||||||
.uri_prefixes = hiti_prefixes,
|
.uri_prefixes = hiti_prefixes,
|
||||||
.cmdline_usage = hiti_cmdline,
|
.cmdline_usage = hiti_cmdline,
|
||||||
.cmdline_arg = hiti_cmdline_arg,
|
.cmdline_arg = hiti_cmdline_arg,
|
||||||
|
|
Loading…
Reference in New Issue