3

I have receipt printer Epson TM T-20II, the cash drawer is connect with printer. I would like to detect if cash drawer is open with standart ESC command. It is possible?

Tu Nguyen
  • 31
  • 1
  • 3

1 Answers1

2

You can use the status commands of ESC/POS.

GS a [n] (0x1d 0x61 [n])

Activate/deactivate ASB (Auto Status Back). If bit 0 of [n] is set, the drawer status will be reported by the printer. Other bits activate monitoring of other features (paper sensor, cover sensor etc.) If any ASB mode is activated, the printer will send the status if any of the requested status have changed. The ASB message are always 4 bytes with some fixed bits which can be used to identify the message as an ASB message. Bit 2 of the first byte signals the drawer state.

GS r 2 (0x1d 0x72 0x02)

If you prefer to poll for the drawer status, you can use this command. Here the printer returns one byte, Bit 0 will give you the drawer state.

For more details I recommend the ESC/POS reference which can be found here: https://reference.epson-biz.com/pos/reference/

Ivan Chernykh
  • 41,617
  • 13
  • 134
  • 146