2026-07-06 17:41:44 +01:00
|
|
|
/*
|
2026-07-06 21:44:10 +01:00
|
|
|
* scan.c - Phase 1: read the integral laser via WL2:D (reverse-engineered init).
|
2026-07-06 17:41:44 +01:00
|
|
|
*
|
2026-07-06 21:44:10 +01:00
|
|
|
* 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.
|
2026-07-06 17:41:44 +01:00
|
|
|
*/
|
|
|
|
|
#include <plib.h>
|
2026-07-06 18:28:22 +01:00
|
|
|
|
2026-07-06 21:44:10 +01:00
|
|
|
#define WL2_ENABLE1 6
|
|
|
|
|
#define WL2_ENABLE2 7
|
2026-07-06 21:23:19 +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;
|
2026-07-06 20:39:17 +01:00
|
|
|
UBYTE buf[256];
|
2026-07-06 21:44:10 +01:00
|
|
|
INT err, r, i;
|
2026-07-06 18:28:22 +01:00
|
|
|
|
2026-07-06 21:44:10 +01:00
|
|
|
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");
|
2026-07-06 19:04:43 +01:00
|
|
|
p_getch();
|
|
|
|
|
return 1;
|
2026-07-06 17:41:44 +01:00
|
|
|
}
|
2026-07-06 18:51:31 +01:00
|
|
|
|
2026-07-06 21:44:10 +01:00
|
|
|
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");
|
2026-07-06 20:14:54 +01:00
|
|
|
|
2026-07-06 19:04:43 +01:00
|
|
|
for (;;) {
|
2026-07-06 20:39:17 +01:00
|
|
|
r = p_iow(chan, P_FREAD, buf);
|
|
|
|
|
if (r < 0) {
|
|
|
|
|
p_printf("read status %d\n", r);
|
2026-07-06 19:04:43 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
2026-07-06 21:23:19 +01:00
|
|
|
p_printf("r=%d b0=%d:", r, buf[0]);
|
2026-07-06 20:54:14 +01:00
|
|
|
for (i = 0; i < 24 && i < 256; i++)
|
2026-07-06 20:39:17 +01:00
|
|
|
p_printf(" %d", buf[i]);
|
|
|
|
|
p_printf(" \"");
|
2026-07-06 20:54:14 +01:00
|
|
|
for (i = 0; i < 24 && i < 256; i++)
|
2026-07-06 20:39:17 +01:00
|
|
|
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
|
|
|
|
p_printf("\"\n");
|
2026-07-06 19:04:43 +01:00
|
|
|
}
|
2026-07-06 17:41:44 +01:00
|
|
|
}
|