From 3fd94158bdabb9ff1467c8b9fddf37ae1c953eb6 Mon Sep 17 00:00:00 2001 From: lyrathorpe Date: Mon, 6 Jul 2026 18:13:55 +0100 Subject: [PATCH] feat(inventory): load decoder LDD + open BAR: instead of raw TTY:D --- code/inventory/bcode.c | 46 ++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/code/inventory/bcode.c b/code/inventory/bcode.c index f9bff1f..d03c254 100644 --- a/code/inventory/bcode.c +++ b/code/inventory/bcode.c @@ -1,21 +1,26 @@ /* - * bcode.c - barcode scanner serial channel (see bcode.h). + * bcode.c - barcode scanner input via the software decoder LDD (see bcode.h). */ #include "bcode.h" +GLDEF_C INT bcodeLoad(VOID) +{ + /* + * Load the EAN/UPC decoder LDD. p_loadldd assumes a .LDD extension, and + * looks along the current path if no full path is given, so BAREAN.LDD + * must be present on the device. If the system already loaded it (e.g. via + * config), this returns E_FILE_EXIST, which the caller treats as success. + */ + return p_loadldd(BCODE_LDD); +} + GLDEF_C INT bcodeOpen(VOID **pChan) { /* - * TTY:D = the top internal slot's serial port, where the barcode module - * sits. mode -1 asks the driver for its default open mode. - * - * If the scanner needs specific line settings (baud rate, parity, stop - * bits), configure the channel after opening with - * p_iow(*pChan, P_FSET, &config); - * where config is an E_CONFIG struct from p_config.h. See the RS232 - * section of the PLIB Reference. The module runs at up to 9600 baud. + * Open the decoder device. Opening it powers and enables the scanner; the + * LDD decodes the raw laser signal and delivers decoded barcodes on reads. */ - return p_open(pChan, "TTY:D", (UINT)-1); + return p_open(pChan, BCODE_DEV, (UINT)-1); } GLDEF_C VOID bcodeClose(VOID *chan) @@ -23,24 +28,3 @@ GLDEF_C VOID bcodeClose(VOID *chan) if (chan != NULL) p_close(chan); } - -GLDEF_C INT bcodeAssemble(UBYTE *raw, INT n, TEXT *line, INT *pLen, INT max) -{ - INT i; - - for (i = 0; i < n; i++) { - UBYTE c = raw[i]; - - if (c == BCODE_TERM) { - line[*pLen] = '\0'; - *pLen = 0; - return 1; - } - if (c < ' ') /* skip LF, NULs and other control bytes */ - continue; - if (*pLen < max - 1) - line[(*pLen)++] = (TEXT)c; - /* else: overflow - drop until the next terminator */ - } - return 0; -}