feat(inventory): read barcode via BAREAN.LDD decoder on BAR: (integral laser is undecoded/HHLC)

This commit is contained in:
2026-07-06 18:13:54 +01:00
parent 64e484448c
commit 034ffd211c
+26 -24
View File
@@ -1,43 +1,45 @@
/* /*
* bcode.h - barcode scanner input via the Workabout serial port. * bcode.h - barcode scanner input on the Workabout MX (integral laser).
* *
* On the Workabout the barcode module decodes the label in hardware and * The Workabout MX integral laser is an UNDECODED (HHLC) scanner: it emits a
* delivers the result as an RS232 stream, so a scan is simply read from the * raw bar/space signal, not decoded ASCII. The hardware serial decoder in the
* serial channel using the standard PLIB serial I/O. The scanner here is on * RS232/Barcode module only handles wands and wand-emulation scanners (the HC
* the top internal slot, which is port D -> device "TTY:D". * guide lists "Undecoded Laser Scanner (HHLC)" as unsupported there), which is
* why reading TTY:D directly yielded nothing even though the laser's own
* good-read LED lit.
*
* The decode is instead done in software by a barcode decoder LDD. The SDK
* ships several (\SIBOSDK\LIB): BAREAN (EAN/UPC), BARC39, BAR128, BARITF,
* BARMPLES, BARRAW. Each registers the device "BAR:". For UPC we load BAREAN.
*
* Usage: bcodeLoad() once, then bcodeOpen() to get a channel, then read it.
* The BAREAN.LDD file must be present on the device so p_loadldd can find it.
*/ */
#ifndef BCODE_H #ifndef BCODE_H
#define BCODE_H #define BCODE_H
#include <plib.h> #include <plib.h>
/* Decoder LDD to load (BAREAN.LDD = EAN/UPC) and the device it registers. */
#define BCODE_LDD "BAREAN"
#define BCODE_DEV "BAR:"
/* Longest decoded barcode we handle (UPC-A is 12; headroom for EAN/supplements). */
#define BCODE_MAXLEN 24
/* /*
* Terminator the scanner appends after each decoded barcode. Most serial * Load the UPC/EAN decoder LDD. Returns 0 if loaded, or a negative PLIB error.
* barcode readers send a carriage return (0x0D). If yours sends LF or a * E_FILE_EXIST (already loaded) is treated as success by callers.
* different suffix, change this to match its configuration.
*/ */
#define BCODE_TERM 0x0D GLREF_C INT bcodeLoad(VOID);
/* Longest decoded barcode we handle (UPC-A is 12; headroom for EAN etc.). */
#define BCODE_MAXLEN 20
/* /*
* Open the barcode serial channel (TTY:D). Stores the channel handle in * Open a channel to the barcode decoder device (BAR:). Stores it in *pChan.
* *pChan. Returns 0 on success or a negative PLIB error code. * Returns 0 on success or a negative PLIB error.
*/ */
GLREF_C INT bcodeOpen(VOID **pChan); GLREF_C INT bcodeOpen(VOID **pChan);
/* Close a channel opened by bcodeOpen. Safe to call with NULL. */ /* Close a channel opened by bcodeOpen. Safe to call with NULL. */
GLREF_C VOID bcodeClose(VOID *chan); GLREF_C VOID bcodeClose(VOID *chan);
/*
* Line assembler. Feeds n freshly-read bytes from raw into the caller's line
* buffer (current length *pLen, capacity max). When BCODE_TERM is seen the
* completed, NUL-terminated barcode is left in line, *pLen is reset to 0 and
* 1 is returned. Otherwise returns 0 (more bytes needed). Control bytes below
* space (other than the terminator) are ignored; overflow bytes are dropped
* until the next terminator.
*/
GLREF_C INT bcodeAssemble(UBYTE *raw, INT n, TEXT *line, INT *pLen, INT max);
#endif /* BCODE_H */ #endif /* BCODE_H */