48 lines
1.5 KiB
C
48 lines
1.5 KiB
C
/*
|
|
* scan.c - Phase 1 barcode diagnostic: minimal TTY:D barcode-driver read.
|
|
*
|
|
* TTY:D is the top-slot bar code interface (I/O Devices Reference, HC
|
|
* Intelligent Bar Code Reader chapter). Opening it powers the interface and
|
|
* the scanner; by default the scanner is enabled and in auto-read mode, and it
|
|
* transmits each decoded label as ASCII text terminated by a carriage return.
|
|
*
|
|
* Earlier attempts failed for self-inflicted reasons: a P_FSET forced 9600/8/1
|
|
* (wrong if the scanner uses another rate, which garbles the data) and a
|
|
* 64-byte read blocked forever with no terminator set. This build does NEITHER:
|
|
* it opens TTY:D, changes nothing, and reads ONE byte at a time, streaming each
|
|
* value. Scan during the brief active window after launch (re-trigger with the
|
|
* scan key if needed).
|
|
*/
|
|
#include <plib.h>
|
|
|
|
GLDEF_C INT main(VOID)
|
|
{
|
|
VOID *chan;
|
|
UBYTE b;
|
|
INT err, n, c;
|
|
|
|
err = p_open(&chan, "TTY:D", (UINT)-1);
|
|
p_printf("open TTY:D: %d\n", err);
|
|
if (err < 0) {
|
|
p_printf("Press a key to exit.\n");
|
|
p_getch();
|
|
return 1;
|
|
}
|
|
|
|
p_printf("Scan now. Streaming bytes:\n\n");
|
|
|
|
for (;;) {
|
|
n = p_read(chan, &b, 1); /* one byte; no reconfiguration at all */
|
|
if (n < 0) {
|
|
p_printf("<e%d>", n);
|
|
continue;
|
|
}
|
|
if (n == 0)
|
|
continue;
|
|
c = b;
|
|
p_printf(" %d", c);
|
|
if (c == 13 || c == 10)
|
|
p_printf(" <EOL>\n");
|
|
}
|
|
}
|