The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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, either serial or network

  • 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 send

  • expect - 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

  1. 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

  1. 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

  1. 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

  1. data type, "A" for ASCII, "B" for binary

  2. image format designation

  3. image name, up to 8 characters long

  4. 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

  1. 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

  1. 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

  1. 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

  1. 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

  1. format field number

  2. 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

  1. file type, "G" for image

  2. file 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

  1. mode

lc_set_column_offset()

See [TLS-PG] p.31

Arguments

  1. column offset

lc_end_label_formatting_and_print()

See [TLS-PG] p.31

lc_set_row_offset()

See [TLS-PG] p.31

Arguments

  1. row offset

lc_end_label_formatting()

See [TLS-PG] p.32

lc_increment_prev_numeric_field()

See [TLS-PG] p.33

Arguments

  1. fill char

  2. increment amount

lc_decrement_prev_numeric_field()

See [TLS-PG] p.33

Arguments

  1. fill char

  2. increment amount

lc_increment_prev_alphanum_field()

See [TLS-PG] p.34

Arguments

  1. fill char

  2. increment amount

lc_decrement_prev_alphanum_field()

See [TLS-PG] p.34

Arguments

  1. fill char

  2. increment amount

lc_set_count_by_amount()

See [TLS-PG] p.35

Arguments

  1. number of labels before incrementing or decrementing

lc_add_field()

See [TLS-PG] p.37

Arguments

  1. rotation, see ROTATION_*

  2. type of field, see TYPE_*

  3. font size / barcode height

  4. row

  5. 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 label

  • print_now - prints the label now if given a true value; defaults to false

Return

  1. 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 error

  • FC_SERIAL_TIMEOUT_ERROR - serial timeout error

  • FC_COMMAND_ERROR - command error

  • FC_MEMORY_FULL_ERROR - memory full error

  • FC_IMAGE_ALREADY_EXISTS - image already exists in memory so it was not stored

  • FC_IMMEDIATE_COMMANDS_ENABLED - immediate commands enabled

  • FC_OUT_OF_LABELS - out of labels

  • FC_PRINTHEAD_OPEN - printhead open

  • FC_OUT_OF_RIBBON - out of ribbon

  • FC_BATTERY_CELL_SHORTED - battery cell is shorted

  • FC_LOW_BATTERY - low battery

  • FC_PRINTING_COMPLETE - printing is complete

  • FC_NO_LABEL_FORMAT_ERROR - did not print because no label format has been given

  • FC_MEMORY_READ_ERROR - error reading memory touch cell on media

  • FC_MEDIA_CHANGED - media has changed

  • FC_PRINTHEAD_TOO_HOT - printhead is too hot

  • FC_LABEL_ERROR - error building label

  • FC_FIELD_ERROR - field error

  • FC_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 disabled

  • FC_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 rotation

  • ROTATION_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 - font

  • TYPE_BARCODE_39 - barcode in Code 39

  • TYPE_BARCODE_39_WITH_CHECK - barcode in Code 39 with check character

  • TYPE_BARCODE_128 - barcode in Code 128

  • TYPE_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 to 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.

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:

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.