From b79b1fa1751db6a55a9f298be4453e93a3cfb28e Mon Sep 17 00:00:00 2001 From: lyrathorpe Date: Mon, 6 Jul 2026 20:21:03 +0100 Subject: [PATCH] diag(inventory): software-trigger scan via Esc-y1J/Esc-y1K over TTY:D --- code/inventory/scan.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/code/inventory/scan.c b/code/inventory/scan.c index ee32c57..d80683d 100644 --- a/code/inventory/scan.c +++ b/code/inventory/scan.c @@ -1,17 +1,15 @@ /* - * scan.c - Phase 1 barcode diagnostic: minimal TTY:D barcode-driver read. + * scan.c - Phase 1 barcode diagnostic: software-triggered scan over TTY:D. * - * TTY:D is the top-slot bar code interface (I/O Devices Reference, HC - * Intelligent Bar Code Reader chapter). Opening it powers the interface and - * the scanner; by default the scanner is enabled and in auto-read mode, and it - * transmits each decoded label as ASCII text terminated by a carriage return. + * TTY:D is the top-slot bar code interface. It did not auto-transmit on a scan, + * so this build uses the documented escape-sequence trigger (I/O Devices + * Reference, HC Intelligent Bar Code Reader chapter): + * -y1J enable single-read mode + * -y1K "read next scan" - arms the reader for one label + * After each decoded label (terminated by CR) it re-arms with another K. + * Every received byte is streamed as a decimal value. * - * Earlier attempts failed for self-inflicted reasons: a P_FSET forced 9600/8/1 - * (wrong if the scanner uses another rate, which garbles the data) and a - * 64-byte read blocked forever with no terminator set. This build does NEITHER: - * it opens TTY:D, changes nothing, and reads ONE byte at a time, streaming each - * value. Scan during the brief active window after launch (re-trigger with the - * scan key if needed). + * =0x1b, '-'=0x2d, 'y'=0x79. Escape sequences carry no embedded spaces. */ #include @@ -21,6 +19,9 @@ GLDEF_C INT main(VOID) UBYTE b; INT err, n, c; + static TEXT cmdJ[5] = { 0x1b, '-', 'y', '1', 'J' }; /* single-read mode on */ + static TEXT cmdK[5] = { 0x1b, '-', 'y', '1', 'K' }; /* trigger one scan */ + err = p_open(&chan, "TTY:D", (UINT)-1); p_printf("open TTY:D: %d\n", err); if (err < 0) { @@ -29,10 +30,15 @@ GLDEF_C INT main(VOID) return 1; } - p_printf("Scan now. Streaming bytes:\n\n"); + err = p_write(chan, cmdJ, 5); + p_printf("single-read mode (Esc-y1J): %d\n", err); + err = p_write(chan, cmdK, 5); + p_printf("trigger (Esc-y1K): %d\n", err); + + p_printf("\nPoint at a barcode. Streaming bytes:\n\n"); for (;;) { - n = p_read(chan, &b, 1); /* one byte; no reconfiguration at all */ + n = p_read(chan, &b, 1); if (n < 0) { p_printf("", n); continue; @@ -41,7 +47,9 @@ GLDEF_C INT main(VOID) continue; c = b; p_printf(" %d", c); - if (c == 13 || c == 10) + if (c == 13 || c == 10) { p_printf(" \n"); + p_write(chan, cmdK, 5); /* re-arm for the next scan */ + } } }