feat(inventory): Phase 1 - scan and validate UPC barcodes #1

Open
lyrathorpe wants to merge 54 commits from feat/inventory-phase1-scan into main
Showing only changes of commit 1544159afc - Show all commits
+29 -17
View File
@@ -1,32 +1,45 @@
/* /*
* scan.c - Phase 1 barcode diagnostic: read the integral laser via WL2:A. * scan.c - Phase 1 barcode diagnostic: read the integral laser via WL2:D.
* *
* demman reports the scanner's port as WL2:A (decoder "Symbol"), so the * The MX ROM shows the scanner port is WL2 with units A and D, decoder
* integral MX laser is driven by the resident WL2 driver - not BAR:, not * "Symbol2" (Workabout MX scanner). WL2:A returned -9 (in use); WL2:D (the
* TTY:D. WL2 is not documented in this SDK, so this opens WL2:A and dumps what * top-slot position, as TTY:D was) is untried. This opens WL2:D (falling back
* a read returns, to learn its format. It uses the barcode-style read * to WL2:A), and if a channel opens, reads it barcode-style
* (p_iow(pcb, P_FREAD, buf), count typically in buf[0]) and prints the first * (p_iow(pcb, P_FREAD, buf)) and dumps the bytes. Press the scan key to fire.
* bytes both as decimal and as text.
*
* Press the scan key to trigger a scan while the read is waiting.
*/ */
#include <plib.h> #include <plib.h>
#define NU 2
GLDEF_C INT main(VOID) GLDEF_C INT main(VOID)
{ {
VOID *chan; VOID *chan;
UBYTE buf[256]; UBYTE buf[256];
INT err, r, i, cnt; INT r, i, opened;
UINT k;
err = p_open(&chan, "WL2:A", (UINT)-1); static TEXT *names[NU] = { "WL2:D", "WL2:A" };
p_printf("open WL2:A: %d\n", err); INT results[NU];
if (err < 0) {
p_printf("Press a key to exit.\n"); 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;
}
for (k = 0; k < NU; k++)
p_printf("open %s: %d\n", names[k], results[k]);
if (opened < 0) {
p_printf("\nNothing opened. Press a key.\n");
p_getch(); p_getch();
return 1; return 1;
} }
p_printf("Scan now (press the scan key). Dumping reads:\n\n"); p_open(&chan, names[opened], (UINT)-1); /* reopen the winner */
p_printf("\nOpened %s. Scan (press scan key). Dumping:\n\n", names[opened]);
for (;;) { for (;;) {
r = p_iow(chan, P_FREAD, buf); r = p_iow(chan, P_FREAD, buf);
@@ -34,8 +47,7 @@ GLDEF_C INT main(VOID)
p_printf("read status %d\n", r); p_printf("read status %d\n", r);
continue; continue;
} }
cnt = buf[0]; p_printf("r=%d b0=%d:", r, buf[0]);
p_printf("r=%d b0=%d:", r, cnt);
for (i = 0; i < 24 && i < 256; i++) for (i = 0; i < 24 && i < 256; i++)
p_printf(" %d", buf[i]); p_printf(" %d", buf[i]);
p_printf(" \""); p_printf(" \"");