feat(inventory): Phase 1 - scan and validate UPC barcodes #1
+31
-18
@@ -1,39 +1,52 @@
|
|||||||
/*
|
/*
|
||||||
* scan.c - Phase 1 barcode diagnostic for the Workabout MX integral laser.
|
* 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:),
|
* The EAN/UPC decoder LDD (BAREAN.LDD) is loaded, then the decoder device is
|
||||||
* and dumps every byte of each read so the decoded format (length, any prefix
|
* opened. The exact device-name form and open mode are not documented in the
|
||||||
* or type byte, terminator) can be confirmed.
|
* 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
|
* Blocking I/O; exit via the System screen.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
#include <plib.h>
|
#include <plib.h>
|
||||||
#include "bcode.h"
|
#include "bcode.h"
|
||||||
|
|
||||||
|
#define NCAND 5
|
||||||
|
|
||||||
GLDEF_C INT main(VOID)
|
GLDEF_C INT main(VOID)
|
||||||
{
|
{
|
||||||
VOID *chan;
|
VOID *chan;
|
||||||
UBYTE buf[64];
|
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();
|
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. */
|
opened = 0;
|
||||||
p_printf("load %s.LDD : %d\n", BCODE_LDD, loadErr);
|
for (k = 0; k < NCAND; k++) {
|
||||||
p_printf("open %s : %d\n", BCODE_DEV, openErr);
|
r = p_open(&chan, names[k], modes[k]);
|
||||||
p_printf("\n(0 = ok; for load, an 'already loaded' error is also ok)\n");
|
p_printf("open \"%s\" mode %u: %d\n", names[k], modes[k], r);
|
||||||
p_printf("Press a key to continue...\n");
|
if (r >= 0) {
|
||||||
p_getch();
|
opened = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (openErr < 0)
|
if (opened == 0) {
|
||||||
|
p_printf("\nNothing opened. Press a key to exit.\n");
|
||||||
|
p_getch();
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
p_printf("\n%s open. Scan a barcode. Exit via the System screen.\n\n",
|
p_printf("\nOpened \"%s\". Scan a barcode. System screen to exit.\n\n",
|
||||||
BCODE_DEV);
|
names[k]);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
n = p_read(chan, buf, sizeof(buf));
|
n = p_read(chan, buf, sizeof(buf));
|
||||||
|
|||||||
Reference in New Issue
Block a user