398. How to kick open the cash drawer of a point of sale system?

Problem

This is in response to duez1981's post titled 'php-gtk2 point of sale system'.

He is writing a point-of-sale (POS) system using PHP-GTK2, and he wants to know how to kick open the cash drawer as shown below.

How to kick open the cash drawer of a point of sale system?


Solution

  • For a standard cash drawer, there's a physical cable that runs from the cash drawer and plugs into the receipt printer.
  • To open the drawer, you issue a command to the printer. The printer will send a signal to the cash drawer that kicks open the drawer.
  • For a standard epson receipt printer such as the Epson TM-T88III receipt printer, the command is:
    fwrite($handle, chr(27). chr(112). chr(0). chr(100). chr(250));
  • For other receipt printers, you should be able to find the command in their user's manual. (Try the above code first. Most probably it will work. Receipt printers have been in existence for a long time. They have more or less adopted the same standard.)

Note: To print to a receipt printer, please refer to the article How to interface to receipt printer in a point of sale system?


Sample Code

1   
2   
3   
4   
5   
6   
<?php
$handle = fopen("PRN", "w"); // note 1
fwrite($handle, 'text to printer'); // note 2
fwrite($handle, chr(27).chr(112).chr(0).chr(100).chr(250)); // note 3
fclose($handle); // note 4
?>

Output

 

Explanation

  1. Establish the connection with the receipt printer through PRN. Pkease refer to How to interface to receipt printer in a point of sale system? for more explanations.
  2. Writes to the receipt printer through the file handle.
  3. Kicks open the cash drawer.
  4. Disconnect the printer.

Related Links

Add comment


Security code
Refresh