2026-07-06 17:41:44 +01:00
|
|
|
/*
|
2026-07-06 19:04:43 +01:00
|
|
|
* scan.c - Phase 1 barcode diagnostic: pin down the BAR: device.
|
2026-07-06 17:41:44 +01:00
|
|
|
*
|
2026-07-06 19:04:43 +01:00
|
|
|
* The scan key is keycode 368 (a Window Server key event an app catches to
|
|
|
|
|
* trigger a scan); the working demo draws the decode itself, so it uses a
|
|
|
|
|
* scanner API - and the only barcode software path in this SDK is the bar*.ldd
|
|
|
|
|
* decoder device "BAR:". Our BAR: open has been failing but its exact error
|
|
|
|
|
* kept scrolling away. This build loads BAREAN, opens BAR:A (then BAR:B),
|
|
|
|
|
* reports each result and HOLDS the screen. If a channel opens, it issues
|
|
|
|
|
* p_iow(P_FREAD) - which should arm the laser - and dumps the decode.
|
2026-07-06 17:41:44 +01:00
|
|
|
*/
|
|
|
|
|
#include <plib.h>
|
2026-07-06 19:04:43 +01:00
|
|
|
#include "bcode.h"
|
2026-07-06 18:28:22 +01:00
|
|
|
|
2026-07-06 17:41:44 +01:00
|
|
|
GLDEF_C INT main(VOID)
|
|
|
|
|
{
|
2026-07-06 19:04:43 +01:00
|
|
|
VOID *chan;
|
|
|
|
|
UBYTE buf[256];
|
|
|
|
|
INT ld, ra, rb, r, i, cnt;
|
2026-07-06 18:28:22 +01:00
|
|
|
|
2026-07-06 19:04:43 +01:00
|
|
|
ld = p_loadldd(BCODE_LDD);
|
|
|
|
|
ra = p_open(&chan, "BAR:A", (UINT)-1);
|
|
|
|
|
if (ra < 0)
|
|
|
|
|
rb = p_open(&chan, "BAR:B", (UINT)-1);
|
|
|
|
|
else
|
|
|
|
|
rb = 0;
|
2026-07-06 18:19:53 +01:00
|
|
|
|
2026-07-06 19:04:43 +01:00
|
|
|
p_printf("load %s: %d\n", BCODE_LDD, ld);
|
|
|
|
|
p_printf("open BAR:A: %d\n", ra);
|
|
|
|
|
if (ra < 0)
|
|
|
|
|
p_printf("open BAR:B: %d\n", rb);
|
|
|
|
|
|
|
|
|
|
if (ra < 0 && rb < 0) {
|
|
|
|
|
p_printf("\nNo BAR channel opened. Press a key.\n");
|
|
|
|
|
p_getch();
|
|
|
|
|
return 1;
|
2026-07-06 17:41:44 +01:00
|
|
|
}
|
2026-07-06 18:51:31 +01:00
|
|
|
|
2026-07-06 19:04:43 +01:00
|
|
|
p_printf("\nOpen. A read should arm the laser - scan now.\n\n");
|
|
|
|
|
for (;;) {
|
|
|
|
|
r = p_iow(chan, P_FREAD, buf); /* arms laser, blocks for a decode */
|
|
|
|
|
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");
|
|
|
|
|
}
|
2026-07-06 17:41:44 +01:00
|
|
|
}
|