PHP-GTK2 Newsletter
PHP-GTK2 Tips & Techniques
FREE Newsletter
by kksou
Sample Code 398: How to kick open the cash drawer of a point of sale system? |
|
Written by kksou
|
|
Monday, 24 December 2007 |
|
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.

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
| <?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
|
- Note that this is only 70% of the sample code. You have to be a registered member to see the entire sample code. Please login or register.
- Registration is free and immediate.
- Have some doubt about the registration? Please read this forum article.
Explanation
- 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.
- Writes to the receipt printer through the file handle.
- Kicks open the cash drawer.
- Disconnect the printer.
Related Links
User reviews Average user ratings: 5.0 (from 8 users) Note: You have to be a registered member to leave a comment. Free registration here. |
|
July 29, 2008 1:11am
August 02, 2009 12:11am
December 29, 2009 8:22pm
i need to open cash drawer by php code
can i? ....
February 07, 2010 7:01pm
i have usb printer how can i kick cashdrawer open ???
February 15, 2010 9:09pm
i need to adjust the text on the printer to left or right on the paper what the code to command please help ....
thanks advance
February 15, 2010 11:27pm
Hi Sakda,
Every printer is different. You have to dig out your printer manual and check what's the code to set the left or right margin.
Regards,
/kksou
May 27, 2010 6:29am
i need to reverse feed the receipt printer (EPSON - TMU950) by use code
chr(27).chr(45).chr(48) but not work ...
anyone help or suggest me ? pls.
M.Thanks >>>>
August 09, 2010 12:23am