diag(inventory): correct BAR: read to p_iow(P_FREAD,buf); probe slot letters; dump [count][type][data]

This commit is contained in:
2026-07-06 18:33:34 +01:00
parent 538705a807
commit 4d8917bb02
+27 -21
View File
@@ -1,38 +1,40 @@
/* /*
* scan.c - Phase 1 barcode diagnostic for the Workabout MX integral laser. * 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 * Per the I/O Devices Reference (HC Bar Code Reader chapter): load a decoder
* opened. The exact device-name form and open mode are not documented in the * LDD (BAREAN.LDD for UPC/EAN), open the device "BAR:<slot>" (top slot is "A"
* available manuals (they live in the I/O Devices Reference), so this build * on the HC; the Workabout may map the top slot differently), and read with
* tries several candidates in one run and reports which one opens - most * p_iow(pcb, P_FREAD, buf), buf >= 256 bytes. The result is a leading byte
* likely "BAR:D" (the decoder over port D, like TTY:D), since bare "BAR:" * count in buf[0] (0 = unsuccessful read), buf[1] = a barcode-type character,
* returns E_FILE_NAME (-38). Once open, it dumps every byte of each read so * and buf[2..] = the decoded digits.
* the decoded UPC format can be seen. *
* 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. * Blocking I/O; exit via the System screen.
*/ */
#include <plib.h> #include <plib.h>
#include "bcode.h" #include "bcode.h"
#define NCAND 5 #define NCAND 4
GLDEF_C INT main(VOID) GLDEF_C INT main(VOID)
{ {
VOID *chan; VOID *chan;
UBYTE buf[64]; UBYTE buf[256];
INT loadErr, r, n, i, opened; INT loadErr, r, i, cnt, opened;
UINT k; UINT k;
static TEXT *names[NCAND] = { "BAR:D", "BAR:D", "BAR:", "BAR:E", "BAR:A" }; static TEXT *names[NCAND] = { "BAR:A", "BAR:D", "BAR:B", "BAR:E" };
static UINT modes[NCAND] = { (UINT)-1, 0, 0, (UINT)-1, (UINT)-1 };
loadErr = bcodeLoad(); loadErr = bcodeLoad();
p_printf("load %s.LDD: %d\n\n", BCODE_LDD, loadErr); p_printf("load %s.LDD: %d\n\n", BCODE_LDD, loadErr);
opened = 0; opened = 0;
for (k = 0; k < NCAND; k++) { for (k = 0; k < NCAND; k++) {
r = p_open(&chan, names[k], modes[k]); r = p_open(&chan, names[k], (UINT)-1);
p_printf("open \"%s\" mode %u: %d\n", names[k], modes[k], r); p_printf("open \"%s\": %d\n", names[k], r);
if (r >= 0) { if (r >= 0) {
opened = 1; opened = 1;
break; break;
@@ -49,18 +51,22 @@ GLDEF_C INT main(VOID)
names[k]); names[k]);
for (;;) { for (;;) {
n = p_read(chan, buf, sizeof(buf)); /* Barcode read: buffer only, count returned in buf[0]. Blocking. */
if (n < 0) { r = p_iow(chan, P_FREAD, buf);
p_printf("read err %d\n", n); if (r < 0) {
p_printf("read status %d\n", r);
continue; continue;
} }
if (n == 0) cnt = buf[0];
if (cnt <= 0) {
p_printf("(empty read)\n");
continue; 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(" %d", buf[i]);
p_printf(" \""); p_printf(" \"");
for (i = 0; i < n; i++) for (i = 1; i <= cnt && i < 256; i++)
p_putch(buf[i] >= ' ' ? buf[i] : '.'); p_putch(buf[i] >= ' ' ? buf[i] : '.');
p_printf("\"\n"); p_printf("\"\n");
} }