Label Printing

If a label printer is attached and powered up, a label will be always printed upon completion of the test plan (PASS or FAIL).

The default ZPL generated by the PLT upon completion of a YAML test plan specification can be overridden by uploading template-pass.zpl and template-fail.zpl files as part of the Release deployed through PLTcloud.

Example template-fail.zpl file:

^FX template-fail.zpl - ZPL Template for failing DUTs
^XA^LH40,30
^MD2
^FO0,10^ADN,30,8^FDCODE^FS
^FO0,80^ADN,30,8^FDN/G^FS
^XZ

Example template-pass.zpl file:

^FX template-pass.zpl - ZPL Template for DUTs that pass testing
^XA
~SD22
^CF0,30
^FO40,20^FDProduct:DUT_PRODUCT^FS
^FO40,30^FDVersion:DUT_VERSION^FS
^FO40,40^FDS/N:DUT_SERIAL^FS
^FO40,50^FDMAC Address:MAC_ADDRESS^FS
^FO40,60^FDBLE Address:BLEMAC^FS
^FO40,70^FDFailure:FAILURE_MSG^FS
^FO40,80^FDCode:CODE^FS
^FO40,170^BY2
^BCN,50,N,N,N
^FDMAC_ADDRESS^FS
^XZ

ZPL Template Filenames

ZPL templates with the following filenames will be used, if included in the Release deployed to the PLT:

  1. Test plan-specific PASS/FAIL Templates :

    Added in version PLT-OS: v2.0.32

    For example, assuming a test plan sampleTestPlan.yaml, the PLT will use these templates, if available:

    • For a passing test plan run: sampleTestPlan-pass.zpl

    • For a failing test plan run: sampleTestPlan-fail.zpl

  2. Release Default Templates:

    • For a passing test plan run template-pass.zpl

    • For a failing test plan run: template-fail.zpl

  3. Built-in ZPL PASS/FAIL labels (if none of the above templates are available)

Substitutions

The following keys are always substituted in the label template:

Key

Description

DUT_PRODUCT

Product name

DUT_VERSION

Version

DUT_SERIAL

DUT Serial number

MAC_ADDRESS

MAC address

BLEMAC

BLE MAC address

FAILURE_MSG

Test failure

Additional substitutions can be set using the label command.

Example: Substitute a custom key

title: "Custom barcode substitution"
suite:
- title: Define label keys
  steps:

  - command: define CODE 12345

  # Substitute `CODE`, in addition to
  # `DUT_PRODUCT`, `DUT_VERSION`, `DUT_SERIAL`,
  # `MAC_ADDRESS`, `BLEMAC` and `FAILURE_MSG`
  - command: label keys CODE

Example: Substitute a timestamp

title: "Custom barcode date code substitution"
suite:
- title: Define label keys
  steps:

  # DATECODE: YYYYMMDD format
  - command: eval "utcTime('20060102')"
    extractKey: DATECODE

  # Substitute `DATECODE`, in addition to
  # `DUT_PRODUCT`, `DUT_VERSION`, `DUT_SERIAL`,
  # `MAC_ADDRESS`, `BLEMAC` and `FAILURE_MSG`
  - command: label keys DATECODE

Commands

PLT Tested Label

../../_images/template-plt-tested-24x12mm-300dpi-datamatrix.png

Sample “PLT Tested” label with DataMatrix barcode

This template contains a BARCODE_A1B2C3D4E5F6G7H8I9 placeholder for the payload of the barcode, reserving sufficient size to encode 128 bits of data. Include this file as template-pass.zpl in the PLTcloud project deployed to a PLT.

title: "PLT Tested barcode substitution"
suite:
- ident: ICT-T0
  title: Define label keys
  steps:
  # 40-bit decimal representation of a UUID
  - command: define BARCODE_A1B2C3D4E5F6G7H8I9 272591031380294133745056697788699092364
  # Specify the placeholder to substitute
  - command: label keys BARCODE_A1B2C3D4E5F6G7H8I9

Common ZPL Commands

^XA Start

Marks the beginning of a ZPL print job. It must be used at the start of each label format to initialize the command sequence.

^XZ End

Marks the end of a ZPL print job. This command finalizes the label format for processing by the printer.

^FO Field Origin

Sets the position (origin) of a field on the label. The origin is defined by X and Y coordinates that specify where the field begins. Commonly used to position text, barcodes, and graphics.

^FD Field Data

Defines the data for a field. This command specifies the actual text, numbers, or barcode data that will be printed. It is typically followed by a ^FS (Field Separator) to mark the end of the data field.

^FX Comment

Used to add comments within the ZPL code. This line will not be processed by the printer and is useful for adding notes.

^PQ Print Quantity

Specifies the number of identical labels to print. This command is typically used to control batch printing with one label format.

References