70 lines
2.0 KiB
C
70 lines
2.0 KiB
C
/*
|
|
* scan.c - Phase 1 barcode diagnostic: probe BAR: units A/B/C.
|
|
*
|
|
* 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.
|
|
*/
|
|
#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;
|
|
|
|
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");
|
|
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]);
|
|
|
|
for (;;) {
|
|
r = p_iow(chan, P_FREAD, buf);
|
|
if (r < 0) {
|
|
p_printf("read status %d\n", r);
|
|
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(" %d", buf[i]);
|
|
p_printf(" \"");
|
|
for (i = 1; i <= cnt && i < 256; i++)
|
|
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
|
p_printf("\"\n");
|
|
}
|
|
}
|