Cash with protocol Xon-Xoff

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Cash with protocol Xon-Xoff

Post by Silvio.Falconi »

How I can link with a cash have protocol Xon(ox11)-Xoff(ox13) ?


BAUD RATE = 9600
PARITA' = NO
STOP BIT = 1
BIT/CAR = 8
HANDSHAKE := CONTROLLO DI FLUSSO XON-XOFF


there is some sample for create it ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
vensanto
Posts: 54
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA
Contact:

Re: Cash with protocol Xon-Xoff

Post by vensanto »

I have used this procedure

setting the com port in nCMD1 ( XON=ON ) and send the MODE command

nCMD1:="MODE "+nCOMPRT+":"+Alltrim(Str(eECRBAUD))+","+eECRPARI+","+Alltrim(Str(eECRBIT))+","+Alltrim(Str(eECRBSTOP))
nCMD1+=",TO=OFF,XON=ON,IDSR=OFF,ODSR=OFF,OCTS=OFF,DTR=OFF,RTS=OFF"
RUN (nCMD1)

after i send with the TYPE command the file with the command cash register

nCMD2:="TYPE SCOBIG.TXT > "+nCOMPRT
RUN (nCMD2)

and this work very well

regards
Santo Venezia
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Cash with protocol Xon-Xoff

Post by Silvio.Falconi »

I think I must use serial comunication ( tSocket) but I not Know how it must make
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Cash with protocol Xon-Xoff

Post by Silvio.Falconi »

Dear Santo...
with txt command you not Know how much paper you have , if the printer is open or close , if the data are saved on printer .....
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Robert Frank
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland
Contact:

Re: Cash with protocol Xon-Xoff

Post by Robert Frank »

try to use

1. FISKALNA_OPEN() - open COM port
2. FISK_COM_SEND(cTEKST) - send string to COM port (fiskal printer)
3. FISKALNA_CLOSE() - close COM port

Code: Select all

Function FISKALNA_OPEN()
Local pNAME
Local nError,cDCB
Local xRESZTA:=.T.
Local cTEKST:=""
Local xPORT:=1

cKASAFISKALNA:=AllTrim(GetENV("KASAFISKALNA"))
cKASACOM:=AllTrim(GetENV("KASACOM"))
If Empty(cKASAFISKALNA)
   cKASAFISKALNA:="BRAK"
EndIf

Do Case
Case cKASAFISKALNA="BRAK"
   MsgStop("Stanowisko nie posiada obslugi kasy fiskalnej")
   cCOM_IP_USB:="BRAK"
   Return .T.
Case cKASAFISKALNA="USB"
   cCOM_IP_USB:="USB"
Case cKASAFISKALNA="COM"
   cCOM_IP_USB:="COM"
   xPORT:=Val(cKASACOM)
   If xPORT=0
      MsgWait("Domyslnie kasa fiskalna na porcie 1","",2)
      xPORT:=1
   EndIf
   Do Case
   Case xPORT=1
    pNAME:="COM1"
   Case xPORT=2
    pNAME:="COM2"
   Case xPORT=3
    pNAME:="COM3"
   Case xPORT=4
    pNAME:="COM4"
   Case xPORT=5
    pNAME:="COM5"
   Case xPORT=6
    pNAME:="COM6"
   Case xPORT=7
    pNAME:="COM7"
   Case xPORT=8
    pNAME:="COM8"
   Case xPORT=9
    pNAME:="COM9"
   EndCase
   cTEKST:="Otwarcie portu : "+pNAME+" ---> "+cSPEED
   LogFile( "LOGS\kasafiskalna.txt", { Len( cTEKST ), cTEKST } )

   //MsgWait(cTEKST,"",1)

   hPORT:= OpenComm( pNAME, 2048, 2048 )
   If ! BuildCommDcb( pNAME+cSPEED, @cDcb )
      nError = GetCommError( hPORT )
      MsgInfo( "BuildCommDcb Error: " + Str( nError ) )
      xRESZTA:=.F.
   EndIf
   If ! SetCommState( hPORT, cDcb )
         nError = GetCommError( hPORT )
         MsgInfo( "SetCommState Error: " + Str( nError ) )
      xRESZTA:=.F.
   EndIf
   If xRESZTA
      oWND:oMSGBAR:cMSGDEF:=PNAME+" : OTWARTY "+pNAME+cSPEED
      oWND:oMSGBAR:Refresh(.T.)
      oWND:bCommNotify := {|nComm,nStatus| ODBIERZ(hPORT,nSTATUS) }
      EnableCommNotification(hPORT,oWNd:hWNd,1,-1)
   Else
      oWND:oMSGBAR:cMSGDEF:=PNAME+" : NIEUDANE OTWARCIE "+pNAME+cSPEED
      oWND:oMSGBAR:Refresh(.T.)
   EndIf
EndCase
Return xRESZTA

Function FISKALNA_CLOSE()
Local xRESZTA:=.T.
Local nERROR
Local cTEKST:=""

cTEKST:="Zamkniecie portu "+cKASAFISKALNA
LogFile( "LOGS\kasafiskalna.txt", { Len( cTEKST ), cTEKST } )

MsgWait(cTEKST,"",1)

Do Case
Case cKASAFISKALNA="COM"
   If FlushComm( hPORT, 0 ) != 0
         nError = GetCommError( hPORT )
         MsgInfo( "FlushComm Error: " + Str( nError ) )
      xRESZTA:=.F.
   EndIf
   If ! CloseComm( hPORT )
         nError = GetCommError( hPORT )
         MsgInfo( "CloseComm Error: " + Str( nError ) )
   xRESZTA:=.F.
   EndIf
   If xRESZTA
   //   oWND:oMSGBAR:cMSGDEF:=" COM : ZAMKNIETY"
   //   oWND:oMSGBAR:Refresh(.T.)
   Else
   //   oWND:oMSGBAR:cMSGDEF:=" COM : NIE UDANE ZAMKNIECIE"
   //   oWND:oMSGBAR:Refresh(.T.)
   EndIf
EndCase
Return (NIL)

Function FISK_COM_SEND(cTEKST)
Local nBYTES
Local nERROR

Do Case
Case cKASAFISKALNA="COM"
   If ( nBytes := WriteComm( hPORT, cTEKST) ) <= 0
      nError = GetCommError( hPORT )
      MsgInfo( "WriteComm Error: " + Str( nError ) )
   Else
      // przeciez wyslal
   EndIf
Case cKASAFISKALNA="USB"
   USB_SEND_PARAGON(cTEKST)
Otherwise
   MsgWait("NIE TAK COS JEST !!!","",2)
EndCase
LogFile( "LOGS\kasafiskalna.txt", { Len( cTEKST ), cTEKST } )
Return .T.
 
Robert Frank
Post Reply