diag(inventory): probe BAR: device-name/mode candidates (BAR:D etc.)
This commit is contained in:
+31
-18
@@ -1,39 +1,52 @@
|
||||
/*
|
||||
* scan.c - Phase 1 barcode diagnostic for the Workabout MX integral laser.
|
||||
*
|
||||
* Loads the EAN/UPC decoder LDD (BAREAN.LDD), opens the decoder device (BAR:),
|
||||
* and dumps every byte of each read so the decoded format (length, any prefix
|
||||
* or type byte, terminator) can be confirmed.
|
||||
* The EAN/UPC decoder LDD (BAREAN.LDD) is loaded, then the decoder device is
|
||||
* opened. The exact device-name form and open mode are not documented in the
|
||||
* available manuals (they live in the I/O Devices Reference), so this build
|
||||
* tries several candidates in one run and reports which one opens - most
|
||||
* likely "BAR:D" (the decoder over port D, like TTY:D), since bare "BAR:"
|
||||
* returns E_FILE_NAME (-38). Once open, it dumps every byte of each read so
|
||||
* the decoded UPC format can be seen.
|
||||
*
|
||||
* The load and open results are printed and then a key is waited for BEFORE
|
||||
* anything else, so the numbers stay on screen even if the open fails (a failed
|
||||
* open would otherwise return instantly and the System screen would wipe the
|
||||
* message). Blocking I/O throughout; exit via the System screen.
|
||||
* Blocking I/O; exit via the System screen.
|
||||
*/
|
||||
#include <plib.h>
|
||||
#include "bcode.h"
|
||||
|
||||
#define NCAND 5
|
||||
|
||||
GLDEF_C INT main(VOID)
|
||||
{
|
||||
VOID *chan;
|
||||
UBYTE buf[64];
|
||||
INT loadErr, openErr, n, i;
|
||||
INT loadErr, r, n, i, opened;
|
||||
UINT k;
|
||||
|
||||
static TEXT *names[NCAND] = { "BAR:D", "BAR:D", "BAR:", "BAR:E", "BAR:A" };
|
||||
static UINT modes[NCAND] = { (UINT)-1, 0, 0, (UINT)-1, (UINT)-1 };
|
||||
|
||||
loadErr = bcodeLoad();
|
||||
openErr = bcodeOpen(&chan);
|
||||
p_printf("load %s.LDD: %d\n\n", BCODE_LDD, loadErr);
|
||||
|
||||
/* Show both results and hold the screen until a key is pressed. */
|
||||
p_printf("load %s.LDD : %d\n", BCODE_LDD, loadErr);
|
||||
p_printf("open %s : %d\n", BCODE_DEV, openErr);
|
||||
p_printf("\n(0 = ok; for load, an 'already loaded' error is also ok)\n");
|
||||
p_printf("Press a key to continue...\n");
|
||||
opened = 0;
|
||||
for (k = 0; k < NCAND; k++) {
|
||||
r = p_open(&chan, names[k], modes[k]);
|
||||
p_printf("open \"%s\" mode %u: %d\n", names[k], modes[k], r);
|
||||
if (r >= 0) {
|
||||
opened = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (opened == 0) {
|
||||
p_printf("\nNothing opened. Press a key to exit.\n");
|
||||
p_getch();
|
||||
|
||||
if (openErr < 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
p_printf("\n%s open. Scan a barcode. Exit via the System screen.\n\n",
|
||||
BCODE_DEV);
|
||||
p_printf("\nOpened \"%s\". Scan a barcode. System screen to exit.\n\n",
|
||||
names[k]);
|
||||
|
||||
for (;;) {
|
||||
n = p_read(chan, buf, sizeof(buf));
|
||||
|
||||
Reference in New Issue
Block a user