Frequently Asked
Questions

Smart Label Printer

Interface Specification

Revised February 7, 1993


1. Overview

This document describes the interface between the Smart Label Printer Pro and a host computer system.

2. Description

The Smart Label Printer Pro, or SLP Pro, is a very small printer which is dedicated (as the name implies) to printing labels.

The SLP Pro is actually a bitmapped device that prints all information on the label (including text) as graphic images. The command set is very lean in order to allow the printer to concentrate only on printing and off-load the other functions to the host.

3. Interface

The SLP Pro communicates with the host computer over a serial (RS-232) line. The supplied cable connects the TX, RX, GND, and DSR signals to the printer via a standard RJ11 type (modular telephone) connector. The host end of the cable is intended for DTE connections using either DB-25 or DB-9 connectors. The host communications port is normally configured for 9600 baud, no parity, 8 data bits, and 1 stop bit. Note that the host may change the baud rate to 19,200 or 38,400 by sending a special command to the printer. The printer's baud rate is always set to 9600 baud after power-up and after receiving a reset command.

The primary communication flow is from the host to the SLP Pro. This is because the host must send commands and data, while the SLP Pro sends only XON/XOFF handshaking and an occasional status byte.

The SLP Pro sends a status byte (unsolicited) to the host computer whenever there is a change in its internal copy of the status byte. A status byte can also be requested by sending the CMD_STATUS command to the SLP Pro. Since the status byte is sent automatically whenever it changes, the CMD_STATUS command is rarely used.

Since the time between transmitted data bytes may be as short as 250 microseconds (at 38,400 baud), overruns may occur in the host's UART if two or more data bytes are sent in a rapid "burst". For this reason, the SLP Pro firmware "paces" the transmitted data at intervals of at least 10 milliseconds.

4. Printer Buffer Size

The SLP Pro's input buffer is approximately 500 bytes (about 33 lines of 15 bytes).

5. Handshaking

When the input buffer is almost full (less than 10 bytes free), the printer will indicate a 'buffer full' condition by sending an XOFF character (13h) to the host and setting the DTR signal low.

After the 'buffer full' condition has occurred and the input buffer has been emptied to the point where there are at least 100 bytes free, the printer will send an XON character (11h) to the host and set the DTR signal high.

With a buffer size of 500 bytes, this will keep the buffer at approximately 80% full, but not more than 98% full. Assuming that each printed line requires approximately 15 bytes, that would be enough to print about 28 to 34 lines. Printing at 8 lines/mm and 17 mm/second, the host would have about 200 ms. to refill the buffer.

The SLP Pro is capable of printing at the rate of 136 lines per second (8 lines/mm x 17 mm/second). Assuming that 15 bytes are transmitted per line, the required throughput is 2040 bytes per second. The worst-case is 26 bytes per line (3536 bytes/second) for a 1" wide label and 50 bytes per line (6800 bytes/second) for a 2" wide label. The physical maximum data throughput for the various supported baud rates is as follows:
Baudrate Maximum Throughput
9,600 960 bytes/second
19,200 1920 bytes/second
38,400 3840 bytes/second

Using these figures, it is obvious that the printer and host must be capable of sustaining communications at 19,200 baud with no more than 200 milliseconds of continuous interruption in order to print an "average" label smoothly.

Sustaining this high data rate will demand efficient I/O drivers on the host system. We strongly recommend that the host's serial I/O routines are interrupt-driven.

6. Serial Interface Cable

The standard serial interface cable for the SLP Pro is a four-conductor cable with an RJ11 connector (for the SLP Pro) at one end and an appropriate connector for the host (DB-9 or DB-25 for IBM PC compatibles and DIN for Macintosh) on the other end. This standard cable is equivalent to the cable used for the SLP Plus and SLP 1000 printers.

Optionally, a six-conductor cable may be used to allow hardware handshaking (using the printer's DTR signal).

SLP Pro serial interface cable wiring:

SLP Pro   Host  
Signal Signal DB-9 DB-25
GND GND 5 7
RD TD 3 2
TD RD 2 3
DSR DTR 4 20
DTR DSR 6 6

7. Command codes

The following commands are recognized by the printer:

MNEMONIC HEX CODE DESCRIPTION
CMD_NOP 00 No operation
CMD_STATUS 01 Request printer status
CMD_VERSION 02 Request firmware version
CMD_BAUDRATE 03 nn Change baud rate to nn
CMD_PRINT 04 nn dd ... Print literal (binary) data
CMD_PRINTRLE 05 nn dd ... Print compressed (RLE) data
CMD_MARGIN 06 nn Image offset (in mm from left edge)
CMD_TAB 09 nn Tab nn dots to the right
CMD_LINEFEED 0A Feed label one line (one dot)
CMD_VERTTAB 0B nn Feed label nn lines (dots)
CMD_FORMFEED 0C Feed to top of next label
CMD_DENSITY 0E nn Set print density to nn
CMD_RESET 0F Reset printer
CMD_CHECK A5 Check for correct baud rate

Notes: "nn" represents a single byte parameter

"dd ..." represents a string of data bytes (length = nn)

8. Description of "Immediate" commands

This section describes the commands that are executed immediately after being received by the printer. These commands are NOT placed in the printer's FIFO input buffer.

CMD_NOP (00h) - no operation

This command is ignored by the SLP Pro. CMD_NOP is used primarily to pad a partially transmitted record when the printer needs to be reset.

CMD_STATUS (01h) - request printer status

This command is used to request the status of the SLP Pro. It is normally used only at start-up, when the state of the printer is unknown, or when a global status variable is not implemented. See "Status Byte Definitions" below for a description of the status byte.

CMD_VERSION (02h) - request printer firmware version

This command is used to request the version of the SLP Pro firmware. See "Version Byte Definition" below for a description of the version byte.

CMD_BAUDRATE (03h) - change the printer's baud rate

This command is used to change the printer's baud rate to the value specified by the parameter byte. The parameter byte is defined as follows:

PARAMETER BAUD RATE
0 9,600
1 19,200
2 38,400

The parameter byte must immediately follow the command. An invalid parameter will cause the STAT_BAD_COMMAND bit to be set in the status byte and the baud rate will not be changed. The printer will respond to this command immediately after it is received (i.e. it is not buffered).

After sending this command, the host must not send ANY other data for at least 100 milliseconds to allow the printer enough time to change it's baud rate. During that time, the host should change it's own baud rate to the specified value.

CMD_RESET (0Fh) - reset printer

This causes the printer to reset to the equivalent of a power-up state and send a status byte. This command is normally sent only when the state of the printer is unknown (e.g. during initialization of the host driver program) and after an error occurs.

The printer reset cycle takes at least 100 milliseconds (possibly much longer) to complete, and all commands and data received during that time are ignored. For that reason, the driver program should always wait for the response (status byte) before continuing. If no response is received within 3 seconds, it is safe to assume there is a problem.

Note that even though this command is not normally buffered, it may end up in the buffer if it is sent when the printer is not expecting a command. For example, if the printer receives a CMD_PRINT followed by a record-length parameter of 100, the printer will assume the next 100 bytes are binary data, not commands.

When using interrupt-driven communications, it may be difficult to distinguish commands from data when an immediate reset is desired. In that case, to ensure that the reset command is executed, send a string of CMD_NOPs at least as long as the longest data record before sending the CMD_RESET. This will pad out any partial data records, and extra CMD_NOPs are ignored.

CMD_CHECK (A5h) - check for proper baud rate

This command is used to detect if the printer and the host are communicating at the same baud rate. If the printer receives this command, it always responds with a response byte which has the value of C9h.

9. Description of "Buffered" commands

This section describes the commands that are placed in a FIFO input buffer when received by the printer. The commands are executed in the order that they were received.

CMD_PRINT (04h) - print literal (binary) data

This command is used to print a bitmap on the printer. The most-significant bit of the first data byte will be printed on the left and the least-significant bit of the last data byte will be printed on the right. The command must be followed by the record length (single byte) and the data record. After all of the data bytes are received, the bitmap pattern is printed and the label is advanced vertically one dot. For example:

Byte sent Meaning
04 CMD_PRINT - print literal data
05 data record length (5 bytes)
01 data byte 1
02 data byte 2
03 data byte 3
04 data byte 4
05 data byte 5

The bits of each data byte are translated into an image of eight "dots" (1=black, 0=white), arranged horizontally with the most-significant bit representing the left-most dot. For example, the following commands (values in hex):

04 03 11 11 11

04 03 33 33 33

04 03 77 77 77

04 03 FF FF FF

CMD_PRINTRLE (05h) - print compressed (RLE) data

This command is used to send compressed bitmap data to the printer. The data is de-compressed after reception by the printer and printed in the same manner as data sent with the CMD_PRINT command. See "RLE Compressed Data" below for a description of the compression method used. An example of a CMD_PRINTRLE command follows:

Byte sent Meaning
05 CMD_PRINTRLE print compressed data
05 data record length (5 bytes)
01 data byte 1
02 data byte 2
03 data byte 3
04 data byte 4
05 data byte 5

After de-compression, the bits of each data byte are translated into an image of eight "dots" (1=black, 0=white), arranged horizontally with the most-significant bit representing the left-most dot. For example, the following commands (values in hex):

05 03 4A 0A 4A

05 04 0A 4A 0A 4A

05 03 4A 0A 4A

05 04 0A 4A 0A 4A

CMD_MARGIN (06h) - set left margin

This command is used to set distance from the first dot of the print head to the first dot position on the left edge of the label. This command is used primarily when labels less than 2" wide are used (because narrow labels are centered on the print head). The distance is in millimeters and is determined by the byte sent immediately after the command. For example, the following command (values in hex):

06 0C

would set the left margin to 12mm (for "standard" size labels).

The following table suggests indent values for the various label sizes:

Label Name Label Size (mm) Image Size (mm) Indent
Standard 89 x 28 81 x 24 12mm
Shipping 101 x 54 93 x 48 0mm
Disk 70 x 54 58 x 48 0mm
Euro 89 x 36 81 x 32 8mm

CMD_TAB (09h) - tab to the right

This command is used to move the initial print position to the right. The distance is added to the left margin value and is determined by the byte sent immediately after the command. For example, the following commands (values in hex):

04 02 77 77 ( CMD_PRINT )

09 04 ( CMD_TAB )

04 02 77 77 ( CMD_PRINT )

09 08 ( CMD_TAB )

04 02 77 77 ( CMD_PRINT )

CMD_LINEFEED (0Ah) - move vertically 1 dot

Moves the paper up 1 dot. Commonly used to skip a blank row of dots (instead of sending a CMD_PRINT command with a byte count of zero).

CMD_VERTTAB (0Bh) - move vertically the specified number of dots

Moves the paper up the number of dots specified by the parameter. Commonly used to skip over a blank section of a label (instead of sending several CMD_PRINT commands with byte counts of zero).

CMD_FORMFEED (0Ch) - advance label

Moves the paper up to the top of the next label.

CMD_DENSITY (0Eh) - set print density

Sets the darkness of the print by defining the amount of time that the head is turned for each dot. The command must be followed by one of the following values:

Hex Value Darkness
FC Lightest
FE Medium-light
00 Normal
02 Medium-dark
04 Darkest

WARNING: Other values will produce unpredictable results and may damage the printer!

10. RLE Compressed Data

To reduce transmission time, some data may be compressed using Run-length Encoding (RLE). Since some data in the record may be transmitted more efficiently without compression, there is a provision to have binary data embedded with the RLE data. Each byte in the record will contain either binary data or RLE data.

If bit 7 of a byte is clear (equal zero), the byte contains RLE compressed data. Bit 6 is the color of the run (0 = white, 1 = black), and bits 0 through 5 specify the length (in pixels) of the run. For example:

00001111 prints a run of 15 white pixels

01010001 prints a run of 17 black pixels

If bit 7 is set (equal one), then bits 0 through 6 contain literal binary (bitmap) data.

11. Status Byte Definitions

The status byte always has a base value of 40 hex. The following values may be added to the base value, as appropriate:

Mnemonic Hex value Reset Status condition
STAT_PAPER_OUT 01 No Out of labels
STAT_PAPER_JAM 02 Yes Label is jammed (feed error)
STAT_HARD_ERR 04 Yes General hardware error
STAT_COMM_ERR 08 Yes Invalid command or I/O error
STAT_IDLE 10 No Printer is idle
STAT_UNUSED 20 No (not used)

If the Reset column indicates "Yes," the host should send a CMD_RESET to clear the error.

Examples:

If a label is jammed in the printer, the status value is 42H:

40 base value

+ 02 label is jammed in printer

42

If printer is idle and out of labels, the status value is 51H:

40 base value

01 out of labels

+ 10 printer is idle

51

12. Version Byte Definition

The version byte always has a base value of 80 hex. The firmware version number is added to the base value to produce the response byte which is returned for the CMD_VERSION command. For example, if the firmware version is 5, the version byte would be 85 hex.

Back to the Top