2026-07-06 17:41:44 +01:00
|
|
|
/*
|
2026-07-06 21:23:19 +01:00
|
|
|
* scan.c - Phase 1 barcode diagnostic: read the integral laser via WL2:D.
|
2026-07-06 17:41:44 +01:00
|
|
|
*
|
2026-07-06 21:23:19 +01:00
|
|
|
* The MX ROM shows the scanner port is WL2 with units A and D, decoder
|
|
|
|
|
* "Symbol2" (Workabout MX scanner). WL2:A returned -9 (in use); WL2:D (the
|
|
|
|
|
* top-slot position, as TTY:D was) is untried. This opens WL2:D (falling back
|
|
|
|
|
* to WL2:A), and if a channel opens, reads it barcode-style
|
|
|
|
|
* (p_iow(pcb, P_FREAD, buf)) and dumps the bytes. Press the scan key to fire.
|
2026-07-06 17:41:44 +01:00
|
|
|
*/
|
|
|
|
|
#include <plib.h>
|
2026-07-06 18:28:22 +01:00
|
|
|
|
2026-07-06 21:23:19 +01:00
|
|
|
#define NU 2
|
|
|
|
|
|
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 21:23:19 +01:00
|
|
|
INT r, i, opened;
|
|
|
|
|
UINT k;
|
2026-07-06 18:28:22 +01:00
|
|
|
|
2026-07-06 21:23:19 +01:00
|
|
|
static TEXT *names[NU] = { "WL2:D", "WL2:A" };
|
|
|
|
|
INT results[NU];
|
|
|
|
|
|
|
|
|
|
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");
|
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 21:23:19 +01:00
|
|
|
p_open(&chan, names[opened], (UINT)-1); /* reopen the winner */
|
|
|
|
|
p_printf("\nOpened %s. Scan (press scan key). Dumping:\n\n", names[opened]);
|
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 21:23:19 +01:00
|
|
|
p_printf("r=%d b0=%d:", r, buf[0]);
|
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_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
|
|
|
}
|