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 ?
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.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 106 guests