This function tries to fetch a barcode from the scanner.

ReadBarcodeEx function that performs the same control as this function has been added, and it is now possible to receive a code ID different from this function.

Syntax

int ReadBarcode(
  struct barcode *barcodep
);

Parameters

barcodep
[in] A pointer to a barcode structure.

Return value

Returns barcode reading success (OK) or failure (ERROR).

Remarks

Use the SystemSetting function to select which barcode symbologies must be read.
Please refer to the single reading setting and multi-reading setting in [Barcode reader settings].
※ About the number of readable digits
Depending on the state of the barcode, it is possible to read data that is shorter than it actually is.
To prevent this, it is recommended to set the number of digits to allow reading.

Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Sample

#include <stdio.h>
#include "lib.h"

void main(void)
{
    char bcr_buf[42];
    struct barcode code;

    code.min = 1;
    code.max = 41;
    code.text = bcr_buf;
    for ( ;; )
    {
        if (!IsScannerOff())
        {
            if (ReadBarcode(&code) == OK)
            {
                if (((code.id == CODABAR) ||
                    (code.id == I2OF5) ||
                    (code.id == D2OF5)) &&
                    (code.length > 5))
                {
                    GoodReadLed(RED,10);
                    Sound(TSTANDARD,VHIGH,SMEDIUM,SHIGH,0);
                    ScannerPower(OFF,0);
                    printf("%s\n",code.text);
                }
            }
        }
        else
        {
            Delay(TIME_100MS * 10);
            ScannerPower(ON,250);
        }
        Idle();
    }
}

See also

Last updated: 2020/10/02