Device::TLSPrinter - Module for using a TLS barcode printer
Version 0.02
use Device::TLSPrinter; # use a printer connected to the serial port my $printer = Device::TLSPrinter->new(type => "serial", device => "/dev/ttyS0"); # use a printer connected to the serial port, reusing an # existing Device::SerialPort or Win32::SerialPort object my $printer = Device::TLSPrinter->new(device => $serial_device); # connect to a printer shared by network my $printer = Device::TLSPrinter->new(type => "network", device => "host:port");
This module is a driver for the TLS PC Link thermal labeling printer. It implements the commands from the Datamax Programming Language (DPL) recognized by the TLS PC Link printer.
Create and return a new object.
Parameters
type - specify the type of connection, either serial or network
type
serial
network
device - (mandatory) specify a device name or path to use, or the host and port to connect to (depending on the connection type)
device
Transmit a command to the printer.
cmd - (mandatory) command string to send
cmd
expect - if the command expects an answer, indicate the number of characters to read
expect
Returns true if feedback characters are enabled.
Returns true if immediate commands are enabled.
Returns true if currently in label editing mode.
Reset the printer: return all settings to the default, clear all buffers and the internal RAM. Return the firmware version. See [TLS-PG] p.7
Fetch and returns the printer status. See [TLS-PG] p.8
Returns
feedback code
raw printer status as a string
decoded printer status as a hash
Example
my ($rc, $raw, %status) = $device->ic_printer_status()
Pause or resume the current print job. See [TLS-PG] p.9
Cancel the current print job. See [TLS-PG] p.10
Disable immediate commands. They can be enabled again using sc_enable_immediate_cmds(). See [TLS-PG] p.10
sc_enable_immediate_cmds()
Fetch and return the quantity of label left to print in the current batch. See [TLS-PG] p.10
my ($rc, $qty) = $device->ic_batch_quantity()
Disable feedback characters. See [TLS-PG] p.12
Enable feedback characters. See [TLS-PG] p.12
Adjust the time during which the dots on the printhead are heated. See [TLS-PG] p.13
Arguments
time offset in hundreds of microseconds; valid range is -5 to -5
See [TLS-PG] p.13
See [TLS-PG] p.14
Set the quantity of labels to print using the current label format. See [TLS-PG] p.14
number of labels to print
Feed one label to the top of form. See [TLS-PG] p.15
Adjust the cutter stop position. See [TLS-PG] p.15
offest in pixels; valid range is -8 to +8
Print the label format currently in memory. See [TLS-PG] p.16
Enable immediate commands. See [TLS-PG] p.16
Upload an image from the host to the printer. See [TLS-PG] p.17
data type, "A" for ASCII, "B" for binary
"A"
"B"
image format designation
image name, up to 8 characters long
image data
Enable extended system commands. See [TLS-PG] p.18
Enter label formatting mode. See "Label formatting commands". See [TLS-PG] p.18
Set the printer to use the metric system for measurements. See [TLS-PG] p.18
Set the printer to use the imperial system for measurements. See [TLS-PG] p.19
Adjust the point where printing starts, relative to the top-of-form position. See [TLS-PG] p.19
offset in pixels, valid range is -5 to +99
Adjust the point where printing starts, relative to the left edge of the label. See [TLS-PG] p.20
Set the label length for continuous material. See [TLS-PG] p.20
label length, valid range is 0.0 to 152.4 mm, or 0.0 to 6.0 inches
Instruct the printer to clear all images from memory. See [TLS-PG] p.21
Set the label spacing for continuous material. See [TLS-PG] p.21
label spacing, in current measurement unit
Instruct the printer to print a dot pattern test label. See [TLS-PG] p.22
Fetch and return the touch cell data from the media as binary. See [TLS-PG] p.22
raw cell status as binary
Place new data into format fields. See [TLS-PG] p.24
format field number
new string data
Fetch and return the touch cell data from the media as ASCII. See [TLS-PG] p.25
raw cell status as a string
decoded cell status as a hash
my ($rc, $raw, %stat) = $device->sc_get_touch_cell_data_ascii
Fetch and return the firmware version. See [TLS-PG] p.25
Fetch and return a directory listing of images in printer memory. See [TLS-PG] p.25
Instruct the printer to remove a specific file from memory. See [TLS-PG] p.26
file type, "G" for image
"G"
file name
Instruct the printer to reclaim all storage space associated with deleted files. See [TLS-PG] p.27
See [TLS-PG] p.30
mode
See [TLS-PG] p.31
column offset
row offset
See [TLS-PG] p.32
See [TLS-PG] p.33
fill char
increment amount
See [TLS-PG] p.34
See [TLS-PG] p.35
number of labels before incrementing or decrementing
See [TLS-PG] p.37
rotation, see ROTATION_*
type of field, see TYPE_*
font size / barcode height
row
column
Flush the input buffers. Must typically be used when the printer is power cycled.
Transfer a label onto the printer, optionally asking for immediate printing.
See [TLS-PG] pp.29-43
lines - (mandatory) arrayref of lines describing the label
lines
print_now - prints the label now if given a true value; defaults to false
print_now
Return
Device::TLSPrinter defines the following constants.
Device::TLSPrinter
Most system and label formatting commands return the feedback character as result code. See [TLS-PG] pp.12, 47
FC_OK - no error
FC_OK
FC_SERIAL_TIMEOUT_ERROR - serial timeout error
FC_SERIAL_TIMEOUT_ERROR
FC_COMMAND_ERROR - command error
FC_COMMAND_ERROR
FC_MEMORY_FULL_ERROR - memory full error
FC_MEMORY_FULL_ERROR
FC_IMAGE_ALREADY_EXISTS - image already exists in memory so it was not stored
FC_IMAGE_ALREADY_EXISTS
FC_IMMEDIATE_COMMANDS_ENABLED - immediate commands enabled
FC_IMMEDIATE_COMMANDS_ENABLED
FC_OUT_OF_LABELS - out of labels
FC_OUT_OF_LABELS
FC_PRINTHEAD_OPEN - printhead open
FC_PRINTHEAD_OPEN
FC_OUT_OF_RIBBON - out of ribbon
FC_OUT_OF_RIBBON
FC_BATTERY_CELL_SHORTED - battery cell is shorted
FC_BATTERY_CELL_SHORTED
FC_LOW_BATTERY - low battery
FC_LOW_BATTERY
FC_PRINTING_COMPLETE - printing is complete
FC_PRINTING_COMPLETE
FC_NO_LABEL_FORMAT_ERROR - did not print because no label format has been given
FC_NO_LABEL_FORMAT_ERROR
FC_MEMORY_READ_ERROR - error reading memory touch cell on media
FC_MEMORY_READ_ERROR
FC_MEDIA_CHANGED - media has changed
FC_MEDIA_CHANGED
FC_PRINTHEAD_TOO_HOT - printhead is too hot
FC_PRINTHEAD_TOO_HOT
FC_LABEL_ERROR - error building label
FC_LABEL_ERROR
FC_FIELD_ERROR - field error
FC_FIELD_ERROR
FC_FEED_TO_CUT_COMPLETE - feed to cut complete
FC_FEED_TO_CUT_COMPLETE
The following errors are specific to Device::TLSPrinter.
FC_UNDEF - default value when no feedback was available (typically for immediate commands)
FC_UNDEF
FC_IMMEDIATE_COMMANDS_DISABLED - confirms that immediate commands were disabled
FC_IMMEDIATE_COMMANDS_DISABLED
FC_NOT_IN_LABEL_EDIT_MODE - a label formatting command was requested while not in label formatting mode
FC_NOT_IN_LABEL_EDIT_MODE
Available rotations for lc_add_field().
lc_add_field()
ROTATION_NONE - no rotation
ROTATION_NONE
ROTATION_90 - rotate by 90°
ROTATION_90
ROTATION_180 - rotate by 180°
ROTATION_180
ROTATION_270 - rotate by 270°
ROTATION_270
Available field types for lc_add_field().
TYPE_FONT - font
TYPE_FONT
TYPE_BARCODE_39 - barcode in Code 39
TYPE_BARCODE_39
TYPE_BARCODE_39_WITH_CHECK - barcode in Code 39 with check character
TYPE_BARCODE_39_WITH_CHECK
TYPE_BARCODE_128 - barcode in Code 128
TYPE_BARCODE_128
TYPE_IMAGE - image file
TYPE_IMAGE
Could not load driver %s: no such module
(E) The indicated driver could be be loaded. Please check the argument given to the parameter type given to new().
new()
Invalid value for %s
(E) The value passed to the indicated parameter is not valid. Please check the documentation of the corresponding function for the valid values.
Missing required parameter: %s
(E) The indicated parameter is mandatory, but you didn't provide an arugment for it. Please check the documentation of the corresponding function.
You should specify the connection type
(W) You didn't set the type parameter for new(). The function then tries to guess the correct type.
[TLS-PG] TLS PC Link Programmer's Guide, http://www.bradyid.com/bradyid/downloads/downloadsPageView.do?file=TLSPCLink_Prog.pdf
Please report any bugs or feature requests to bug-device-tlsprinter at rt.cpan.org, or through the web interface at https://rt.cpan.org/Dist/Display.html?Name=Device-TLSPrinter. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-device-tlsprinter at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Device::TLSPrinter
You can also look for information at:
MetaCPAN
https://metacpan.org/module/Device::TLSPrinter
Search CPAN
http://search.cpan.org/dist/Device-TLSPrinter
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Device-TLSPrinter
RT: CPAN's request tracker
https://rt.cpan.org/Dist/Display.html?Name=Device-TLSPrinter
CPAN Ratings
http://cpanratings.perl.org/d/Device-TLSPrinter
Sébastien Aperghis-Tramoni, <sebastien (at) aperghis.net>
<sebastien (at) aperghis.net>
Copyright 2006-2012 Sébastien Aperghis-Tramoni, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Device::TLSPrinter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Device::TLSPrinter
CPAN shell
perl -MCPAN -e shell install Device::TLSPrinter
For more information on module installation, please visit the detailed CPAN module installation guide.