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.

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   
<?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
  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

User reviews   Average user ratings:    5.0   (from 1 user)
  1. logam sunwares
    July 29, 2008 2:11am

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

Copyright © 2006-2008. kksou.com. All Rights Reserved