Understanding Printer Command Codes (ESC POS)

Understanding Printer Command Codes (ESC POS)

The printer codes that we use in manager console, known as ESC POS codes, are decimally-represented ASCII characters that are combined to make Epson Print Commands. We use Epson commands by default because SNBC printers are Epson-emulating printers. These codes can be used for other Epson-emulating printers as well. 

*These codes are the main reason we don't use the USB interface for printers - the software hasn't been designed to. These codes are communicated via serial and ethernet, but any USB printer would have to be implemented via a virtual com port. 

The tools you will need to understand this KB are:

The Epson ESC POS code list: 

An ASCII conversion chart, like the one below
Finally a onePOS installation to test with. For this KB, we will be referencing a standard SNBC thermal printer hardware setup.
 
As you can see from the hardware settings, commands are strung together like sentences where the spaces between the numbers are just like spaces between words. 

To begin, let's convert the characters (the "words" in our command sentence) that are put together to make the "Normal Command" from decimal back to ASCII. Using the ASCII conversion chart, we can see that the decimal numbers convert as follows: 
27 - ESC
33 - !
2  - STX

Referencing these ASCII characters to the Epson code list, we can see that we are using the "ESC !" command (further explained here: https://download4.epson.biz/sec_pubs/pos/reference_en/escpos/esc_exclamation.html).

The "ESC !" command tells the printer that we are selecting "the character font and styles (emphasized, double-height, double-width, and underline) together..." In this command format "27 33 n", "27 33" represent the command itself and "n" represents what our desired outcome should be; in this case "2" emphasizes bold text.  

Looking at the "Wide Command," we can see that we are still utilizing the "ESC !" command, but instead of default, we are using "32" which is defined in the command details in the decimal column, to the right of the "Double-Width Mode: On" function. 

Moving on to the "Exit Command", the words we use in this sentence are: 
10 - LF
27 - ESC
105 - i

Whereas "10" is the "Line Feed" function and "27 105" is the "ESC i" or "partial cut" function. The result of this command sentence is us telling the printer "after you print everything as defined above, feed the paper 5 times and cut the paper down to a point." That's how we get all of our chits to string together.

As you can see, sentences are made up entirely of commands or commands and their definable variables. The Drawer command is a pulse command (ESC p) with a formula that controls the specific drawer. The Epson page for the ESC P command (and other commands) lays out the formula in ASCII and decimal. The formula for our drawer in decimal is "27 112 m t1 t2" where "m" is the pin being pulsed to kick out the drawer and the pulse ON time is (t1 × 2 msec) and OFF time is (t2 × 2 msec).


For another example, some of our customers ask for the text to be bigger. Using the "ESC !" function, we could simply change the normal command to "27 33 24." This would make all of their text print bigger. 
Following is a more advanced description of how you get the decimal code for multi-bit functions (where the 24 came from): 
BitDecimal ValueDescription
01Select Font (0 = Font A, 1 = Font B)
12Emphasized (bold)
24Double-strike
38Double-height
416Double-width
532Reserved on official Epson docs (sometimes repurposed)
664Reserved
7128Reserved

1. How Bits Add Up to Decimal

To find the decimal value of n, you add the decimal values of the individual bits you want to turn on:

  • If you want to turn on bit 3 (Double-height), you add 8.
  • If you also want to turn on bit 4 (Double-width), add 16.
  • Together, bits 3 + 4 = 8 + 16 = 24.

Hence, n = 24 (binary 0001 1000) means double-height + double-width.

Similarly:

  • n = 16 alone (binary 0001 0000) sets only bit 4 (Double-width).
  • n = 8 alone (binary 0000 1000) sets only bit 3 (Double-height).
  • n = 32 alone (binary 0010 0000) sets bit 5, which is reserved in the official spec but on many clone printers can mimic double-height or do something else.
    • Related Articles

    • Basic Printer Troubleshooting

      1. Does the Printer have power? Look for a lit LED light. If anything is lit, regardless of color, then the printer has power. If you do have power, continue to step 2. If you do not see a light, make sure the switch is flipped to the on position. If ...
    • Epson Receipt Printer Troubleshooting

      If a printer is an epson, the troubleshooting process is a bit different in some areas. Self Test: Hold the feed button (not labled feed, but is the only other button besides power button), turn power off, turn power on while still holding feed Be ...
    • Understanding and Troubleshooting Printers

      Understanding and Troubleshooting Printers in the onePOS software. Types of Printers Two main types of printers: Impact and Thermal. See below. Impact: Uses an ink ribbon and usually a kitchen printer. Thermal: It does not use an ink ribbon; it can ...
    • Configuring JK-W03 Wifi Printer

      Configuring JK-W03 Wifi Printer Update Firmware Plug printer into PC using USB to USB cable Go to Drive. Search for “SNBC Configuration Tools” Download the Beta Printer Utility V1.66 folder Download the .zip file that has the .jk file needed for the ...
    • Understanding Modifiers

      Here is a video on understanding Modifiers and how they work in the onePOS system.