#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0

    Unhappy How to open Cash Drawer that connect to a mini printer on Delphi 7?


    I try to make some point of sales program that can support mini printer and cash drawer. I Have try some code from the others.

    But it's not work correctly.

    var
    f: TextFile;
    begin
    AssignFile(f,'COM1');
    try
    rewrite(f);
    writeln(f,Char(27),Char(112),Char(0),Char(25),Char(250));
    CloseFile(f);
    except
    ShowMessage('Error');
    end;
    end;

    Anyone can help me to fix this?? Please???
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    156
    Rep Power
    3
    From a quick glance I found nothing is wrong with the code (except the weird use of try except). So I think your problem might have caused by either one of these:
    • Your computer's COM1 settings were different with one(s) acceptable by the cash drawer. Making failed communication. So consult your cash drawer's documentation. That approach in using serial port leaving you with default settings. So you have to do the adjustment in Windows Control Panel (System - Device Manager - Ports ...)
    • You might want to try Write instead of WriteLn.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    I use try except because the computer maybe hang if the program can't find the port that i use. so i catch them on some error message.
    I have try use Write, but its nothing happen. cash drawer still wouldn't open. And the printer is connected to COM1.

    Do you have another code to open cash drawer?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    356
    Rep Power
    7
    I've never done worked with a cash register, so excuse me if this doesn't work, but have you tried

    Writeln(f, Chr(27)+Chr(112)+Chr(0)+Chr(25)+Chr(250));

    (Assuming that sequence of characters open the cash register - This link shows a slightly different sequence for an Epson Register)
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    Thx for the code, the cause is setting on the printer.
    There is properties that i must set to use a cash drawer function.

    And the drawer can open now...
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    Guys, how if the mini printer use USB port, i try with the same code above and change the port to USB1 like this :
    AssignFile(f,'USB1');

    But nothing happend, Cash Drawer still close... So Confuse.... .
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    156
    Rep Power
    3
    USB is not actually port. The name already suggested, it's bus for data traffic. You have to know what device at the end of the "port". If a device could be connected to a USB "port" and it claims that you can communicate with it through serial port, then it must have created a virtual serial port upon installation. You need to find this virtual serial port name.

    What I usually done is by opening device manager then look for serial ports under "Ports" node, and then for each serial port I don't really know I would query it using software like HyperTerminal. Try send ATI3 command, usually device at the other end device will dump its basic identity information.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    Can i have some example how to send ATI3 command? I never heard like that before...

    Or i read on some article that says, I must install USB to COM virtualitation, did you know how it's work ?
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    156
    Rep Power
    3
    Originally Posted by BugzStriffe
    Can i have some example how to send ATI3 command? I never heard like that before...
    That's mean you need to learn a bit more on usual "standard" in serial port communication. I suggest to google for "AT commands".

    If you have Windows XP installation, you can look for HyperTerminal in Start - Access - Communication. You can use it to manually communicate with your serial device. So it's great for testing. If you don't have XP, I believe you still can download HyperTerminal, google it.

    Or i read on some article that says, I must install USB to COM virtualitation, did you know how it's work ?
    Like I have said previously, that is what your device should have done upon driver installation, IF your device connects through USB. If your device has serial port, you can buy a USB-to-COM cable to "convert" your USB port to serial.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    It's work my friends... Thx for the answer...
    My problem solved...

IMN logo majestic logo threadwatch logo seochat tools logo