scan - Scan Barcode

Scan a barcode using USB-attached barcode scanner.

Usage:

- command: scan [<format>]
  [expect: [hex] <expectText>]
  [extract: <extractText>]
  [extractKey: <key>...]
  [retry: <retryCount>]

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)

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