2026-07-06 17:41:44 +01:00
|
|
|
/*
|
2026-07-06 18:13:56 +01:00
|
|
|
* scan.c - Phase 1 barcode diagnostic for the Workabout MX integral laser.
|
2026-07-06 17:41:44 +01:00
|
|
|
*
|
2026-07-06 18:19:53 +01:00
|
|
|
* 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.
|
2026-07-06 17:41:44 +01:00
|
|
|
*
|
2026-07-06 18:19:53 +01:00
|
|
|
* 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.
|
2026-07-06 17:41:44 +01:00
|
|
|
*/
|
|
|
|
|
#include <plib.h>
|
|
|
|
|
#include "bcode.h"
|
|
|
|
|
|
|
|
|
|
GLDEF_C INT main(VOID)
|
|
|
|
|
{
|
2026-07-06 18:13:56 +01:00
|
|
|
VOID *chan;
|
|
|
|
|
UBYTE buf[64];
|
2026-07-06 18:19:53 +01:00
|
|
|
INT loadErr, openErr, n, i;
|
2026-07-06 17:41:44 +01:00
|
|
|
|
2026-07-06 18:19:53 +01:00
|
|
|
loadErr = bcodeLoad();
|
|
|
|
|
openErr = bcodeOpen(&chan);
|
2026-07-06 18:13:56 +01:00
|
|
|
|
2026-07-06 18:19:53 +01:00
|
|
|
/* 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");
|
|
|
|
|
p_getch();
|
|
|
|
|
|
|
|
|
|
if (openErr < 0)
|
2026-07-06 17:41:44 +01:00
|
|
|
return 1;
|
2026-07-06 18:19:53 +01:00
|
|
|
|
|
|
|
|
p_printf("\n%s open. Scan a barcode. Exit via the System screen.\n\n",
|
|
|
|
|
BCODE_DEV);
|
2026-07-06 17:41:44 +01:00
|
|
|
|
2026-07-06 17:51:17 +01:00
|
|
|
for (;;) {
|
2026-07-06 18:13:56 +01:00
|
|
|
n = p_read(chan, buf, sizeof(buf));
|
2026-07-06 17:51:17 +01:00
|
|
|
if (n < 0) {
|
2026-07-06 18:13:56 +01:00
|
|
|
p_printf("read err %d\n", n);
|
2026-07-06 17:41:44 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
2026-07-06 18:13:56 +01:00
|
|
|
if (n == 0)
|
|
|
|
|
continue;
|
|
|
|
|
p_printf("n=%d:", n);
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
p_printf(" %d", buf[i]);
|
|
|
|
|
p_printf(" \"");
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
|
|
|
|
p_printf("\"\n");
|
2026-07-06 17:41:44 +01:00
|
|
|
}
|
|
|
|
|
}
|