Quick Start
On this page
- Add your first printer
- Tags of a printer
- USB printers (Windows print queue)
- Printers that do not answer ~HS or ~HI
- Raw ZPL is off by default
- Label templates
- Images in labels
- GS1 check digits, SSCC and GS1-128 barcodes
- Scripting
- Print queue
- Job history
- Storing records
- Print confirmation (network printers)
- Extended status and alerts (network printers)
- Test label
- Tag-triggered printing
- PLC handshake for tag-triggered prints
- Logs
This release covers printer set-up, status tags, label templates, the print queue, the scripting functions
system.innorobix.zpl.*, the job history, the test label and tag-triggered printing.
A printer is reached either over the network (TCP 9100 or the port you configure) or, on a Windows gateway, through a printer installed on the gateway machine (USB, see “USB printers” below). Serial printers are not supported. The
system.innorobix.zpl.*functions exist in gateway scope only (gateway event scripts, Perspective session and component scripts that run on the gateway, tag events), not in Vision clients or the Designer script console. Printing always goes from the gateway, so the printer must be reachable from the gateway machine, not from the client. If a print fails, look at the gateway log (logger names start withinnorobix.zpl).The printers and the label templates are kept as the gateway’s configuration resources (one resource per printer or template, see the Installation chapter), not in the internal database. They survive a restart of the module or the gateway and are part of a gateway backup (
.gwbk). After a restart the module starts every enabled printer from the saved settings. A printer or template written by a newer version of the module is not loaded and is left untouched; the gateway log names it. Exporting the templates (see below) is still a good way to move them to another gateway. The job history is not saved (see Job history).
Add your first printer
- Open Connections > ZPL Label Printing > Printers in the gateway web UI and press Add device +.
- Enter a Name (it becomes the tag folder) and choose the Connection type:
NETWORK(network printer, the default) orOS_PRINTER(USB printer through the Windows print queue, see “USB printers” below). Leave Enabled on to start the printer when you save. - For
NETWORKopen the step Network printer and enter the Host. The Port is 9100 unless you changed it on the printer. The Status poll interval (ms) is the time between two status reads (at least 2 000 ms), the Timeout (ms) is how long the module waits for the printer to connect or answer, and the Description is free text. - For
OS_PRINTERopen the step USB printer (Windows print queue) and enter the OS printer name exactly as Windows lists it; leave the host empty. The form shows every step for both types, so fill in only the step of the type you chose. - Save. The printer starts at once, no restart needed. The printer list shows the connection type in the column
after Name. The port value (prefilled 9100) is ignored for
OS_PRINTER. For a USB printer the Test button only shows that Windows lists a printer of that name; its “answered” text does not mean the printer replied.
After a few seconds the printer shows its state in the list.
Tags of a printer
The module creates the tag provider [ZPL] with one folder per printer. The gateway lists the provider and its tag
count under Services > Tags; the tags themselves are in the Designer’s tag browser, provider [ZPL], folder
<Printer>.
| Tag | Meaning |
|---|---|
Connected |
True once the connection is open and the first status read has run. |
State |
Connecting, Reconnecting, Not licensed, Disabled, Stopped, Standby (this gateway is the backup node of a redundant pair and does not connect, see the Compatibility chapter, Redundancy), Waiting for licence, or NoStatus for a USB printer. |
LastError |
What is wrong when the printer is not connected. |
LastUpdate |
Time of the last good answer. |
ReconnectCount |
How often the connection was lost. |
LicenseState |
The module licence as this printer sees it. |
ProtocolErrors |
Answers from the printer the module could not use. |
Model and Firmware |
From the printer’s ~HI answer when the connection opens. |
Ready |
True when none of the fault tags below is set. |
PaperOut, RibbonOut, HeadOpen, Paused, BufferFull, TempError |
From ~HS at every poll; TempError is under or over temperature. |
Attention |
True while the printer sends no complete ~HS answer on an open connection (see below). |
HasError, HasWarning |
The printer reports at least one error or warning flag in its ~HQES answer (see “Extended status”). |
ErrorFlags, WarningFlags |
The two hex words of each flag line, as the printer sent them, so a flag the module does not name is not lost. |
CutterFault, PrintheadOverTemp, MotorOverTemp, BadPrintheadElement, PrintheadDetectionError, InvalidFirmwareConfig, PrintheadThermistorOpen |
Named error flags from ~HQES. |
Total, UserCounter1, UserCounter2, Unit |
The printer’s odometer from ~HQOD, read about once a minute. |
LifeText, CurrentDistance |
The printhead life answer from ~HQPH as text, and its first number when the row has the expected shape. |
Length, LastJobId, LastJobResult, LastJobTime |
The print queue, see “Print queue”. |
JobsOk, JobsFailed |
Job counters since the module started. |
Printer, JobId, Description, RequestedBy, Bytes, Ok, Result, Time |
The last finished job as a record, see “Storing records”. |
If the printer’s answer cannot be read, or it does not answer, the Status/* tags turn bad quality and
_Status/ProtocolErrors counts it. When the printer is not connected they are bad as well.
USB printers (Windows print queue)
Choose Connection type OS_PRINTER for a printer that is connected by USB (or is any printer installed in Windows
on the gateway machine). The page is the shared Innorobix configuration page: it shows the same steps for both types and
cannot hide fields, draw a dropdown of installed printers or show a separate information box. So:
- The text under Connection type lists the limits below; read it before you choose
OS_PRINTER. - Enter the printer’s exact name in the step USB printer (Windows print queue). The page has no dropdown. If the name
is wrong, the printer’s state shows “There is no printer named … installed on the gateway machine.” followed by “Installed:” and as many installed names
as fit in 200 characters (then “and N more”); copy the right one from there or from the full list. The same list is at
GET /data/zpl/config/os-printers(signed-in gateway session) as{"supported": true, "printers": [...]}; on a gateway that is not Windows it answerssupported: falsewith the reason and an empty list. - On a gateway that is not Windows, saving
OS_PRINTERis refused with “OS printer transport is supported on Windows gateways only”. The page cannot grey the option out, so the refusal comes when you press Save. - The page does not check on Save that the host is filled in for
NETWORKor the name forOS_PRINTER(it has no rule that depends on another field). A printer with the missing value is saved and then does not run; its state andLastErrorsay “Host is required.” or “OS printer name is required.”.
Limits of a USB printer:
- The gateway machine must run Windows, and the printer must be installed on that machine, not on a client. Use the Generic / Text Only driver (the usual choice). The account that runs the gateway service must be allowed to print to it.
- No printer status:
_Status/StateisNoStatus, theStatus/*tags have bad quality,_Infois empty. No online or paper-out state exists. Do not put these tags in alarms. - Sent means accepted by the print queue, not printed.
Queue/LastJobResultsaysOK: sent to the print queue. A printer that is off, out of paper or unplugged may still accept the job into its queue. - A job that fails with “The print queue did not accept the job within 60000 ms … Check the print queue before sending the job again.” can still print later. The module never sends it again by itself; look at the Windows print queue before you send it again, or the label may print twice.
- Raw ZPL that contains
~HS,~HIor^HQis refused for these printers, with a WARN. Templates, the test label, the queue, the job history, the tag trigger and the scripting functions work as for a network printer. - The printer is checked when it connects and every job tells if the queue refused it. A printer that is removed or unplugged later is not noticed until a job fails; Windows normally keeps the queue of an unplugged USB printer.
See the Compatibility chapter for the USB printer limits.
Printers that do not answer ~HS or ~HI
Printing does not depend on the status answers. A ZPL-compatible printer that never answers ~HS or ~HI still
connects: Status/* stays bad, _Info stays empty, _Status/ProtocolErrors counts, and one WARN says so.
Status/Attention then stays true for good: leave it out of your alarms for such a printer.
After three ~HS polls in a row without a complete answer (no answer, or fewer than three strings) Status/Attention
turns true and one WARN is logged. The connection is not dropped and not reopened: according to Zebra’s ZPL guide a
printer sends no ~HS answer at all while it is in MEDIA OUT, RIBBON OUT, HEAD OPEN, REWINDER FULL or HEAD
OVER-TEMPERATURE, so silence on an open connection means “look at the printer”, not “dead connection”. The module
reconnects only when the connection closes or a write fails. A printer that is switched off or unplugged sends no
close; the module turns on TCP keepalive (10 s idle, then 5 s probes, 3 tries) so the operating system reports
the dead connection after about 25 s where the OS supports these settings (otherwise after the OS default, up to
about 15 minutes on Linux). Status/Attention returns to false and one INFO is
logged at the next complete answer. Consequence: on a printer PaperOut, HeadOpen, RibbonOut and TempError
may seldom be seen set, because the printer is silent in those states; treat Status/Attention (with
Status/* bad) as the alarm.
Raw ZPL is off by default
Each printer has Allow raw ZPL (under Safety), off by default. While it is off, every raw send to that printer is refused with a WARN. Turn it on only for printers where scripts may send arbitrary ZPL.
The module sends only ~HI (once per connection), ~HS (every poll) and the ZPL you ask it to print. It refuses raw
ZPL that contains a known printer setup command: network and wireless setup (^NB ^NC ^ND ^NI ^NN ^NP ^NS ^NT ^NW ^NR ^WA ^WE ^WI ^WL ^WP ^WR ^WS, also with ~), restore or reset (^JU..., ~JR), downloads (~DY ^DY ~DU), changes
of the command prefix (^CC ^CT ^CD, also with ~), and any line that starts with ! or { (printer settings
commands in SGD and JSON form). This check is a guard against mistakes, not a security boundary. The check
can refuse a label whose
text or binary graphics happen to look like one of these. Whoever may send raw ZPL can send anything else the printer
accepts as ZPL.
A print job has no answer on the wire. “Sent” means the bytes left the gateway, not that the label came out. Check
Status/* for paper, ribbon and head. If the printer stops reading for a minute (or the printer timeout, if longer)
while a job is sent, the connection is closed and the job fails with that reason; the printer may then hold a partial
label.
Label templates
A template has a name, a description and a ZPL body with ${field} placeholders, for example:
^XA^CI28^FO50,50^A0N,40,40^FDPart ${part}^FS^FO50,120^BCN,60,Y,N,N^FD${serial}^FS^XZ
The body must contain ^XA and ^XZ. A template is checked when it is saved and refused, with the reason, if it holds a
printer setup, reset or download command (same list as raw ZPL above) or a placeholder anywhere except inside field
data (^FD or ^FV): a position, a barcode setting or a command name cannot be made safe, so ^FO${x},10 is refused.
Inside a barcode or a ^FB block the characters of a value still have their meaning for that field type (for example
the invocation codes of Code 128 or a \& line break), so free text typed by operators can change what a barcode
holds; the value cannot, however, start a printer command. A template with more than one label (^XA twice) can only
be printed with one copy. Placeholder names are letters, digits, _, . and -, starting with a letter. Names of templates are letters, digits,
space, ., - and _, at most 64 characters.
Field values cannot become commands. The module writes every value with ^FH hex escaping: ^, ~, _, \,
control characters and every non-ASCII character are sent as _XX (UTF-8 bytes), so a value such as ^XZ^XA or ~JR
prints as plain text. If the field has no ^FH before its ^FD, the module adds one (and then also escapes a literal
_ in that field’s own text). If you wrote ^FH yourself, with the default _ or another symbol such as ^FH\, it is
used as written. For accented letters or other non-ASCII text, put ^CI28 (UTF-8) in the template.
Templates are managed through the gateway’s web routes (the module has no page for them: the shared configuration page has no multi-line field). Use a gateway web UI session with write permission. Every change is written to the gateway’s configuration resources before it is accepted; if that fails, the change is refused and nothing changes:
Request (under /data/zpl/config/) |
What it does |
|---|---|
GET templates |
Lists the templates with the field names each needs |
PUT templates/<name> with {"body": "...", "description": "..."} |
Adds or replaces a template |
DELETE templates/<name> |
Deletes it |
GET templates-export |
Returns {"json": "..."}, the export of all templates |
POST templates-import with {"json": "..."} |
Imports an export, all or nothing; templates of the same name are replaced |
Every change is logged at INFO with the user. Template printing does not need Allow raw ZPL: the ZPL comes from a stored, checked template.
Images in labels
The module turns a PNG or JPEG into a ZPL graphic field (^GFA) in black and white. You can use it in two ways: store
the image on the gateway and use it in a template, or convert it in a script.
What the conversion does. Transparent areas become white. The image is made gray (weights 0.299 red, 0.587 green,
0.114 blue) and scaled to the size you ask for by averaging the pixels each dot covers. Then it is made black and white
by one of two methods: floyd-steinberg (default; spreads the rounding error to the neighbouring dots, so a photo keeps
its shades) or threshold (a dot is black when the gray value is below the threshold, default 128; sharp edges, best
for logos and line art). invert swaps black and white. The data is written in the run-length form of the ZPL II guide
(a row that equals the one before is one character, a run of the same hex digit is a count and the digit); compress
set to false writes plain hex.
| Setting | Meaning | Default |
|---|---|---|
width, height |
Size of the graphic in printer dots. One of them alone keeps the proportions; both stretch the image to that size; neither keeps the image’s own pixel size | image size |
dither |
floyd-steinberg or threshold |
floyd-steinberg |
threshold |
1 to 255, used by threshold |
128 |
invert |
Swap black and white | false |
compress |
Run-length form | true |
Limits. Every limit is refused with a message that says what to change; nothing is cut off or shrunk without telling
you. Only PNG and JPEG are read, whatever the file is called (a GIF, a BMP or a JPEG saved in CMYK is refused: save it
as an RGB or gray PNG). The file is at most 5 MiB and 8,000,000 pixels. The graphic is at most 4096 dots on a side and
400,000 bytes of bitmap (ceil(width / 8) * height; for example 1600 x 2000 dots). The gateway stores at most 100
images and 30 million characters of graphic data in total. Pick the width from your printer’s dots per inch: a 4 inch
wide label at 203 dpi is 812 dots.
Stored images in templates. Upload an image once; the module converts it with the size and settings you give and
keeps only the converted graphic, as the gateway’s configuration (one resource per image, in backups). A template uses it
where the ^GF command goes, and the ^GF command then holds nothing else:
^XA^FO20,20^GF${asset:Logo}^FS^FO20,200^A0N,40,40^FD${part}^FS^XZ
The module replaces ^GF${asset:Logo} by the stored ^GFA,... command when the label is printed. The name matches
without regard to letter case. A template that names an image is saved even if the image is not there yet; printing it
then fails with “Template X uses the image Logo, which is not stored on this gateway. Upload it first.” and nothing is
sent. ${asset:Name} anywhere else (in ^FD, in a position, with other text in the ^GF command) is refused when the
template is saved. A field value that looks like a reference stays plain text. An image that a template uses cannot be
deleted until the template is changed.
Images are managed through the gateway’s web routes, like templates (the shared configuration page cannot upload a file). Use a gateway web UI session with write permission:
Request (under /data/zpl/config/) |
What it does |
|---|---|
GET assets |
Lists the images: name, description, size in dots, bitmap bytes, whether compressed, and the templates that use each (no graphic data) |
PUT assets/<name> with {"image": "<base64 of the file>", "width": 300, "dither": "threshold", "description": "..."} |
Converts and stores an image; only image is required, the other fields are the settings in the table above. Answers with the size in dots and bitmap bytes |
DELETE assets/<name> |
Deletes an image no template uses |
Image names follow the template name rules (letters, digits, space, ., -, _, at most 64 characters). Every change is
logged at INFO with the user and the size, a refusal at WARN with the reason; the image data is never logged. The base64
text may contain line breaks and nothing else outside the base64 alphabet.
In a script. system.innorobix.zpl.imageToZpl(image, width=0, height=0, dither="floyd-steinberg", threshold=128, invert=False, compress=True) takes the bytes of the file (for example from system.file.readFileAsBytes, or
base64.b64decode) and returns a dictionary: zpl (the ^GFA,... command), width, height, bytesPerRow,
totalBytes and compressed. Put the command after ^FO in a label you send with printRaw (needs Allow raw ZPL),
or convert once and upload with the route above. The call does not print and does not change any setting.
png = system.file.readFileAsBytes("C:/labels/logo.png")
g = system.innorobix.zpl.imageToZpl(png, width=300, dither="threshold")
zpl = "^XA^FO20,20" + g["zpl"] + "^FS^XZ"
system.innorobix.zpl.printRaw("Dock1", zpl)
A printer has limited memory: a large graphic can fail on the printer, which the module cannot see. Print a sample label with the image on your printer and look at it before production.
GS1 check digits, SSCC and GS1-128 barcodes
Four script functions build and check GS1 values. They never repair a value: a wrong or unsupported input raises an error that says what is wrong, and a wrong check digit is never written silently. Pass numbers as text so that leading zeros stay (a Python number would lose them).
| Function | Result |
|---|---|
gs1CheckDigit("0950110153000") |
The check digit as text ("3"). Takes 7, 11, 12, 13 or 17 digits without the check digit (GTIN-8, GTIN-12, GTIN-13 or GLN, GTIN-14, SSCC) |
gs1IsValid("09501101530003") |
True when the key has the right check digit (8, 12, 13, 14 or 18 digits); False for anything else |
gs1Sscc("0614141", 123456789, extension=3) |
An SSCC-18: the extension digit, your GS1 company prefix, the serial reference padded with zeros so that these three make 17 digits, and the check digit: "306141411234567891" |
gs1Barcode("(01)09501101530003(17)250101(10)ABC123") |
A dictionary for a GS1-128 barcode, see below |
SSCC. The company prefix is your own GS1 company prefix, given as text, 4 to 12 digits; the module does not know or check that it is yours. The serial reference is digits only (a Python number is accepted) and at most 16 minus the length of the prefix; the extension digit is 0 to 9 and defaults to 0. You are responsible for never reusing a serial reference: the module keeps no counter.
GS1-128. gs1Barcode takes the data as text with the application identifiers in round brackets, or as a list of
(identifier, value) pairs when a value must contain brackets. It checks every element and raises an error naming it:
the identifier is known, the length and characters are right (GS1 character set: letters, digits and ! " % & ' ( ) * + , - . / : ; < = > ? _, no space), the check digit of 00, 01, 02, 410 to 417 and 8018 is right (the message tells which
digit it should be), a date (11, 12, 13, 15, 16, 17) is a valid YYMMDD (day 00 means the end of the month), no
identifier is given twice, and the data is at most 48 characters including identifiers and separators. The supported
identifiers are 00, 01, 02, 10, 11, 12, 13, 15, 16, 17, 20, 21, 22, 240, 241, 242, 243, 250, 251, 254, 30, 310n to 316n,
320n to 329n, 330n to 337n, 340n to 349n, 350n to 357n, 360n to 369n, 37, 400, 401, 403, 410 to 417, 420, 422, 424, 7001,
7002, 710 to 714, 8005, 8006, 8018, 8020 and 90 to 99; others are refused.
The result has zpl, the text for ^FD with the start code, the FNC1 characters and the code-set changes written as ZPL
invocation codes (>; or >: start code C or B, >8 FNC1, >5 and >6 switch to code C and B, >0 a literal >),
text (the data with brackets, for a text line) and elementString (what a scanner reports, without FNC1). An FNC1
separator follows a value of variable length when another element follows, and a fixed-length value whose identifier is
not on the standard’s list of predefined lengths.
Use it through a template field, which leaves > and ; as they are:
^XA^FO50,50^BCN,120,N,N,N^FD${code}^FS^FO50,190^A0N,30,30^FD${text}^FS^XZ
g = system.innorobix.zpl.gs1Barcode("(00)" + system.innorobix.zpl.gs1Sscc("0614141", serial, 3))
system.innorobix.zpl.print("Dock1", "Pallet", {"code": g["zpl"], "text": g["text"]})
Keep the last two ^BC parameters (UCC check digit, mode) at N so the printer adds nothing of its own. The module
makes no claim that a printed barcode meets any GS1 requirement beyond the checks listed here: print a sample label and
scan it with the scanner you use before production.
Scripting
Gateway scope only: the functions do not exist in the Designer script console or in Vision clients. Test them in a gateway event script or a Perspective session script. For example in a gateway event script or a Perspective session script:
job = system.innorobix.zpl.print("Dock1", "PartLabel", {"part": "A-100", "serial": "SN0001"}, 2)
system.innorobix.zpl.printRaw("Dock1", "^XA^FDtest^FS^XZ") # only if Allow raw ZPL is on
status = system.innorobix.zpl.getStatus("Dock1") # dictionary, see below
printers = system.innorobix.zpl.listPrinters()
templates = system.innorobix.zpl.listTemplates()
images = system.innorobix.zpl.listAssets() # stored images, see "Images in labels"
imageToZpl, gs1CheckDigit, gs1IsValid, gs1Sscc and gs1Barcode are described under “Images in labels” and “GS1
check digits, SSCC and GS1-128 barcodes”. Their refusals are raised as errors in the same way as the print calls, and
each refusal is one WARN in innorobix.zpl.graphics or innorobix.zpl.gs1, once per reason every 5 minutes.
print(printer, template, fields, copies=1, requestedBy=None) and printRaw(printer, zpl, requestedBy=None) (keyword
arguments work, for example copies=2) return the job ID when the job is in the
printer’s queue; they do not wait for the printer. A call that cannot be queued raises an error whose message says why:
unknown printer or template, a field the template needs that is missing (a field with value None prints empty), raw
printing off, refused ZPL, copies outside 1 to 1000, or a full queue. copies above 1 adds ^PQ<n> before the last
^XZ; a template that has its own ^PQ can only be printed with one copy.
The error is a Java exception, for example java.lang.IllegalArgumentException for an unknown printer or a missing
field. In the gateway’s Jython 2.7 a plain except Exception: does not catch it (the
script ends with the traceback and an HTTP 500 from WebDev). A printer that is switched off, not connected or not
licensed may raise another Java exception class; catching java.lang.Exception covers them all:
from java.lang import Exception as JavaException
try:
system.innorobix.zpl.print("Dock1", "PartLabel", {"part": "A-100"})
except (Exception, JavaException), e:
system.util.getLogger("labels").warn("Print refused: %s" % e)
getStatus returns name, state, connected, lastError, ready, paperOut, ribbonOut, headOpen, paused, bufferFull, tempError, queueLength; a flag is None while the last ~HS answer is not known. listPrinters returns name, host, port, enabled, description, state, connected; listTemplates returns name, description, fields.
Ignition does not tell a module which user runs a gateway script. Jobs from scripts are logged with the text “gateway
script (user not reported by Ignition)” and the name of the calling thread. Pass requestedBy (a person, screen or
project) to have it logged next to that text as “caller says”; the module cannot check it, so treat it as a note by the
script author, not as proof.
Print queue
Every printer has a queue. Jobs are sent in the order they were accepted, one at a time. Two settings per printer (group Queue): Maximum queue length (jobs) (default 100 jobs, counting the one being sent) and Queue timeout (s) (default 300 s). A queue also holds at most 32 MiB of ZPL in all; a job that would exceed it is refused like a full queue.
- A job that does not fit is refused at once with “The queue of printer … is full”.
- A job that has waited longer than the timeout fails with that reason instead of printing late. Waiting jobs are checked when a job is accepted or finishes, so a job fails at the latest when the job before it ends.
- A printer that is not connected fails a job at once with the reason; the module does not hold labels for later, so a label is never printed minutes after the part it belongs to.
- A printer that is disabled, not licensed, beyond the number of printers your licence allows, or whose saved
settings cannot run has no queue at all: a print call to it is refused with an
error that says so, and a trigger on it prints nothing. The refusal is a warning in the gateway log; it does not
appear in the job history. The
Queue/*andCounters/*tags still exist for such a printer, withLength0 and a Bad quality (Disabled or Not connected) until it runs. - A failed job does not stop the jobs behind it.
- Printed means the printer reported nothing left of the job, not that the label reached the product. Raw port
9100 has no acknowledgement, so after every job the module asks
~HSand waits for the answer (or for the connection to close). If the connection is cut or reset before or right after the last bytes, the job fails with the reason (“The printer closed the connection right after the job was sent”). An answer that arrives late to an earlier~HSis not accepted for this check: after an unanswered~HSthe module waits until the line is quiet (up to 0.5 s) before it asks again. See “Print confirmation” below for whatPrintedandFailed: Outcome unknownmean. Where a missing label matters, check the printer’sStatus/*tags and your own count of labels printed. - A job that is cut in the middle fails with the reason. The printer may hold the first part of that label; the module does not send any command to clear it (that would be a configuration command). The printer may drop or keep that partial label when the connection closes; print one test label after a fault (Compatibility chapter).
Tags: Queue/Length (jobs waiting plus the one being sent), Queue/LastJobId, Queue/LastJobResult (Printed, OK
or Failed: reason), Queue/LastJobTime, Counters/JobsOk (jobs that ended Printed or OK), Counters/JobsFailed.
The counters start at 0 when the module starts. A job that waited longer than the queue timeout fails; the queue is kept
in memory only, so jobs that are still waiting when the module or the gateway restarts are not printed afterwards. Saving a printer’s settings restarts the printer: jobs waiting at that moment fail with “stopped”, and the
counters carry on.
Job history
Every printer keeps its last 200 jobs in memory (lost when the module restarts) with the job ID, time, Printed, OK or Failed: reason, size, description (template name, never the label content) and who asked. Newest first:
Request (under /data/zpl/config/) |
What it does |
|---|---|
GET printers/<name>/history |
Returns {"jobs": [...]} with jobId, endedAt, ok, result, description, requestedBy, bytes |
The history is not part of the saved configuration (the gateway’s configuration resources hold only printers and
templates) and is not moved to resources: a job record is not configuration. For a history that survives a restart store
the records yourself, see “Storing records” below. The in-memory history survives saving the printer’s settings and goes
when the printer is deleted. A tag trigger that fired but could not print (template missing, a field tag without a good
value, queue full) appears with job ID - and Failed: reason, so a lost label can be found.
Storing records
The module does not write to a database. It shows every finished job as a record in the printer’s LastJob tag folder, and
storing it is done in Ignition with your own table.
| Tag | Content |
|---|---|
Printer |
The printer’s name |
JobId |
Job ID, or - for a trigger that never became a job |
Description |
Template name and size, never the label content |
RequestedBy |
Who asked, as in the log |
Bytes |
Size of the ZPL, 0 when nothing was queued |
Ok |
True when the job was sent |
Result |
Printed, a text that starts with OK (a printer that cannot confirm, or an OS printer: OK: sent to the print queue), or Failed: reason |
Time |
When the job ended |
Record |
The whole record as one JSON text with the keys printer, jobId, description, requestedBy, bytes, ok, result, time |
Use Record to store a job. The module writes the eight single tags first and Record last, in one update. A script
that reads only the new value of Record always gets one complete job, even when two jobs end within milliseconds of each
other. A script that reads the single tags when it runs can see a mix of two jobs on a fast line, because Ignition does not
hold the module’s writes together for a reader. Use the single tags for displays, not for storing.
Time is the time the job ended. If a job ends in the same millisecond as the one before, the module writes the time 1 ms
later, so Time and Record change for every job; the time can differ by a few milliseconds from the time in the
gateway log line of the job. There is no counter tag. The tags keep the last record only, so a gateway restart shows an
empty record until the next job.
Quality. The LastJob tags have the quality of the printer’s other data tags. When the printer disconnects (switched
off at night, network down, or a restart after you saved a change) they turn Bad_NotConnected and keep the last record’s
values, and they turn Good again with the next job, not at the reconnect. A Bad quality there does not mean the record is
damaged. A script must act on a changed value of Record, not on the quality alone; the script below ignores a change that
has the same value as before.
Gateway tag change script (recommended). In the Designer, open Gateway Events, Tag Change, add the tag path
[ZPL]Dock1/LastJob/Record and paste this as the script. It is the body of the script, not a function:
if not initialChange and newValue.quality.isGood() and newValue.value \
and (previousValue is None or previousValue.value != newValue.value):
r = system.util.jsonDecode(newValue.value)
system.db.runPrepUpdate(
"INSERT INTO my_label_jobs (printer, job_id, description, requested_by, bytes, ok, result, ended_at) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
[r['printer'], r['jobId'], r['description'], r['requestedBy'], r['bytes'], r['ok'],
r['result'], r['time']],
'MyDatabase')
my_label_jobs and MyDatabase are your own table and database connection; create the table first, with columns of the
types you need (text, integer, boolean or small integer). The time is UTC text such as 2026-01-02T03:04:05.123Z; store it
as text, or convert it with system.date.parse to the format your database column needs. Test the script with one print
before you rely on it. The same body works in a tag event script on a tag of your own, such as an expression tag
{[ZPL]Dock1/LastJob/Record} (use currentValue instead of newValue); the module’s own tags cannot carry scripts.
Transaction group (slow lines only). A transaction group needs the SQL Bridge module. It runs on its execution rate
(1 s by default) and writes at most one row per run, so two jobs that end within one interval give one row and the other
is lost without an error. Use it only when jobs are seconds apart, and set the execution rate below the shortest time
between two jobs. In the Designer make a Standard group on your own table, add the LastJob tags as items (tag provider
ZPL, folder = the printer’s name), use a trigger on a change of LastJob/Time as your Designer offers it, and map each
item to a column. The group reads the single tags, so on a fast label line it can read a mix of two jobs: use the script.
Print confirmation (network printers)
After a job is sent, the module asks the printer ~HS until the printer reports no format in its receive buffer, no
labels remaining and no format being printed, and none of paper out, ribbon out, head open, paused or a temperature
error. Then Queue/LastJobResult is Printed. This is what the printer reports about its own buffer. It does not say
that the label was applied, that it is readable, or that it reached the product.
Printed needs evidence that the printer took the job: at least one ~HS answer after the job must show a format in
the buffer, a label remaining or a format printing. If every answer in the first two seconds says “idle”, the module
cannot tell a label that printed quickly from one the printer never counted, so the result is Failed: Outcome unknown.
Check the printer’s own display and, if your printer prints faster than the module can see, set the wait to 0.
| Result | Meaning | Send the job again? |
|---|---|---|
Printed |
The printer reports nothing left of the job. | No. |
Failed: Outcome unknown: ... |
The job was sent, but the printer did not confirm: it still reported work after Print confirmation wait (s) without any change, reported a fault, never showed the job as buffered or printing, sent no ~HS answer twice in a row (a printer that is out of labels or ribbon, has the head open or is too hot sends none), or the connection ended during or after the job. The label may have printed, may still print, or may be partial. |
Only after you looked at the printer. |
Failed: Not connected., Failed: Job ... waited more than ... s in the queue ... and was not printed., a refusal |
Nothing was sent. | Yes. |
OK |
Print confirmation wait (s) is 0: the bytes were sent and nothing more is known. | Not applicable. |
The module never sends a job a second time. It does not retry after Failed, after a reconnect or after the printer
comes back. A Failed: Outcome unknown job that you send again may print twice. The wait restarts whenever the printer’s
counts change, so a long batch is not cut off while it is still printing. The default is 60 seconds without progress;
0 turns the confirmation off. A printer that never answers ~HS cannot be confirmed: every job on it ends
Failed: Outcome unknown: ... (after up to about three answer timeouts) until you set the wait to 0 for it.
While a job is being confirmed the printer’s connection is busy with it: the next job is sent only after the
confirmation ends, so one label at a time is in the printer (each confirmation answer is polled every 200 ms). The
Status/* tags follow the ~HS answers read during the confirmation; the extended tags (~HQES, odometer, printhead)
are updated again after the job. On a printer that was saved before print confirmation existed the wait is 0 after the
upgrade, so nothing changes until you set it. A new printer starts with 60.
A failed job reads Failed: <reason> (capital F, lower case rest). A script or expression that compares the start of
Queue/LastJobResult or the history text with FAILED must compare with Failed.
A USB printer (Windows print queue) cannot be asked, so its result stays OK: sent to the print queue.
Jobs that wait longer than the queue timeout fail. The queue is kept in memory only: after a restart of the module or the gateway nothing that was waiting is printed.
Extended status and alerts (network printers)
With Extended printer status on (the default) the module also asks the printer, read-only:
~HQESat every poll: the error and warning flags. They fillStatus/HasError,Status/HasWarning,Status/ErrorFlags,Status/WarningFlagsand one boolean tag for each named error flag (for exampleStatus/PrintheadOverTemp). Warning bits have no named tag yet: their bit order is not known to the module, so useHasWarningand the rawWarningFlagsword. Use these tags for your own Ignition alarms; the module has no alarm system of its own. A new alert is logged once as a WARN, and one INFO says when it is gone.~HQODand~HQPHabout once a minute: the odometer and the printhead life history, in theOdometer/*andPrinthead/*tags. The unit is the printer’s own (theOdometer/Unittag shows the text it sent).
A printer that does not answer one of these queries is asked twice and then left alone until the connection is made
again; its tags stay bad and one INFO says so. The Status/* tags of ~HS are not affected. The layout of these answers
is read from the vendor’s description; check the tags against your printer’s own display before you build alarms on them.
Turn the setting off for a printer that should receive only ~HS and ~HI.
Test label
POST /data/zpl/config/printers/<name>/test-label (gateway web UI session with write permission and the CSRF header)
queues a test label: printer name, the time, a text line and a Code 128 barcode of the printer name. It returns
{"jobId": "..."}. It does not need Allow raw ZPL, sets no media, speed or darkness, and logs at INFO with the user.
A button for it on the printer page is not built yet (it needs a change to the shared config page).
Tag-triggered printing
Group Tag trigger on the printer form:
- Trigger tag path: a boolean tag, for example
[default]Line1/PrintNow. Empty means no trigger. - Trigger template: the template to print.
- Trigger field mapping: which tag fills which template field, for example
part=[default]Line1/PartNo;serial=[default]Line1/Serial. Pairs are separated by;, so a tag path cannot hold;. A field the template needs and the mapping lacks makes the print fail with that field’s name.
A change of the trigger tag from false to true prints one label with the values the field tags have at that moment (one
copy). A tag that stays true prints nothing more; it must go false and true again for the next label. Numbers other than 0
and the text true or 1 count as true. The tag is read every 250 ms, so a pulse shorter than that can be missed: hold
the tag for at least half a second.
- A tag that is already true when the module starts or when the printer’s settings are saved does not print.
- A trigger tag or field tag with bad quality does not change the state. If a field tag has bad quality at the moment of the edge, nothing is printed and the edge is not retried (a label printed late is worse than a lost one). One WARN is logged (once per printer every 5 minutes) and the history shows the failure.
- A trigger tag that does not exist (a typo in the path), whose provider is down or whose quality is bad logs one WARN (once per printer every 5 minutes) saying so, and one INFO when it has a good value again. Nothing prints in between.
- If the printer is not connected, is paused, out of labels or ribbon, or has the head open at the moment of the edge, no
label is queued: the edge is lost, one WARN is logged and the history shows
Failedwith the reason. Labels are not held until the printer is back, because they would print late for parts that have left. - Each trigger is read on its own, so a slow tag provider delays only the printers that use it.
- Trigger prints are ordinary jobs: same queue, history and counters. They are logged as
tag trigger <tag path>. - A trigger tag without a template, or a broken saved mapping, leaves the trigger off with a WARN; the printer itself
keeps running. A mapping that is not written
field=tag pathis refused when you press Save.
PLC handshake for tag-triggered prints
Group PLC handshake on the printer form. For a label printed by the tag trigger the module can write the result back to four tags, so the PLC does not have to guess:
- Handshake tag: done: set to true when the job ended
Printed(orOKwhen the confirmation wait is 0). - Handshake tag: failed: set to true when the job failed, ended with an unknown outcome, or no label was queued at all (a lost edge).
- Handshake tag: job ID: the job ID, empty when no job was queued.
- Handshake tag: reason:
PrintedorFailed: reason.
Leave a field empty to skip that tag. At the edge of the trigger the module sets done and failed to false and the reason to empty, before the label is queued; the job ID is written with the result. The tag values of the template fields are read once, at the edge. The tags are written only when Allow writes is on for the printer (on for a new printer; a printer saved before this setting existed has it off). Every write is logged at INFO with the printer, the tags and the values. A handshake tag that cannot be written is one WARN, rate-limited, and never changes the job. Only prints made by the trigger write the handshake; a script print does not. Handshake tags must be Ignition tags you create yourself (for example memory tags or tags that a PLC driver maps); the module does not create them. Test the handshake in your environment before production use.
The module writes these tags with the gateway’s system security context, so tag write permissions of the tag provider do not apply to them. Only the four paths you typed are ever written, and only with Allow writes on. A tag of the wrong type for the value (for example a Boolean written to an integer PLC tag) or a path that does not exist is one WARN that names the tags and values; the job is not changed by it.
Wait for done or failed before the next trigger edge. When a new edge arrives while the job of the previous edge is
still being confirmed (this can take seconds), the new edge resets the four tags and the older job’s result is not
written, so a PLC never reads the previous label’s result as the new one. The module logs one WARN naming the job whose
result was dropped. The PLC then sees only the result of the newest edge, and the older job’s result is still in
Queue/LastJobResult and the history.
Logs
The Troubleshooting chapter says what to look for in these logs.
Logger innorobix.zpl.trigger (trigger on or off, edge problems at WARN, rate-limited), innorobix.zpl.device (connection, one WARN per fault then a summary every 5 minutes),
innorobix.zpl.print (each job at INFO with job ID (start time and counter, unique across restarts), printer, size and who asked, never the label content; refusals,
full queue and failed jobs at WARN, once per printer, caller and reason every 5 minutes), innorobix.zpl.config
(template and image changes), innorobix.zpl.graphics and innorobix.zpl.gs1 (script calls that were refused at WARN,
each conversion or build at DEBUG). Every line names the printer or template.
Generated from the module's documentation for version 8.13.0. Questions: contact us.