feat(inventory): load decoder LDD + open BAR: instead of raw TTY:D
This commit is contained in:
+15
-31
@@ -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"
|
#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)
|
GLDEF_C INT bcodeOpen(VOID **pChan)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* TTY:D = the top internal slot's serial port, where the barcode module
|
* Open the decoder device. Opening it powers and enables the scanner; the
|
||||||
* sits. mode -1 asks the driver for its default open mode.
|
* LDD decodes the raw laser signal and delivers decoded barcodes on reads.
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
return p_open(pChan, "TTY:D", (UINT)-1);
|
return p_open(pChan, BCODE_DEV, (UINT)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLDEF_C VOID bcodeClose(VOID *chan)
|
GLDEF_C VOID bcodeClose(VOID *chan)
|
||||||
@@ -23,24 +28,3 @@ GLDEF_C VOID bcodeClose(VOID *chan)
|
|||||||
if (chan != NULL)
|
if (chan != NULL)
|
||||||
p_close(chan);
|
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;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user