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
|
* demman reports the scanner's port as WL2:A (decoder "Symbol"), so the
|
||||||
* appears when its scanner runs), so BAR: is the path - we've just been
|
* integral MX laser is driven by the resident WL2 driver - not BAR:, not
|
||||||
* opening the wrong unit. BAR:A/BAR:B gave -41 (no interface in slot) and
|
* TTY:D. WL2 is not documented in this SDK, so this opens WL2:A and dumps what
|
||||||
* BAR:D/BAR:E gave -38 (invalid name); BAR:C (the internal position, as MCR
|
* a read returns, to learn its format. It uses the barcode-style read
|
||||||
* uses C for its non-A/B slot) is untried. This tries A, B, C, holds the
|
* (p_iow(pcb, P_FREAD, buf), count typically in buf[0]) and prints the first
|
||||||
* results on screen, and if one opens, issues p_iow(P_FREAD) (which should arm
|
* bytes both as decimal and as text.
|
||||||
* the laser) and dumps the [count][type][data] decode.
|
*
|
||||||
|
* Press the scan key to trigger a scan while the read is waiting.
|
||||||
*/
|
*/
|
||||||
#include <plib.h>
|
#include <plib.h>
|
||||||
#include "bcode.h"
|
|
||||||
|
|
||||||
#define NU 3
|
|
||||||
|
|
||||||
GLDEF_C INT main(VOID)
|
GLDEF_C INT main(VOID)
|
||||||
{
|
{
|
||||||
VOID *chan;
|
VOID *chan;
|
||||||
UBYTE buf[256];
|
UBYTE buf[256];
|
||||||
INT ld, r, i, cnt, opened;
|
INT err, r, i, cnt;
|
||||||
UINT k;
|
|
||||||
|
|
||||||
static TEXT *names[NU] = { "BAR:A", "BAR:B", "BAR:C" };
|
err = p_open(&chan, "WL2:A", (UINT)-1);
|
||||||
INT results[NU];
|
p_printf("open WL2:A: %d\n", err);
|
||||||
|
if (err < 0) {
|
||||||
ld = p_loadldd(BCODE_LDD);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
p_getch();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reopen the winner (others were not kept) */
|
p_printf("Scan now (press the scan key). Dumping reads:\n\n");
|
||||||
p_open(&chan, names[opened], (UINT)-1);
|
|
||||||
p_printf("\nOpened %s. A read arms the laser - scan now.\n\n", names[opened]);
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
r = p_iow(chan, P_FREAD, buf);
|
r = p_iow(chan, P_FREAD, buf);
|
||||||
@@ -54,15 +35,11 @@ GLDEF_C INT main(VOID)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cnt = buf[0];
|
cnt = buf[0];
|
||||||
if (cnt <= 0) {
|
p_printf("r=%d b0=%d:", r, cnt);
|
||||||
p_printf("(empty read)\n");
|
for (i = 0; i < 24 && i < 256; i++)
|
||||||
continue;
|
|
||||||
}
|
|
||||||
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 = 1; i <= cnt && i < 256; i++)
|
for (i = 0; i < 24 && i < 256; i++)
|
||||||
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
||||||
p_printf("\"\n");
|
p_printf("\"\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user