From 0ec706d658ee1afd84468a7040650f5a7e7a25bc Mon Sep 17 00:00:00 2001 From: lyrathorpe Date: Mon, 6 Jul 2026 20:39:17 +0100 Subject: [PATCH] diag(inventory): probe BAR:A/B/C units (demman uses existing bar device) --- code/inventory/scan.c | 80 +++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/code/inventory/scan.c b/code/inventory/scan.c index d80683d..a1db2d4 100644 --- a/code/inventory/scan.c +++ b/code/inventory/scan.c @@ -1,55 +1,69 @@ /* - * scan.c - Phase 1 barcode diagnostic: software-triggered scan over TTY:D. + * scan.c - Phase 1 barcode diagnostic: probe BAR: units A/B/C. * - * 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. - * - * =0x1b, '-'=0x2d, 'y'=0x79. Escape sequences carry no embedded spaces. + * LLDEV shows demman uses the already-loaded "bar" device (no new driver + * appears when its scanner runs), so BAR: is the path - we've just been + * opening the wrong unit. BAR:A/BAR:B gave -41 (no interface in slot) and + * BAR:D/BAR:E gave -38 (invalid name); BAR:C (the internal position, as MCR + * uses C for its non-A/B slot) is untried. This tries A, B, C, holds the + * results on screen, and if one opens, issues p_iow(P_FREAD) (which should arm + * the laser) and dumps the [count][type][data] decode. */ #include +#include "bcode.h" + +#define NU 3 GLDEF_C INT main(VOID) { VOID *chan; - UBYTE b; - INT err, n, c; + UBYTE buf[256]; + INT ld, r, i, cnt, opened; + UINT k; - static TEXT cmdJ[5] = { 0x1b, '-', 'y', '1', 'J' }; /* single-read mode on */ - static TEXT cmdK[5] = { 0x1b, '-', 'y', '1', 'K' }; /* trigger one scan */ + static TEXT *names[NU] = { "BAR:A", "BAR:B", "BAR:C" }; + INT results[NU]; - err = p_open(&chan, "TTY:D", (UINT)-1); - p_printf("open TTY:D: %d\n", err); - if (err < 0) { - p_printf("Press a key to exit.\n"); + ld = p_loadldd(BCODE_LDD); + opened = -1; + for (k = 0; k < NU; k++) { + r = p_open(&chan, names[k], (UINT)-1); + results[k] = r; + if (r >= 0 && opened < 0) + opened = k; + } + + p_printf("load %s: %d\n", BCODE_LDD, ld); + for (k = 0; k < NU; k++) + p_printf("open %s: %d\n", names[k], results[k]); + + if (opened < 0) { + p_printf("\nNo BAR unit opened. Press a key.\n"); p_getch(); return 1; } - 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"); + /* reopen the winner (others were not kept) */ + p_open(&chan, names[opened], (UINT)-1); + p_printf("\nOpened %s. A read arms the laser - scan now.\n\n", names[opened]); for (;;) { - n = p_read(chan, &b, 1); - if (n < 0) { - p_printf("", n); + 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; - c = b; - p_printf(" %d", c); - if (c == 13 || c == 10) { - p_printf(" \n"); - p_write(chan, cmdK, 5); /* re-arm for the next scan */ } + 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 = 1; i <= cnt && i < 256; i++) + p_putch(buf[i] >= ' ' ? buf[i] : '.'); + p_printf("\"\n"); } }