diag(inventory): held BAR:A/B open report + read-arms-laser test
This commit is contained in:
+47
-27
@@ -1,39 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
* scan.c - Phase 1 barcode diagnostic: keyboard / scan-key route.
|
* scan.c - Phase 1 barcode diagnostic: pin down the BAR: device.
|
||||||
*
|
*
|
||||||
* A working on-device demo triggers the laser from the keyboard scan key, so
|
* The scan key is keycode 368 (a Window Server key event an app catches to
|
||||||
* the system arms the scanner and delivers the decode via the scan-key path -
|
* trigger a scan); the working demo draws the decode itself, so it uses a
|
||||||
* not via an app-opened TTY:D or BAR: channel (both of which gave us nothing).
|
* scanner API - and the only barcode software path in this SDK is the bar*.ldd
|
||||||
* This build opens NOTHING and simply reads the keyboard, echoing every key
|
* decoder device "BAR:". Our BAR: open has been failing but its exact error
|
||||||
* code. If the decoded barcode is injected as keystrokes (a "wedge"), it will
|
* kept scrolling away. This build loads BAREAN, opens BAR:A (then BAR:B),
|
||||||
* appear here.
|
* reports each result and HOLDS the screen. If a channel opens, it issues
|
||||||
*
|
* p_iow(P_FREAD) - which should arm the laser - and dumps the decode.
|
||||||
* Test order:
|
|
||||||
* 1. Press normal keys ('1' = 49, '2' = 50, ...) to confirm the read works.
|
|
||||||
* 2. Press the scan key and scan a barcode - watch for the digits.
|
|
||||||
* Esc (27) quits.
|
|
||||||
*/
|
*/
|
||||||
#include <plib.h>
|
#include <plib.h>
|
||||||
|
#include "bcode.h"
|
||||||
|
|
||||||
GLDEF_C INT main(VOID)
|
GLDEF_C INT main(VOID)
|
||||||
{
|
{
|
||||||
INT c, cnt;
|
VOID *chan;
|
||||||
|
UBYTE buf[256];
|
||||||
|
INT ld, ra, rb, r, i, cnt;
|
||||||
|
|
||||||
p_printf("Keyboard/scan-key test.\n");
|
ld = p_loadldd(BCODE_LDD);
|
||||||
p_printf("Press keys; press the scan key and scan a barcode.\n");
|
ra = p_open(&chan, "BAR:A", (UINT)-1);
|
||||||
p_printf("Esc (27) quits.\n\n");
|
if (ra < 0)
|
||||||
|
rb = p_open(&chan, "BAR:B", (UINT)-1);
|
||||||
|
else
|
||||||
|
rb = 0;
|
||||||
|
|
||||||
cnt = 0;
|
p_printf("load %s: %d\n", BCODE_LDD, ld);
|
||||||
|
p_printf("open BAR:A: %d\n", ra);
|
||||||
|
if (ra < 0)
|
||||||
|
p_printf("open BAR:B: %d\n", rb);
|
||||||
|
|
||||||
|
if (ra < 0 && rb < 0) {
|
||||||
|
p_printf("\nNo BAR channel opened. Press a key.\n");
|
||||||
|
p_getch();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_printf("\nOpen. A read should arm the laser - scan now.\n\n");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = p_getch();
|
r = p_iow(chan, P_FREAD, buf); /* arms laser, blocks for a decode */
|
||||||
cnt++;
|
if (r < 0) {
|
||||||
p_printf(" %d", c);
|
p_printf("read status %d\n", r);
|
||||||
if (c == 13 || c == 10)
|
continue;
|
||||||
p_printf(" <EOL>\n");
|
}
|
||||||
if (c == 27)
|
cnt = buf[0];
|
||||||
break;
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
p_printf("\n%d keys read.\n", cnt);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user