/* * scan.c - Phase 1 barcode diagnostic for the Workabout MX integral laser. * * Per the I/O Devices Reference (HC Bar Code Reader chapter): load a decoder * LDD (BAREAN.LDD for UPC/EAN), open the device "BAR:" (top slot is "A" * on the HC; the Workabout may map the top slot differently), and read with * p_iow(pcb, P_FREAD, buf), buf >= 256 bytes. The result is a leading byte * count in buf[0] (0 = unsuccessful read), buf[1] = a barcode-type character, * and buf[2..] = the decoded digits. * * This build probes the likely slot letters (bare "BAR:" gave E_FILE_NAME/-38 * because it lacks the slot letter), reports which opens, then dumps the raw * [count][type][data] of each scan so the exact UPC format is confirmed. * * Blocking I/O; exit via the System screen. */ #include #include "bcode.h" #define NCAND 4 GLDEF_C INT main(VOID) { VOID *chan; UBYTE buf[256]; INT loadErr, r, i, cnt, opened; UINT k; static TEXT *names[NCAND] = { "BAR:A", "BAR:D", "BAR:B", "BAR:E" }; loadErr = bcodeLoad(); p_printf("load %s.LDD: %d\n\n", BCODE_LDD, loadErr); opened = 0; for (k = 0; k < NCAND; k++) { r = p_open(&chan, names[k], (UINT)-1); p_printf("open \"%s\": %d\n", names[k], r); if (r >= 0) { opened = 1; break; } } if (opened == 0) { p_printf("\nNothing opened. Press a key to exit.\n"); p_getch(); return 1; } p_printf("\nOpened \"%s\". Scan a barcode. System screen to exit.\n\n", names[k]); for (;;) { /* Barcode read: buffer only, count returned in buf[0]. Blocking. */ r = p_iow(chan, P_FREAD, buf); if (r < 0) { p_printf("read status %d\n", r); continue; } cnt = buf[0]; if (cnt <= 0) { p_printf("(empty read)\n"); continue; } p_printf("cnt=%d type=%d:", cnt, buf[1]); for (i = 1; i <= cnt && i < 256; i++) p_printf(" %d", buf[i]); p_printf(" \""); for (i = 1; i <= cnt && i < 256; i++) p_putch(buf[i] >= ' ' ? buf[i] : '.'); p_printf("\"\n"); } }