dnp_ds40: Add status query.
This commit is contained in:
parent
15909ce5ad
commit
ad6d71afa0
|
@ -112,6 +112,46 @@ static char *dnpds40_media_types(char *str)
|
|||
return "Unknown type";
|
||||
}
|
||||
|
||||
static char *dnpds40_statuses(char *str)
|
||||
{
|
||||
char tmp[6];
|
||||
int i;
|
||||
memcpy(tmp, str, 5);
|
||||
tmp[5] = 0;
|
||||
|
||||
i = atoi(tmp);
|
||||
|
||||
switch (i) {
|
||||
case 0: return "Idle";
|
||||
case 1: return "Printing";
|
||||
case 500: return "Cooling Print Head";
|
||||
case 510: return "Cooling Paper Motor";
|
||||
case 1000: return "Cover Open";
|
||||
case 1010: return "No Scrap Box";
|
||||
case 1100: return "Paper End";
|
||||
case 1200: return "Ribbon End";
|
||||
case 1300: return "Paper jam";
|
||||
case 1400: return "Ribbon error";
|
||||
case 1500: return "Paper Definition Error";
|
||||
case 1600: return "Data Error";
|
||||
case 2000: return "Head Voltage Error";
|
||||
case 2100: return "Head Position Error";
|
||||
case 2200: return "Power Supply Fan Error";
|
||||
case 2300: return "Cutter Error";
|
||||
case 2400: return "Pinch Roller Error";
|
||||
case 2500: return "Abnormal Head Temperature";
|
||||
case 2600: return "Abnormal Media Temperature";
|
||||
case 2610: return "Abnormal Paper Motor Temperature";
|
||||
case 2700: return "Ribbon Tension Error";
|
||||
case 2800: return "RF-ID Module Error";
|
||||
case 3000: return "System Error";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "Unkown type";
|
||||
}
|
||||
|
||||
static void *dnpds40_init(void)
|
||||
{
|
||||
struct dnpds40_ctx *ctx = malloc(sizeof(struct dnpds40_ctx));
|
||||
|
@ -362,6 +402,47 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dnpds40_get_status(struct dnpds40_ctx *ctx)
|
||||
{
|
||||
struct dnpds40_cmd cmd;
|
||||
uint8_t rdbuf[READBACK_LEN];
|
||||
char tmp[9];
|
||||
|
||||
int ret, i, num = 0;
|
||||
|
||||
/* Get Firmware Version */
|
||||
dnpds40_build_cmd(&cmd, "STATUS", "", 0);
|
||||
|
||||
if ((ret = send_data(ctx->dev, ctx->endp_down,
|
||||
(uint8_t*)&cmd, sizeof(cmd))))
|
||||
return ret;
|
||||
|
||||
/* Read in the response */
|
||||
memset(rdbuf, 0, sizeof(rdbuf));
|
||||
ret = libusb_bulk_transfer(ctx->dev, ctx->endp_up,
|
||||
rdbuf,
|
||||
READBACK_LEN,
|
||||
&num,
|
||||
5000);
|
||||
|
||||
if (ret < 0 || num < 8) {
|
||||
ERROR("Failure to receive data from printer (libusb error %d: (%d/%d from 0x%02x))\n", ret, num, (int)sizeof(rdbuf), ctx->endp_up);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
return 4;
|
||||
}
|
||||
|
||||
memcpy(tmp, rdbuf, 8);
|
||||
tmp[8] = 0;
|
||||
i = atoi(tmp); /* Length of payload in bytes, possibly padded */
|
||||
|
||||
dnpds40_cleanup_string((char*)rdbuf + 8, i);
|
||||
|
||||
INFO("Printer Status: %s => %s\n", (char*)rdbuf + 8, dnpds40_statuses((char*)rdbuf+8));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dnpds40_cmdline(char *caller)
|
||||
{
|
||||
DEBUG("\t\t%s [ -qs | -qi ]\n", caller);
|
||||
|
@ -377,10 +458,8 @@ static int dnpds40_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
|||
return (!strcmp("-qs", arg1) ||
|
||||
!strcmp("-qi", arg1));
|
||||
|
||||
#if 0
|
||||
if (!strcmp("-qs", arg1))
|
||||
return dnpds40_get_status(ctx);
|
||||
#endif
|
||||
if (!strcmp("-qi", arg1))
|
||||
return dnpds40_get_info(ctx);
|
||||
|
||||
|
@ -390,7 +469,7 @@ static int dnpds40_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
|||
/* Exported */
|
||||
struct dyesub_backend dnpds40_backend = {
|
||||
.name = "DNP DS40/DS80",
|
||||
.version = "0.01",
|
||||
.version = "0.02",
|
||||
.uri_prefix = "dnpds40",
|
||||
.cmdline_usage = dnpds40_cmdline,
|
||||
.cmdline_arg = dnpds40_cmdline_arg,
|
||||
|
|
Loading…
Reference in a new issue