NAME
Device::TLSPrinter - Module for using a TLS barcode printer
VERSION
Version 0.02
SYNOPSIS
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");
DESCRIPTION
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.
FUNCTIONS
General methods
new()
Create and return a new object.
Parameters
type
- specify the type of connection, eitherserial
ornetwork
device
- (mandatory) specify a device name or path to use, or the host and port to connect to (depending on the connection type)
exec_command()
Transmit a command to the printer.
Parameters
cmd
- (mandatory) command string to sendexpect
- if the command expects an answer, indicate the number of characters to read
Attributes
feedback_chars()
Returns true if feedback characters are enabled.
immediate_cmds()
Returns true if immediate commands are enabled.
label_edition()
Returns true if currently in label editing mode.
Immediate commands
ic_printer_reset()
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
ic_printer_status()
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()
ic_toggle_pause()
Pause or resume the current print job. See [TLS-PG] p.9
ic_cancel_job()
Cancel the current print job. See [TLS-PG] p.10
ic_disable_immediate_cmds()
Disable immediate commands. They can be enabled again using sc_enable_immediate_cmds()
. See [TLS-PG] p.10
ic_batch_quantity()
Fetch and return the quantity of label left to print in the current batch. See [TLS-PG] p.10
Example
my ($rc, $qty) = $device->ic_batch_quantity()
System commands
sc_disable_feedback_chars()
Disable feedback characters. See [TLS-PG] p.12
sc_enable_feedback_chars()
Enable feedback characters. See [TLS-PG] p.12
sc_heat_setting_offset()
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
sc_disable_feed_to_cut_position()
See [TLS-PG] p.13
sc_enable_feed_to_cut_position()
See [TLS-PG] p.14
sc_quantity_for_stored_labels()
Set the quantity of labels to print using the current label format. See [TLS-PG] p.14
Arguments
number of labels to print
sc_form_feed()
Feed one label to the top of form. See [TLS-PG] p.15
sc_set_form_stop_position()
Adjust the cutter stop position. See [TLS-PG] p.15
offest in pixels; valid range is -8 to +8
sc_print_last_label_format()
Print the label format currently in memory. See [TLS-PG] p.16
sc_enable_immediate_cmds()
Enable immediate commands. See [TLS-PG] p.16
sc_input_image_data()
Upload an image from the host to the printer. See [TLS-PG] p.17
Arguments
data type,
"A"
for ASCII,"B"
for binaryimage format designation
image name, up to 8 characters long
image data
sc_extended_system_cmds()
Enable extended system commands. See [TLS-PG] p.18
sc_enter_label_formatting_cmd()
Enter label formatting mode. See "Label formatting commands". See [TLS-PG] p.18
sc_set_printer_to_metric()
Set the printer to use the metric system for measurements. See [TLS-PG] p.18
sc_set_printer_to_inches()
Set the printer to use the imperial system for measurements. See [TLS-PG] p.19
sc_set_start_of_print_offset()
Adjust the point where printing starts, relative to the top-of-form position. See [TLS-PG] p.19
Arguments
offset in pixels, valid range is -5 to +99
sc_set_horizontal_align_offset()
Adjust the point where printing starts, relative to the left edge of the label. See [TLS-PG] p.20
Arguments
offset in pixels, valid range is -5 to +99
sc_set_continuous_label_length()
Set the label length for continuous material. See [TLS-PG] p.20
Arguments
label length, valid range is 0.0 to 152.4 mm, or 0.0 to 6.0 inches
sc_clear_all_memory()
Instruct the printer to clear all images from memory. See [TLS-PG] p.21
sc_set_continuous_label_spacing()
Set the label spacing for continuous material. See [TLS-PG] p.21
Arguments
label spacing, in current measurement unit
sc_print_test_label()
Instruct the printer to print a dot pattern test label. See [TLS-PG] p.22
sc_get_touch_cell_data_binary
Fetch and return the touch cell data from the media as binary. See [TLS-PG] p.22
Returns
feedback code
raw cell status as binary
sc_replace_label_format_field
Place new data into format fields. See [TLS-PG] p.24
Arguments
format field number
new string data
sc_get_touch_cell_data_ascii
Fetch and return the touch cell data from the media as ASCII. See [TLS-PG] p.25
Returns
feedback code
raw cell status as a string
decoded cell status as a hash
Example
my ($rc, $raw, %stat) = $device->sc_get_touch_cell_data_ascii
sc_firmware_version()
Fetch and return the firmware version. See [TLS-PG] p.25
sc_memory_information()
Fetch and return a directory listing of images in printer memory. See [TLS-PG] p.25
sc_delete_file()
Instruct the printer to remove a specific file from memory. See [TLS-PG] p.26
Arguments
file type,
"G"
for imagefile name
sc_pack_memory()
Instruct the printer to reclaim all storage space associated with deleted files. See [TLS-PG] p.27
Label formatting commands
lc_set_format_attribute()
See [TLS-PG] p.30
Arguments
mode
lc_set_column_offset()
See [TLS-PG] p.31
Arguments
column offset
lc_end_label_formatting_and_print()
See [TLS-PG] p.31
lc_set_row_offset()
See [TLS-PG] p.31
Arguments
row offset
lc_end_label_formatting()
See [TLS-PG] p.32
lc_increment_prev_numeric_field()
See [TLS-PG] p.33
Arguments
fill char
increment amount
lc_decrement_prev_numeric_field()
See [TLS-PG] p.33
Arguments
fill char
increment amount
lc_increment_prev_alphanum_field()
See [TLS-PG] p.34
Arguments
fill char
increment amount
lc_decrement_prev_alphanum_field()
See [TLS-PG] p.34
Arguments
fill char
increment amount
lc_set_count_by_amount()
See [TLS-PG] p.35
Arguments
number of labels before incrementing or decrementing
lc_add_field()
See [TLS-PG] p.37
Arguments
rotation, see ROTATION_*
type of field, see TYPE_*
font size / barcode height
row
column
High-level commands
hc_flush_input()
Flush the input buffers. Must typically be used when the printer is power cycled.
hc_upload_label()
Transfer a label onto the printer, optionally asking for immediate printing.
See [TLS-PG] pp.29-43
Parameters
lines
- (mandatory) arrayref of lines describing the labelprint_now
- prints the label now if given a true value; defaults to false
Return
feedback code
CONSTANTS
Device::TLSPrinter
defines the following constants.
Feedback codes
Most system and label formatting commands return the feedback character as result code. See [TLS-PG] pp.12, 47
FC_OK
- no errorFC_SERIAL_TIMEOUT_ERROR
- serial timeout errorFC_COMMAND_ERROR
- command errorFC_MEMORY_FULL_ERROR
- memory full errorFC_IMAGE_ALREADY_EXISTS
- image already exists in memory so it was not storedFC_IMMEDIATE_COMMANDS_ENABLED
- immediate commands enabledFC_OUT_OF_LABELS
- out of labelsFC_PRINTHEAD_OPEN
- printhead openFC_OUT_OF_RIBBON
- out of ribbonFC_BATTERY_CELL_SHORTED
- battery cell is shortedFC_LOW_BATTERY
- low batteryFC_PRINTING_COMPLETE
- printing is completeFC_NO_LABEL_FORMAT_ERROR
- did not print because no label format has been givenFC_MEMORY_READ_ERROR
- error reading memory touch cell on mediaFC_MEDIA_CHANGED
- media has changedFC_PRINTHEAD_TOO_HOT
- printhead is too hotFC_LABEL_ERROR
- error building labelFC_FIELD_ERROR
- field errorFC_FEED_TO_CUT_COMPLETE
- 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_IMMEDIATE_COMMANDS_DISABLED
- confirms that immediate commands were disabledFC_NOT_IN_LABEL_EDIT_MODE
- a label formatting command was requested while not in label formatting mode
Rotations
Available rotations for lc_add_field()
.
ROTATION_NONE
- no rotationROTATION_90
- rotate by 90°ROTATION_180
- rotate by 180°ROTATION_270
- rotate by 270°
Field types
Available field types for lc_add_field()
.
TYPE_FONT
- fontTYPE_BARCODE_39
- barcode in Code 39TYPE_BARCODE_39_WITH_CHECK
- barcode in Code 39 with check characterTYPE_BARCODE_128
- barcode in Code 128TYPE_IMAGE
- image file
DIAGNOSTICS
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 tonew()
. 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 fornew()
. The function then tries to guess the correct type.
SEE ALSO
[TLS-PG] TLS PC Link Programmer's Guide, http://www.bradyid.com/bradyid/downloads/downloadsPageView.do?file=TLSPCLink_Prog.pdf
BUGS
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.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Device::TLSPrinter
You can also look for information at:
MetaCPAN
Search CPAN
AnnoCPAN: Annotated CPAN documentation
RT: CPAN's request tracker
https://rt.cpan.org/Dist/Display.html?Name=Device-TLSPrinter
CPAN Ratings
AUTHOR
Sébastien Aperghis-Tramoni, <sebastien (at) aperghis.net>
COPYRIGHT & LICENSE
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.