|
Citizen CT-s651 serial barcode command |
Débuté par willy hermans, 14 sep. 2017 15:29 - 9 réponses |
| |
| | | |
|
| |
Posté le 14 septembre 2017 - 15:29 |
Hello,
I want to print a barcode via serial commands to a Citizen CT-s651. Tis is a serial ticket (pos) printer. (Old DOS methode)
The manual is not clear for me. Has someone an example to print a barcode this way.
Many thanks.
Willy Hermans |
| |
| |
| | | |
|
| | |
| |
Posté le 14 septembre 2017 - 16:38 |
Hi Willy,
Do a google search for CommandReference015E_120607_4.pdf This is the correct manual for your printer.
Look at page 140.
The first thing to do is to get it to print the barcode. Which format are you using - EAN-13 etc.
After that you can add the extra bits - barcode number above / below barcode , change size etc.
It is the same format as if you were cutting paper - "1D" Hex , XXX , XXX , XXX
You can PM me if you really get into trouble.
Kindest Regards,
Mike Allison |
| |
| |
| | | |
|
| | |
| |
Posté le 15 septembre 2017 - 13:59 |
Hello,
I use EAN 13
I found this code <1D>H<6B>H [d1…dn]
I have an inifile with this content Barcode=charact(29) + charact(72) + Charact(107) + charact(67) + "123456789012" I read the content into the variabele cBarcode
cCode = StringBuild(cBasicCode,cBarcode) // This works fine for cBarcode = ExecuteCode(cCode) // the othet commands
If I understand it well, the position of the hri and the size of the barcode is optional.
The result is text "C123456789012" and not a barcode
Thanks,
Willy Hermans |
| |
| |
| | | |
|
| | |
| |
Posté le 15 septembre 2017 - 14:25 |
Hi Willy,
If you are using it in default mode ean-13, you have to put the check digit on the end. You are only putting in 12 digits - so it is not a correct barcode.
You are getting the error because it CAN'T print it!
The correct barcode is 1234567890128.
Regards,
Mike Allison |
| |
| |
| | | |
|
| | |
| |
Posté le 18 septembre 2017 - 09:51 |
Hello,
I''ve tried it but it makes no difference.
It still does not work. |
| |
| |
| | | |
|
| | |
| |
Posté le 18 septembre 2017 - 13:24 |
Hi Willy,
What isn't working? How are you opening the port? Can you show us all your code? |
| |
| |
| | | |
|
| | |
| |
Posté le 18 septembre 2017 - 15:03 |
Hello,
This is the last trial
PROCEDURE prttest() IF sOpen(Port_E, 2000,2000) THEN // sParameter(gsCom_Poort,19200,0,8,0,true) ELSE Error("Probleem met openen seriële poort ","Staat de printer aan" + Port_E) RETURN END Schrijf(Port_E, ESC + "H1Dh"+Charact(50)) Schrijf(Port_E, ESC + "H1DH"+Charact(2)) Schrijf(Port_E, ESC +"H1Df"+Charact(0)) Schrijf(Port_E, ESC +"H1Dk") Schrijf(Port_E, 4) Schrijf(Port_E, “12”+Charact(0)) Schrijf(Port_E, ESC +"HA") FOR i = 1 TO 10 Schrijf(Port_E,cLineFeet) END // Cut the paper Writestring = Charact(10) + Charact(27) + Charact(105) Schrijf(Port_E, cCutter) sClose(Port_E) PROCEDURE Schrijf(pPoort,pLijn) IF cSerielePrinter = "HTML" THEN cHtmlBody += pLijn ELSE sWrite(pPoort, pLijn) END
This is based on this sample basic program from the printer manual
LPRINTCHR$(&H1D);"h";CHR$(30); LPRINTCHR$(&H1D);"w";CHR$(2); GOSUBBC LPRINTCHR$(&H1D);"h";CHR$(50); LPRINTCHR$(&H1D);"w";CHR$(3); GOSUBBC LPRINTCHR$(&H1D);"h";CHR$(80); LPRINTCHR$(&H1D);"w";CHR$(4); GOSUBBC END BC: LPRINTCHR$(&H1D);"k"; LPRINTCHR$(4); LPRINT"12";CHR$(0); RETURN
What is going wrong. Wel there is no barcode printed but the printer prints a text string.
Thanks already Willy Hermans |
| |
| |
| | | |
|
| | |
| |
Posté le 18 septembre 2017 - 17:29 |
Willy,
This is how I print a barcode on the bottom of a receipt. Gianni Spano and I wrote this module in 2010 (long with a bit of help from Fabrice Harari).
The first module is the procedure to get the barcode details. The second module is the printing on the comport that the printer is attached to.
I hope that you can follow it Ok.
Kindest Regards,
Mike Allison
PROCEDURE PrintReceiptBarcode()
wtillno is string wRecpNb is string IF TillNo<10 THEN wtillno="0"+TillNo ELSE wtillno=TillNo END
wRecpNb=Left(NumToString(RecpNb,"04d"))
rline=Charact(29)+Charact(72)+Charact(02)+CRLF ssize=Length(rline) WriteCOMPort()
rline=Charact(29)+Charact(104)+Charact(72)+CRLF ssize=Length(rline) WriteCOMPort()
F1500_barcode_x=DateToInteger(DateSys())+wtillno+wRecpNb+TillSite F1500_checkDigit() rline=" "+Charact(29)+Charact(107)+Charact(02)+F1500_barcode+CRLF ssize=Length(rline) WriteCOMPort() rline=" "+F1500_barcode+CRLF fWrite(AuditFileID,rline)
FOR i=1 TO 4 rline="" rline+=CRLF ssize=Length(rline) WriteCOMPort() END
PROCEDURE WriteCOMPort() PortNbr is int // Port number BaudRate is int // Baud rate Parity is int // Parity StopBit is int // Stop Bit SizeWritten is int // Size of the string that was written InputBufferSize is int = 100 // Size of the buffer for reading OutputBufferSize is int = 5000 // Size of the buffer for writing // Waiting time of the sRead/sWrite functions between two characters (in ms) PortWaitingTime is int = 10 // was 100
titleline is an array of 10 string //k is int
IF FlagRcp=False THEN RETURN END
SizeWritten=ssize
PortNbr=INIRead ("TILLPARAM","COMPORT","X",(fExeDir()+"\FPoS.ini")) BaudRate=INIRead ("TILLPARAM","COMBAUD","X",(fExeDir()+"\FPoS.ini")) Parity=INIRead("TILLPARAM","COMPARITY","X",(fExeDir()+"\FPoS.ini")) StopBit=INIRead("TILLPARAM","COMBITSTOP","X",(fExeDir()+"\FPoS.ini"))
IF PortNbr < 1 THEN ComPortOK=False RETURN ELSE ComPortOK=True END // IF NOT sOpen ( PortNbr , InputBufferSize , OutputBufferSize , PortWaitingTime ) THEN // Process port opening error Error ( "Error while opening COM" + PortNbr ) RETURN END
//Port settings IF NOT sParameter ( PortNbr , BaudRate , Parity , 8 , StopBit , False , False , True ) THEN // Process setting error Error ( "Error while setting COM" + PortNbr ) ELSE IF SizeWritten = 0 AND rline <> "" THEN // Nothing has been written even though the string to write is not empty // Check the output buffer IF sInExitQueue (PortNbr)=OutputBufferSize THEN // The output buffer is full IF NOT YesNo ( "Cannot write to port" +... "COM" + PortNbr ,... "Check that a device is connected " +... "and ready." ,... "Do you want to retry?" ) THEN RETURN // Cancel write operation END END END ELSE IF SizeWritten = ssize THEN // Everything has been written // Otherwise, only part has been written // But since we were able to write some, we keep trying
sWrite (PortNbr,rline) GOTO Closecom END END END
Closecom:
// Close COM sClose ( PortNbr ) |
| |
| |
| | | |
|
| | |
| |
Posté le 20 septembre 2017 - 12:37 |
Hello,
Indeed this helped al lot. Its working now and this is the code.
I think this works for most Citizen Ticketprinters. And for the ean13 barcode.
PROCEDURE PrintBarcode(pBarcode) cLine is string cLine=Charact(29)+Charact(72)+Charact(02)+CRLF sWrite(2,cLine) cLine=Charact(29)+Charact(104)+Charact(72)+CRLF sWrite(2,cLine) cLine=Charact(29)+Charact(107)+Charact(02)+pBarcode+CRLF sWrite(2,cLine)
It looks simple and it corresponds to the manual, but every bit and byte must be exact. This code assumes that the port is opened and you have to close it afterwards but it works fast.
The manual does not mention any CrLf ...
With this code I can print every ean13 serial.
The last digt is a checksum. So you can make a 12 digit code and use this code add the check
PROCEDURE AddCheckDigit(cIn)
nDummy1 is int = 0 nDummy2 is int cCheck is string cTerug is string = ""
IF Length(cIn) = 12 THEN FOR i = 2 TO 12 STEP 2 nDummy1 += Asc(Middle(cIn,i,1))-48 nDummy2 += Asc(Middle(cIn,i-1,1))-48 END nDummy1 = (nDummy1*3) +nDummy2
IF IntegerPart(nDummy1/10) = nDummy1 THEN cCheck = "0" // Dit wordt de checkdigit ELSE cCheck = ((IntegerPart(nDummy1/10)*10)+10) - nDummy1 END
IF cCheck = "10" THEN cCheck = "0" END END
RESULT cCheck
This function is not optimized but it works.
Thanks voor the example.
Willy Hermans |
| |
| |
| | | |
|
| | |
| |
Posté le 20 septembre 2017 - 15:24 |
Hi Willy,
Glad we were able to help.
Kindest Regards,
Mike Allison |
| |
| |
| | | |
|
| | | | |
| | |
|