56 lines
1.7 KiB
C
56 lines
1.7 KiB
C
/*
|
|
* scan.c - Phase 1: read the integral laser via WL2:D (reverse-engineered init).
|
|
*
|
|
* 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.
|
|
*/
|
|
#include <plib.h>
|
|
|
|
#define WL2_ENABLE1 6
|
|
#define WL2_ENABLE2 7
|
|
|
|
GLDEF_C INT main(VOID)
|
|
{
|
|
VOID *chan;
|
|
UBYTE buf[256];
|
|
INT err, r, i;
|
|
|
|
err = p_open(&chan, "WL2:D", (UINT)-1);
|
|
p_printf("open WL2:D: %d\n", err);
|
|
if (err < 0) {
|
|
p_printf("Press a key to exit.\n");
|
|
p_getch();
|
|
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");
|
|
|
|
for (;;) {
|
|
r = p_iow(chan, P_FREAD, buf);
|
|
if (r < 0) {
|
|
p_printf("read status %d\n", r);
|
|
continue;
|
|
}
|
|
p_printf("r=%d b0=%d:", r, buf[0]);
|
|
for (i = 0; i < 24 && i < 256; i++)
|
|
p_printf(" %d", buf[i]);
|
|
p_printf(" \"");
|
|
for (i = 0; i < 24 && i < 256; i++)
|
|
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
|
p_printf("\"\n");
|
|
}
|
|
}
|