From 4d8917bb02469145ab53ef779fb690810c960a6a Mon Sep 17 00:00:00 2001 From: lyrathorpe Date: Mon, 6 Jul 2026 18:33:34 +0100 Subject: [PATCH] diag(inventory): correct BAR: read to p_iow(P_FREAD,buf); probe slot letters; dump [count][type][data] --- code/inventory/scan.c | 48 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/code/inventory/scan.c b/code/inventory/scan.c index 9827c42..c94d91c 100644 --- a/code/inventory/scan.c +++ b/code/inventory/scan.c @@ -1,38 +1,40 @@ /* * scan.c - Phase 1 barcode diagnostic for the Workabout MX integral laser. * - * The EAN/UPC decoder LDD (BAREAN.LDD) is loaded, then the decoder device is - * opened. The exact device-name form and open mode are not documented in the - * available manuals (they live in the I/O Devices Reference), so this build - * tries several candidates in one run and reports which one opens - most - * likely "BAR:D" (the decoder over port D, like TTY:D), since bare "BAR:" - * returns E_FILE_NAME (-38). Once open, it dumps every byte of each read so - * the decoded UPC format can be seen. + * Per the I/O Devices Reference (HC Bar Code Reader chapter): load a decoder + * LDD (BAREAN.LDD for UPC/EAN), open the device "BAR:" (top slot is "A" + * on the HC; the Workabout may map the top slot differently), and read with + * p_iow(pcb, P_FREAD, buf), buf >= 256 bytes. The result is a leading byte + * count in buf[0] (0 = unsuccessful read), buf[1] = a barcode-type character, + * and buf[2..] = the decoded digits. + * + * This build probes the likely slot letters (bare "BAR:" gave E_FILE_NAME/-38 + * because it lacks the slot letter), reports which opens, then dumps the raw + * [count][type][data] of each scan so the exact UPC format is confirmed. * * Blocking I/O; exit via the System screen. */ #include #include "bcode.h" -#define NCAND 5 +#define NCAND 4 GLDEF_C INT main(VOID) { VOID *chan; - UBYTE buf[64]; - INT loadErr, r, n, i, opened; + UBYTE buf[256]; + INT loadErr, r, i, cnt, opened; UINT k; - static TEXT *names[NCAND] = { "BAR:D", "BAR:D", "BAR:", "BAR:E", "BAR:A" }; - static UINT modes[NCAND] = { (UINT)-1, 0, 0, (UINT)-1, (UINT)-1 }; + static TEXT *names[NCAND] = { "BAR:A", "BAR:D", "BAR:B", "BAR:E" }; loadErr = bcodeLoad(); p_printf("load %s.LDD: %d\n\n", BCODE_LDD, loadErr); opened = 0; for (k = 0; k < NCAND; k++) { - r = p_open(&chan, names[k], modes[k]); - p_printf("open \"%s\" mode %u: %d\n", names[k], modes[k], r); + r = p_open(&chan, names[k], (UINT)-1); + p_printf("open \"%s\": %d\n", names[k], r); if (r >= 0) { opened = 1; break; @@ -49,18 +51,22 @@ GLDEF_C INT main(VOID) names[k]); for (;;) { - n = p_read(chan, buf, sizeof(buf)); - if (n < 0) { - p_printf("read err %d\n", n); + /* Barcode read: buffer only, count returned in buf[0]. Blocking. */ + r = p_iow(chan, P_FREAD, buf); + if (r < 0) { + p_printf("read status %d\n", r); continue; } - if (n == 0) + cnt = buf[0]; + if (cnt <= 0) { + p_printf("(empty read)\n"); continue; - p_printf("n=%d:", n); - for (i = 0; i < n; i++) + } + p_printf("cnt=%d type=%d:", cnt, buf[1]); + for (i = 1; i <= cnt && i < 256; i++) p_printf(" %d", buf[i]); p_printf(" \""); - for (i = 0; i < n; i++) + for (i = 1; i <= cnt && i < 256; i++) p_putch(buf[i] >= ' ' ? buf[i] : '.'); p_printf("\"\n"); }