Fix print completion flow for PT-P710BT and PT-P900W.
Align raster protocol bytes and print-end sequencing by printer family, add safer status polling/retry behavior, and document the changes with regression coverage to prevent protocol regressions. Made-with: Cursor
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void usage(const char *argv0)
|
||||
{
|
||||
@@ -141,12 +142,28 @@ static void verbose_print_post_print_status(libptouch_ctx *ctx, const char *labe
|
||||
if (!ctx)
|
||||
return;
|
||||
printf("=== verbose: post-print status (%s) ===\n", label);
|
||||
uint8_t st[LIBPTOUCH_STATUS_LENGTH];
|
||||
if (libptouch_get_status(ctx, st) == LIBPTOUCH_OK) {
|
||||
libptouch_status_fprint(stdout, st);
|
||||
} else {
|
||||
printf("status: unavailable (%s)\n", libptouch_strerror(ctx));
|
||||
/*
|
||||
* 印刷直後は phase change (status[18] != 0x00) が続くことがあるため、
|
||||
* 短時間ポーリングで最終状態まで追跡する。
|
||||
*/
|
||||
const int max_polls = 12; /* ~2.4s */
|
||||
const useconds_t poll_interval_us = 200000;
|
||||
for (int i = 0; i < max_polls; i++) {
|
||||
uint8_t st[LIBPTOUCH_STATUS_LENGTH];
|
||||
if (libptouch_get_status(ctx, st) != LIBPTOUCH_OK) {
|
||||
printf("status poll %d/%d: unavailable (%s)\n", i + 1,
|
||||
max_polls, libptouch_strerror(ctx));
|
||||
} else {
|
||||
printf("status poll %d/%d:\n", i + 1, max_polls);
|
||||
libptouch_status_fprint(stdout, st);
|
||||
if (st[18] == 0x00u) {
|
||||
printf("post-print polling settled: print end.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
usleep(poll_interval_us);
|
||||
}
|
||||
printf("post-print polling timeout: phase did not settle.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@@ -261,6 +278,10 @@ int main(int argc, char **argv)
|
||||
libptouch_destroy(sctx);
|
||||
return 1;
|
||||
}
|
||||
/* 印刷直後などは内部処理中で最初のステータス応答が不安定なことがあるため、
|
||||
* 少し待ってからステータスを取りに行く。 */
|
||||
usleep(300000); /* 300ms */
|
||||
|
||||
uint8_t st[LIBPTOUCH_STATUS_LENGTH];
|
||||
se = libptouch_get_status(sctx, st);
|
||||
if (se != LIBPTOUCH_OK) {
|
||||
|
||||
Reference in New Issue
Block a user