Files
sibo-playground/code/inventory/scan.c
T

49 lines
1.4 KiB
C
Raw Normal View History

/*
* 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: the decimal value of each byte plus a
* printable rendering. This shows exactly what the decoder delivers for a UPC
* (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.
*/
#include <plib.h>
#include "bcode.h"
GLDEF_C INT main(VOID)
{
VOID *chan;
UBYTE buf[64];
INT err, n, i;
err = bcodeLoad();
/* 0 = loaded now; E_FILE_EXIST = already loaded. Anything else is a problem
(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) {
p_printf("open %s failed: %d\n", BCODE_DEV, err);
return 1;
}
p_printf("%s open. Scan a barcode.\n\n", BCODE_DEV);
for (;;) {
n = p_read(chan, buf, sizeof(buf));
if (n < 0) {
p_printf("read err %d\n", n);
continue;
}
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");
}
}