feat(inventory): Phase 1 - scan and validate UPC barcodes #1
+18
-41
@@ -1,51 +1,32 @@
|
||||
/*
|
||||
* scan.c - Phase 1 barcode diagnostic: probe BAR: units A/B/C.
|
||||
* scan.c - Phase 1 barcode diagnostic: read the integral laser via WL2:A.
|
||||
*
|
||||
* 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.
|
||||
* demman reports the scanner's port as WL2:A (decoder "Symbol"), so the
|
||||
* integral MX laser is driven by the resident WL2 driver - not BAR:, not
|
||||
* TTY:D. WL2 is not documented in this SDK, so this opens WL2:A and dumps what
|
||||
* a read returns, to learn its format. It uses the barcode-style read
|
||||
* (p_iow(pcb, P_FREAD, buf), count typically in buf[0]) and prints the first
|
||||
* bytes both as decimal and as text.
|
||||
*
|
||||
* Press the scan key to trigger a scan while the read is waiting.
|
||||
*/
|
||||
#include <plib.h>
|
||||
#include "bcode.h"
|
||||
|
||||
#define NU 3
|
||||
|
||||
GLDEF_C INT main(VOID)
|
||||
{
|
||||
VOID *chan;
|
||||
UBYTE buf[256];
|
||||
INT ld, r, i, cnt, opened;
|
||||
UINT k;
|
||||
INT err, r, i, cnt;
|
||||
|
||||
static TEXT *names[NU] = { "BAR:A", "BAR:B", "BAR:C" };
|
||||
INT results[NU];
|
||||
|
||||
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");
|
||||
err = p_open(&chan, "WL2:A", (UINT)-1);
|
||||
p_printf("open WL2:A: %d\n", err);
|
||||
if (err < 0) {
|
||||
p_printf("Press a key to exit.\n");
|
||||
p_getch();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 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]);
|
||||
p_printf("Scan now (press the scan key). Dumping reads:\n\n");
|
||||
|
||||
for (;;) {
|
||||
r = p_iow(chan, P_FREAD, buf);
|
||||
@@ -54,15 +35,11 @@ GLDEF_C INT main(VOID)
|
||||
continue;
|
||||
}
|
||||
cnt = buf[0];
|
||||
if (cnt <= 0) {
|
||||
p_printf("(empty read)\n");
|
||||
continue;
|
||||
}
|
||||
p_printf("cnt=%d type=%d:", cnt, buf[1]);
|
||||
for (i = 1; i <= cnt && i < 256; i++)
|
||||
p_printf("r=%d b0=%d:", r, cnt);
|
||||
for (i = 0; i < 24 && i < 256; i++)
|
||||
p_printf(" %d", buf[i]);
|
||||
p_printf(" \"");
|
||||
for (i = 1; i <= cnt && i < 256; i++)
|
||||
for (i = 0; i < 24 && i < 256; i++)
|
||||
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
||||
p_printf("\"\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user