/*
 * 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)
{
    /*
     * 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, BCODE_DEV, (UINT)-1);
}

GLDEF_C VOID bcodeClose(VOID *chan)
{
    if (chan != NULL)
        p_close(chan);
}
