2026-07-06 17:41:44 +01:00
|
|
|
/*
|
2026-07-06 20:54:14 +01:00
|
|
|
* scan.c - Phase 1 barcode diagnostic: read the integral laser via WL2:A.
|
2026-07-06 17:41:44 +01:00
|
|
|
*
|
2026-07-06 20:54:14 +01:00
|
|
|
* 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.
|
2026-07-06 17:41:44 +01:00
|
|
|
*/
|
|
|
|
|
#include <plib.h>
|
2026-07-06 18:28:22 +01:00
|
|
|
|
2026-07-06 17:41:44 +01:00
|
|
|
GLDEF_C INT main(VOID)
|
|
|
|
|
{
|
2026-07-06 19:04:43 +01:00
|
|
|
VOID *chan;
|
2026-07-06 20:39:17 +01:00
|
|
|
UBYTE buf[256];
|
2026-07-06 20:54:14 +01:00
|
|
|
INT err, r, i, cnt;
|
2026-07-06 18:28:22 +01:00
|
|
|
|
2026-07-06 20:54:14 +01:00
|
|
|
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");
|
2026-07-06 19:04:43 +01:00
|
|
|
p_getch();
|
|
|
|
|
return 1;
|
2026-07-06 17:41:44 +01:00
|
|
|
}
|
2026-07-06 18:51:31 +01:00
|
|
|
|
2026-07-06 20:54:14 +01:00
|
|
|
p_printf("Scan now (press the scan key). Dumping reads:\n\n");
|
2026-07-06 20:14:54 +01:00
|
|
|
|
2026-07-06 19:04:43 +01:00
|
|
|
for (;;) {
|
2026-07-06 20:39:17 +01:00
|
|
|
r = p_iow(chan, P_FREAD, buf);
|
|
|
|
|
if (r < 0) {
|
|
|
|
|
p_printf("read status %d\n", r);
|
2026-07-06 19:04:43 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
2026-07-06 20:39:17 +01:00
|
|
|
cnt = buf[0];
|
2026-07-06 20:54:14 +01:00
|
|
|
p_printf("r=%d b0=%d:", r, cnt);
|
|
|
|
|
for (i = 0; i < 24 && i < 256; i++)
|
2026-07-06 20:39:17 +01:00
|
|
|
p_printf(" %d", buf[i]);
|
|
|
|
|
p_printf(" \"");
|
2026-07-06 20:54:14 +01:00
|
|
|
for (i = 0; i < 24 && i < 256; i++)
|
2026-07-06 20:39:17 +01:00
|
|
|
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
|
|
|
|
p_printf("\"\n");
|
2026-07-06 19:04:43 +01:00
|
|
|
}
|
2026-07-06 17:41:44 +01:00
|
|
|
}
|