scan - Scan Barcode

Scan a barcode using USB-attached barcode scanner.

Usage:

- command: scan [<format>]
  [expect: [hex] <expectText>]
  [extract: <extractText>]
  [extractKey: <key>...]
  [retry: <retryCount>]
  [timeout: <timeout>]
  [with:
    [- trigger:<DDTPxx|RDTPxx> <kind> <level> [<triggerDuration>]]

Argument

Description

format

Format of code to scan (optional as of PLT-OS v2.0.30)

expectText

Text to expect in the barcode. If the hex keyword is used, expectText is interpreted as a hex string.

extractText

Regular expression to extract (uses RE2 Syntax, except \C)

key

Key(s) in which to store extracted text. To save multiple values, use multiple capture groups.

retryCount

Number of times to retry the test step (optional)

timeout

Timeout, with time suffix ("500ms") or in milliseconds (default: 30s)

RDTPxx/DDTPxx

Optional trigger pin to initiate scanning.

level

Trigger level: high or low

kind

Trigger kind: active or pulse

triggerDuration

Option trigger duration (default: 100ms)

Supported format values:

format

Description

ANY

Any barcode

%MAC_ADDRESS%

48-bit MAC address (XX:XX:XX:XX:XX:XX)

title: "Scan serial number"
suite:
- steps:
  - command: scan ANY
    extractKey: MY_BARCODE
  - command: serial set %MY_BARCODE%
title: "Scan barcode with expected substring"
suite:
- steps:
  - command: scan
    # "MN-004137-01EN"
    expect: "MN-"
    extractKey: BARCODE_EXPECTED
title: "Scan barcode and extract multiple values"
suite:
- steps:
  - command: scan
    # "MN-004137-01EN"
    extract: "^MN-(\\d+)-(\\d+.*)$"
    extractKey: NUM SUFFIX