From 6dfa868fa2417630f4bece1d1914bc6dfdc69b2a Mon Sep 17 00:00:00 2001 From: lyrathorpe Date: Mon, 6 Jul 2026 18:28:22 +0100 Subject: [PATCH] diag(inventory): probe BAR: device-name/mode candidates (BAR:D etc.) --- code/inventory/scan.c | 49 +++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/code/inventory/scan.c b/code/inventory/scan.c index cd814cd..9827c42 100644 --- a/code/inventory/scan.c +++ b/code/inventory/scan.c @@ -1,39 +1,52 @@ /* * scan.c - Phase 1 barcode diagnostic for the Workabout MX integral laser. * - * Loads the EAN/UPC decoder LDD (BAREAN.LDD), opens the decoder device (BAR:), - * and dumps every byte of each read so the decoded format (length, any prefix - * or type byte, terminator) can be confirmed. + * 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. * - * The load and open results are printed and then a key is waited for BEFORE - * anything else, so the numbers stay on screen even if the open fails (a failed - * open would otherwise return instantly and the System screen would wipe the - * message). Blocking I/O throughout; exit via the System screen. + * Blocking I/O; exit via the System screen. */ #include #include "bcode.h" +#define NCAND 5 + GLDEF_C INT main(VOID) { VOID *chan; UBYTE buf[64]; - INT loadErr, openErr, n, i; + INT loadErr, r, n, i, 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 }; loadErr = bcodeLoad(); - openErr = bcodeOpen(&chan); + p_printf("load %s.LDD: %d\n\n", BCODE_LDD, loadErr); - /* Show both results and hold the screen until a key is pressed. */ - p_printf("load %s.LDD : %d\n", BCODE_LDD, loadErr); - p_printf("open %s : %d\n", BCODE_DEV, openErr); - p_printf("\n(0 = ok; for load, an 'already loaded' error is also ok)\n"); - p_printf("Press a key to continue...\n"); - p_getch(); + 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); + if (r >= 0) { + opened = 1; + break; + } + } - if (openErr < 0) + if (opened == 0) { + p_printf("\nNothing opened. Press a key to exit.\n"); + p_getch(); return 1; + } - p_printf("\n%s open. Scan a barcode. Exit via the System screen.\n\n", - BCODE_DEV); + p_printf("\nOpened \"%s\". Scan a barcode. System screen to exit.\n\n", + names[k]); for (;;) { n = p_read(chan, buf, sizeof(buf));