magicard: Add a couple of USB PIDs and self test, eject, and reset commands

This commit is contained in:
Solomon Peachy 2018-03-10 07:51:35 -05:00
parent fa5f1ee796
commit 44162d76b6
3 changed files with 109 additions and 7 deletions

8
README
View file

@ -793,6 +793,9 @@ Notes:
Work-in-progress printers:
Rio 2E
Tango +L
Enduro
Enduro+
(And all others)
This backend supports additional commands:
@ -804,5 +807,8 @@ Notes:
-s Query printer status
-q Generate printer information dump
-I Query printer sensors
-T Print self-test card
-E Eject card in printer
-R Reset printer
***************************************************************************
***************************************************************************

View file

@ -46,6 +46,8 @@
/* Exported */
#define USB_VID_MAGICARD 0x0C1F
#define USB_PID_MAGICARD_TANGO2E 0x1800
#define USB_PID_MAGICARD_ENDURO 0x4800 // ??
#define USB_PID_MAGICARD_ENDUROPLUS 0x880A // ??
/* Gamma tables computed with this perl program:
@ -169,11 +171,11 @@ static struct magicard_requests magicard_sta_requests[] = {
{ "PSR", "Print Head Serial Number", TYPE_STRING },
{ "BSR", "PCB Serial Number", TYPE_STRING },
{ "VRS", "Firmware Version", TYPE_STRING },
{ "FDC", "Head Density", TYPE_STRINGINT },
{ "FSP", "Image Start", TYPE_STRINGINT },
{ "FEP", "Image End", TYPE_STRINGINT },
{ "FDC", "Head Density", TYPE_STRINGINT }, /* 25 per step */
{ "FSP", "Image Start", TYPE_STRINGINT }, /* 8 steps per pixel */
{ "FEP", "Image End", TYPE_STRINGINT }, /* 8 steps per pixel */
{ "FSS", "Ramp Adjust", TYPE_STRINGINT },
{ "FPP", "Head Position", TYPE_STRINGINT },
{ "FPP", "Head Position", TYPE_STRINGINT }, /* L-R alignment */
{ "MDL", "Model", TYPE_MODEL }, /* 0 == Standard. Others? */
{ "PID", "USB PID", TYPE_STRINGINT_HEX }, /* ASCII integer, but needs to be shown as hex */
{ "VID", "USB VID", TYPE_STRINGINT_HEX }, /* ASCII integer, but needs to be shown as hex */
@ -285,6 +287,48 @@ static int magicard_query_sensors(struct magicard_ctx *ctx)
return 0;
}
static int magicard_selftest_card(struct magicard_ctx *ctx)
{
int ret = 0;
uint8_t buf[256];
char buf2[24];
snprintf(buf2, sizeof(buf2), "TST,");
ret = magicard_build_cmd_simple(buf, buf2);
ret = send_data(ctx->dev, ctx->endp_down,
buf, ret);
return ret;
}
static int magicard_reset(struct magicard_ctx *ctx)
{
int ret = 0;
uint8_t buf[256];
char buf2[24];
snprintf(buf2, sizeof(buf2), "RST,");
ret = magicard_build_cmd_simple(buf, buf2);
ret = send_data(ctx->dev, ctx->endp_down,
buf, ret);
return ret;
}
static int magicard_eject(struct magicard_ctx *ctx)
{
int ret = 0;
uint8_t buf[256];
char buf2[24];
snprintf(buf2, sizeof(buf2), "EJT,");
ret = magicard_build_cmd_simple(buf, buf2);
ret = send_data(ctx->dev, ctx->endp_down,
buf, ret);
return ret;
}
static int magicard_query_printer(struct magicard_ctx *ctx)
{
int ret = 0;
@ -800,6 +844,10 @@ static void magicard_cmdline(void)
{
DEBUG("\t\t[ -s ] # Query status\n");
DEBUG("\t\t[ -q ] # Query information\n");
DEBUG("\t\t[ -I ] # Query printer sensors\n");
DEBUG("\t\t[ -E ] # Eject card\n");
DEBUG("\t\t[ -T ] # Print self-test card\n");
DEBUG("\t\t[ -R ] # Reset printer\n");
}
static int magicard_cmdline_arg(void *vctx, int argc, char **argv)
@ -810,7 +858,7 @@ static int magicard_cmdline_arg(void *vctx, int argc, char **argv)
if (!ctx)
return -1;
while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "sqI")) >= 0) {
while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "sqEIRT")) >= 0) {
switch(i) {
GETOPT_PROCESS_GLOBAL
case 's':
@ -819,9 +867,18 @@ static int magicard_cmdline_arg(void *vctx, int argc, char **argv)
case 'q':
j = magicard_query_printer(ctx);
break;
case 'E':
j = magicard_eject(ctx);
break;
case 'I':
j = magicard_query_sensors(ctx);
break;
case 'R':
j = magicard_reset(ctx);
break;
case 'T':
j = magicard_selftest_card(ctx);
break;
}
if (j) return j;
@ -832,7 +889,7 @@ static int magicard_cmdline_arg(void *vctx, int argc, char **argv)
struct dyesub_backend magicard_backend = {
.name = "Magicard family",
.version = "0.08",
.version = "0.09",
.uri_prefix = "magicard",
.cmdline_arg = magicard_cmdline_arg,
.cmdline_usage = magicard_cmdline,
@ -843,6 +900,8 @@ struct dyesub_backend magicard_backend = {
.main_loop = magicard_main_loop,
.devices = {
{ USB_VID_MAGICARD, USB_PID_MAGICARD_TANGO2E, P_MAGICARD, NULL},
{ USB_VID_MAGICARD, USB_PID_MAGICARD_ENDURO, P_MAGICARD, NULL},
{ USB_VID_MAGICARD, USB_PID_MAGICARD_ENDUROPLUS, P_MAGICARD, NULL},
{ USB_VID_MAGICARD, 0xFFFF, P_MAGICARD, NULL},
{ 0, 0, 0, NULL}
}
@ -992,4 +1051,35 @@ struct dyesub_backend magicard_backend = {
* How to set IP address (etc)
* How to set other parameters
"Simple Commands" (REQ,....,)
RST Reset printer
TST Generate self-test page
EJT Eject card
Other "Simple commands" referenced in Rio Pro/Enduro+ docs
DEALERSERVICE%s ON/OFF (enter/exit dealer service mode)
CAM Reset print head cam position
CHP%s UP/DOWN Feed card into smart encoder
CLN Cleaning cycle
DYE Re-init dye film
ENC Test encoding cycle
FEED%d 0/1,+ 0/1, load card into standby, >1 feed N cards.
FLIP Flip card in printer
FRN%s ON/OFF -- Film saving
HEAD%s UP/DOWN -- Raise or lower print head.
RAMP%d 0-100 Density ramp, 50 default
SET Saves settings into NVDATA
STN Re-init Holokote
SNS Soak cycle, test all sensors
SHW%s CAM, TACHO, FLIP, DYE, LID, FRONT, MID, READ, BUTTON1, BUTTON2,
SMART, TEMP, ON, OFF
LNG%d 0/1/2/3/4/5 == ENG/POR/FRE/GER/SPA/ITA
RUN%s CAM, FEED, DYE, MAIN, FLIPPER, FLIPROLL, FAN, PANEL, POUT, CAL, LCD,
OFF
FLM%s Y/M/C/K/O Align ribbon at corresponding panel
FCL Init dye calibration routine
FCL###### Set dye color to ###### (RGB hex)
*/

View file

@ -229,3 +229,9 @@
# Magicard Tango 2E
0x0c1f 0x1800 blacklist
# Magicard Enduro
0x0c1f 0x4800 blacklist
# Magicard Enduro+
0x0c1f 0x880a blacklist