Files
sibo-playground/code/inventory/scan.c
T

47 lines
1.4 KiB
C

/*
* scan.c - Phase 1 barcode diagnostic: read the integral laser via WL2:A.
*
* 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>
GLDEF_C INT main(VOID)
{
VOID *chan;
UBYTE buf[256];
INT err, r, i, cnt;
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;
}
p_printf("Scan now (press the scan key). Dumping reads:\n\n");
for (;;) {
r = p_iow(chan, P_FREAD, buf);
if (r < 0) {
p_printf("read status %d\n", r);
continue;
}
cnt = buf[0];
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 = 0; i < 24 && i < 256; i++)
p_putch(buf[i] >= ' ' ? buf[i] : '.');
p_printf("\"\n");
}
}