feat(inventory): Phase 1 - scan and validate UPC barcodes #1
+21
-26
@@ -1,27 +1,23 @@
|
||||
/*
|
||||
* scan.c - Phase 1: read the integral laser via WL2:D (reverse-engineered init).
|
||||
* scan.c - Phase 1: WL2:D scanner, trigger + read loop (reverse-engineered).
|
||||
*
|
||||
* From disassembling SCANNER.DYL in the MX ROM, the scanner is driven over the
|
||||
* SIBO I/O executive (int 0xCF), i.e. the p_iow(chan, func, ...) layer. After
|
||||
* opening WL2:D the driver is enabled with two control ops (function codes 6
|
||||
* then 7 on the channel), after which decoded barcodes can be read. Decoded
|
||||
* output is terminated by CR LF (default Symbol2 postamble 0x0D 0x0A).
|
||||
*
|
||||
* This is the first RE-based attempt: the enable-then-read path. The full config
|
||||
* download (cl=0x0C command-byte writes) is not replicated here - if the driver
|
||||
* applies Symbol2 defaults on open, enable+read should suffice; if not, we add
|
||||
* the config writes next. Press the scan key to fire the laser.
|
||||
* Confirmed from the previous build: opening WL2:D then issuing control ops 6
|
||||
* and 7 triggers a scan (laser fires, green good-read LED). What was missing was
|
||||
* the read: a bare p_iow(chan, P_FREAD, buf) passes no length. This uses p_read
|
||||
* (which passes &len) to collect the decoded result, and re-triggers (ops 6/7)
|
||||
* each iteration so successive scans work without relying on the scan key.
|
||||
* Decoded output is CR/LF-terminated (default Symbol2 postamble).
|
||||
*/
|
||||
#include <plib.h>
|
||||
|
||||
#define WL2_ENABLE1 6
|
||||
#define WL2_ENABLE2 7
|
||||
#define WL2_TRIG1 6
|
||||
#define WL2_TRIG2 7
|
||||
|
||||
GLDEF_C INT main(VOID)
|
||||
{
|
||||
VOID *chan;
|
||||
UBYTE buf[256];
|
||||
INT err, r, i;
|
||||
INT err, n, i;
|
||||
|
||||
err = p_open(&chan, "WL2:D", (UINT)-1);
|
||||
p_printf("open WL2:D: %d\n", err);
|
||||
@@ -31,24 +27,23 @@ GLDEF_C INT main(VOID)
|
||||
return 1;
|
||||
}
|
||||
|
||||
r = p_iow(chan, WL2_ENABLE1);
|
||||
p_printf("enable op6: %d\n", r);
|
||||
r = p_iow(chan, WL2_ENABLE2);
|
||||
p_printf("enable op7: %d\n", r);
|
||||
|
||||
p_printf("\nScan a barcode (press scan key). Dumping reads:\n\n");
|
||||
p_printf("Present a barcode under the laser. Reads:\n\n");
|
||||
|
||||
for (;;) {
|
||||
r = p_iow(chan, P_FREAD, buf);
|
||||
if (r < 0) {
|
||||
p_printf("read status %d\n", r);
|
||||
p_iow(chan, WL2_TRIG1); /* trigger a scan */
|
||||
p_iow(chan, WL2_TRIG2);
|
||||
n = p_read(chan, buf, sizeof(buf)); /* collect decoded result (with len) */
|
||||
if (n < 0) {
|
||||
p_printf("read %d\n", n);
|
||||
continue;
|
||||
}
|
||||
p_printf("r=%d b0=%d:", r, buf[0]);
|
||||
for (i = 0; i < 24 && i < 256; i++)
|
||||
if (n == 0)
|
||||
continue;
|
||||
p_printf("n=%d:", n);
|
||||
for (i = 0; i < n && i < 40; i++)
|
||||
p_printf(" %d", buf[i]);
|
||||
p_printf(" \"");
|
||||
for (i = 0; i < 24 && i < 256; i++)
|
||||
for (i = 0; i < n && i < 40; i++)
|
||||
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
||||
p_printf("\"\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user