How Open Cash Drawer via printer? *working great*

How Open Cash Drawer via printer? *working great*

Postby dutch » Sat Feb 14, 2009 2:37 pm

Dear All,

I need to open cash drawer that connect via printer (Epson TM-U220b).
The Cash Drawer is connect via RJ11 connect to printer. I've to send command to printer with FONT NAME 'control' but it must print a piece a paper every time to open.
I try to send command to open it but it do nothing.

What I do wrong?
Code: Select all  Expand view
 
*------------------*
Function OpenDrawer
local oFnt, oPrinter
 
   PRINTER oPrinter FROM USER
   // DEFINE FONT oFnt NAME 'Courier' SIZE 0, -8 OF oPrinter
   DEFINE FONT oFnt NAME 'control' SIZE 0, -8 OF oPrinter
   
//   oPrinter:StartPage()
   oPrinter:Say( 1, 1, 'A', oFnt )
   
   ENDPRINT
   
   oFnt:End()
 
return
 


Regards,
Dutch
Last edited by dutch on Tue Mar 03, 2009 8:00 am, edited 1 time in total.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How Open Cash Drawer via printer?

Postby Otto » Sat Feb 14, 2009 2:53 pm

Hello Dutch,
this is my code. Maybe it is of some use for you.
Best regards,
Otto
Code: Select all  Expand view
  1.     if GetPvProfString( "Kassenlade", "UEBERDRUCKER" , "N", ".\INI\TOUCH.INI" ) ="J"
  2.                     oPrnDOS := TDosPrn():New("LPT1")
  3.                     *oPrnDOS:write(chr(27)+chr(112)+chr(15)+chr(15))
  4.                     oPrnDOS:write(chr(27)+chr(112)+chr(0)+chr(10)+chr(100))
  5.                     oPrnDOS:cFormFeed:="0"
  6.                     oPrnDOS:EndPage()           // optional
  7.                     oPrnDOS:End()
  8.  
  9.                 else
  10.  
  11.                     oPrn   := PrintBegin("DRUCKER", .f., .f.,cPrnName )
  12.                     PAGE
  13.                     DEFINE FONT oFntNormal NAME "ARIAL" SIZE 16,40
  14.                     oPrn:Say( 0,5 ,   (chr(27)+chr(112)+chr(0)+chr(10)+chr(100))           , oFntNormal  )
  15.                     ENDPAGE
  16.                     ENDPRINT
  17.                     RELEASE FONT oFntNormal
  18.  
  19.                 ENDIF
  20.  
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: How Open Cash Drawer via printer?

Postby dutch » Sat Feb 14, 2009 3:56 pm

Thanks Otto, I will try.

Regards,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How Open Cash Drawer via printer?

Postby Richard Chidiak » Sun Feb 15, 2009 6:28 am

Dutch

This is my code, note i do not use tdosprn because of usb limitations

HTH

Richard
Code: Select all  Expand view
  1.  
  2. ICAISSE := GetPvProfString("PRINTER","TICKET",,CINIFile )   // this is the printer you should change to identify yours
  3. OPRN    := TPrinter():New("TEST Impression", .F. , .F. , ICAISSE, .T.)
  4.  
  5. Ntext   := SPACE(45)
  6. NTEXT   := CHR(27) +'p'+ CHR(0)+CHR(10)+CHR(25)
  7.  
  8. CFILE := "c:\test.TXT"  // could be any name
  9. nHandle := fCreate( cFile )
  10. FWRITE( nHandle, NTEXT)
  11. fClose( nHandle )
  12.  
  13. PrintFileRaw(ICAISSE,CFILE)  // this line opens the cash draw
  14.  
  15. FERASE("C:\test.txt")
  16.  
  17.  
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: How Open Cash Drawer via printer?

Postby Francisco Horta » Mon Feb 16, 2009 3:55 pm

Richard,

Where is function PrintFileRaw()?
regards
Paco
____________________
Paco
Francisco Horta
 
Posts: 845
Joined: Sun Oct 09, 2005 5:36 pm
Location: la laguna, mexico.

Re: How Open Cash Drawer via printer?

Postby Richard Chidiak » Tue Feb 17, 2009 6:31 am

Paco

It is a xharbour function

Code: Select all  Expand view

PrintFileRaw()
Prints a file to a Windows printer in RAW mode.
Syntax
PrintFileRaw( <cPrinterName>, ;
              <cFileName>   , ;
             [<cJobTitle>]    ) --> nErrorCode

Arguments
<cPrinter>
This is a character string holding the name of the printer to use for printing.
<cFileName>
The file to print must be specified as a character string, including path and extension. If the path is omitted, the file is searched in the current directory.
<cJobTitle>
This is an optional character string which appears as print job description in the spooler. It defaults to <cFileName>. Return
The function returns 1 on success or a value less than zero on error. See the example for error codes.
Description
Function PrintFileRaw() prints a file to a Windows printer in RAW mode. This restricts file types for printing to enhanced metafiles (EMF), ASCII text, and raw data, which includes all printer specific file types such as PostScript and PCL. The file is sent to the Windows spooler which processes the print job. The function returns zero when the file is successfully transferred to the spooler. Note that this is no guarantee for a printout. If the physical printer is out of paper, for example, the spooler reports an error to the user. This type of failure cannot be detected by PrintFileRaw().
Info
See also: GetPrinters(), GetDefaultPrinter(), PrinterExists(), PrinterPortToName()
Category: Printer functions , xHarbour extensions
Source: rtl\tprinter.c
LIB: xhb.lib
DLL: xhbdll.dll

Example
// The example prints a file in RAW mode and demonstrates
// the possible return values of PrintFileRaw().

   PROCEDURE Main()
      LOCAL cPrinter := GetDefaultPrinter()
      LOCAL cFile    := "MyFile.Txt"
      LOCAL nResult  := -1
      LOCAL cMsg     := "PrintFileRaw(): "

      CLS
      IF Empty( cPrinter )
         ? "No default printer found"
         QUIT
      ENDIF

      nResult := PrintFileRaw( cPrinter, cFile, "Test for PrintFileRaw()" )

      SWITCH nResult
      CASE -1
         cMsg += "Invalid parameters passed to function" ; EXIT
      CASE -2
         cMsg += "WinAPI OpenPrinter() call failed"      ; EXIT
      CASE -3
         cMsg += "WinAPI StartDocPrinter() call failed"  ; EXIT
      CASE -4
         cMsg += "WinAPI StartPagePrinter() call failed" ; EXIT
      CASE -5
         cMsg += "WinAPI malloc() of memory failed"      ; EXIT
      CASE -6
         cMsg += "File " + cFile + " not found"          ; EXIT
      DEFAULT
         cMsg += cFile + " PRINTED OK!!!"
      END

      ? cMsg
   RETURN


 
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: How Open Cash Drawer via printer?

Postby dutch » Tue Mar 03, 2009 7:57 am

Dear Otto & Richard,

Otto's samples is working well with 16bits and 32bits
Richard's sample is working weel with 32bits.

Thanks for all of you and kindness,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How Open Cash Drawer via printer? *working great*

Postby Francisco Horta » Tue Mar 03, 2009 9:56 pm

thanks richard,
don´t found cause i use harbour
regards
paco
____________________
Paco
Francisco Horta
 
Posts: 845
Joined: Sun Oct 09, 2005 5:36 pm
Location: la laguna, mexico.


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests