feat(inventory): Phase 1 - scan and validate UPC barcodes #1

Open
lyrathorpe wants to merge 54 commits from feat/inventory-phase1-scan into main
Showing only changes of commit 3fd94158bd - Show all commits
+15 -31
View File
@@ -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;
}