Controls the reading operation of the OPH-5000i scanner module.

Syntax

int ScannerPower(
  int mode, 
  int time
);

Parameters

mode
[in] Specifies the read operation of the scanner module.
mode can have one of the following values:
ValueDescription
OFF Stops the scanner module's reading operation.
The scanner module will not start reading even if the trigger key is pressed.
ON After calling this function, the scanner module starts reading immediately.
If a barcode is read by the ReadBarcode function, the reading stops.
The scanner module stops reading after the time specified by time has elapsed.
The scanner module does not start reading even if the trigger key is pressed. The next time you start reading, you must call this function again.
When time=0, the reading does not stop until the barcode is read.
TRIGGER Enables the reading operation to read one barcode by pressing and holding the trigger key.
The scanner module only reads while the trigger key is pressed.
When a barcode is read by the ReadBarcode function, the read operation stops.
When the key remains pressed, the read operation stops after the time specified by time has elapsed.
When time=0, if the key remains pressed, the read operation does not stop until the barcode is read.
*When the function is called, the scanner module is set to single read (S0).
SINGLE Enables the read operation to read one barcode with the trigger key.
The scanner module starts reading when the trigger key is pressed.
When a barcode is read by the ReadBarcode function, or after the time specified by time has elapsed, the read operation stops.
When time=0, reading ends when the trigger key is released.
*When the function is called, the scanner module is set to single-shot reading (S0).
MULTIPLE Enables reading operation to read multiple barcodes with the trigger key.
The scanner module starts reading operation when the trigger key is pressed.
The reading operation continues even after the barcode is read once, and reads a barcode with different contents from the previous time.
When a barcode is read using the ReadBarcode function, the reading operation stops when the time specified in time has elapsed since the barcode was read.
If the barcode is not read, the reading operation stops when the time specified in time has elapsed since the trigger key was pressed.
When time=0, reading ends when the trigger key is released.
*Multiple reading (S1) is set to the scanner module when the function is called.
SCANNER_MODE_REACTIVATION When the reading operation is stopped by mode=OFF, pressing the trigger key starts the reading operation with the previously set reading operation.
If SINGLE, MULTIPLE, or TRIGGER has not been executed after startup, it operates in SINGLE.
The reading operation time is the time specified in time.
*Single reading (S0) or multiple reading (S1) settings are not sent to the scanner module when the function is called.
time
[in] Specifies the time to read.
The value range is 0 to 32,767.
Do not set a value outside this range.
One unit is 20 msec.
Example: If time is 250, it will be 250 x 20 msec = 5 seconds.

Return value

The scanner module setting success (OK) or setting failure (ERROR) is returned.

Remarks

This function controls the reading operation of the OPH-5000i scanner module.
To determine whether a barcode has been read, use the ReadBarcode function.

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();
    }
}

Last updated: 2024/10/30