feat(inventory): Phase 1 - scan and validate UPC barcodes #1

Open
lyrathorpe wants to merge 54 commits from feat/inventory-phase1-scan into main
Showing only changes of commit ca7ed3e178 - Show all commits
+21 -15
View File
@@ -1,13 +1,14 @@
/* /*
* 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:) * Loads the EAN/UPC decoder LDD (BAREAN.LDD), opens the decoder device (BAR:),
* and dumps every byte of each read: the decimal value of each byte plus a * and dumps every byte of each read so the decoded format (length, any prefix
* printable rendering. This shows exactly what the decoder delivers for a UPC * or type byte, terminator) can be confirmed.
* (length, any prefix/type byte, terminator) so the reader and Phase 2 key
* format can be built on fact rather than assumption.
* *
* Blocking reads; exit via the System screen. * 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.
*/ */
#include <plib.h> #include <plib.h>
#include "bcode.h" #include "bcode.h"
@@ -16,18 +17,23 @@ GLDEF_C INT main(VOID)
{ {
VOID *chan; VOID *chan;
UBYTE buf[64]; UBYTE buf[64];
INT err, n, i; INT loadErr, openErr, n, i;
err = bcodeLoad(); loadErr = bcodeLoad();
/* 0 = loaded now; E_FILE_EXIST = already loaded. Anything else is a problem openErr = bcodeOpen(&chan);
(e.g. E_FILE_NXIST = BAREAN.LDD not found on the device). */
p_printf("load %s.LDD: %d\n", BCODE_LDD, err);
if ((err = bcodeOpen(&chan)) < 0) { /* Show both results and hold the screen until a key is pressed. */
p_printf("open %s failed: %d\n", BCODE_DEV, err); 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");
p_getch();
if (openErr < 0)
return 1; return 1;
}
p_printf("%s open. Scan a barcode.\n\n", BCODE_DEV); p_printf("\n%s open. Scan a barcode. Exit via the System screen.\n\n",
BCODE_DEV);
for (;;) { for (;;) {
n = p_read(chan, buf, sizeof(buf)); n = p_read(chan, buf, sizeof(buf));