feat(inventory): WL2:D trigger(6/7)+p_read loop with length + re-trigger
This commit is contained in:
+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
|
* Confirmed from the previous build: opening WL2:D then issuing control ops 6
|
||||||
* SIBO I/O executive (int 0xCF), i.e. the p_iow(chan, func, ...) layer. After
|
* and 7 triggers a scan (laser fires, green good-read LED). What was missing was
|
||||||
* opening WL2:D the driver is enabled with two control ops (function codes 6
|
* the read: a bare p_iow(chan, P_FREAD, buf) passes no length. This uses p_read
|
||||||
* then 7 on the channel), after which decoded barcodes can be read. Decoded
|
* (which passes &len) to collect the decoded result, and re-triggers (ops 6/7)
|
||||||
* output is terminated by CR LF (default Symbol2 postamble 0x0D 0x0A).
|
* each iteration so successive scans work without relying on the scan key.
|
||||||
*
|
* Decoded output is CR/LF-terminated (default Symbol2 postamble).
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
#include <plib.h>
|
#include <plib.h>
|
||||||
|
|
||||||
#define WL2_ENABLE1 6
|
#define WL2_TRIG1 6
|
||||||
#define WL2_ENABLE2 7
|
#define WL2_TRIG2 7
|
||||||
|
|
||||||
GLDEF_C INT main(VOID)
|
GLDEF_C INT main(VOID)
|
||||||
{
|
{
|
||||||
VOID *chan;
|
VOID *chan;
|
||||||
UBYTE buf[256];
|
UBYTE buf[256];
|
||||||
INT err, r, i;
|
INT err, n, i;
|
||||||
|
|
||||||
err = p_open(&chan, "WL2:D", (UINT)-1);
|
err = p_open(&chan, "WL2:D", (UINT)-1);
|
||||||
p_printf("open WL2:D: %d\n", err);
|
p_printf("open WL2:D: %d\n", err);
|
||||||
@@ -31,24 +27,23 @@ GLDEF_C INT main(VOID)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = p_iow(chan, WL2_ENABLE1);
|
p_printf("Present a barcode under the laser. Reads:\n\n");
|
||||||
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");
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
r = p_iow(chan, P_FREAD, buf);
|
p_iow(chan, WL2_TRIG1); /* trigger a scan */
|
||||||
if (r < 0) {
|
p_iow(chan, WL2_TRIG2);
|
||||||
p_printf("read status %d\n", r);
|
n = p_read(chan, buf, sizeof(buf)); /* collect decoded result (with len) */
|
||||||
|
if (n < 0) {
|
||||||
|
p_printf("read %d\n", n);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p_printf("r=%d b0=%d:", r, buf[0]);
|
if (n == 0)
|
||||||
for (i = 0; i < 24 && i < 256; i++)
|
continue;
|
||||||
|
p_printf("n=%d:", n);
|
||||||
|
for (i = 0; i < n && i < 40; i++)
|
||||||
p_printf(" %d", buf[i]);
|
p_printf(" %d", buf[i]);
|
||||||
p_printf(" \"");
|
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_putch(buf[i] >= ' ' ? buf[i] : '.');
|
||||||
p_printf("\"\n");
|
p_printf("\"\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user