Lazarus

Programming => General => Topic started by: essam eddine adib on November 09, 2019, 10:31:20 pm

Title: [SOLVED] impossible to cut paper in POS Printer via com Port
Post by: essam eddine adib on November 09, 2019, 10:31:20 pm
hi,

i want to cut paper in POS Printer via com port but it doesn't .

when i send data to com it print but when i send command to cut it doesn't work

i use this commande

procedure TFiche.CutPaper(XCom:String);
var Lst : System.Text;
  Command:string;
  tt: string;
begin
// Serial.st;
 try
  AssignFile(Lst,XCom);// the name of printer port, can be a network share
  Rewrite(Lst);

/////  i try all thoses commands one by one

  Command :=Chr(29)+Chr(86)+CHR(1) ;
  write(Lst,Command);

  Command :=Chr(29)+Chr(86)+CHR(0) ;
  write(Lst,Command);

  Command :=Chr(29)+Chr(86)+CHR(66)+Chr(1) ;
  write(Lst,Command);

  Command :=Chr(29)+Chr(86)+CHR(98)+Chr(1) ;
  write(Lst,Command);

  Command :=Chr(29)+Chr(86)+CHR(104)+Chr(1) ;
  write(Lst,Command);

  Command :=Chr(29)+Chr(86)+CHR(48) ;
  write(Lst,Command);


  CloseFile(Lst);

 except
 end;
end;


Can you help me

thank's
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: winni on November 09, 2019, 10:54:31 pm
Hi!

Before every new command send a "reset printer command" because it might get confused by the last command.

Winni
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: jamie on November 09, 2019, 11:07:05 pm
There is  a 128 byte buffer in the IO stream, or that's what Delphi/TP has..

Using Flush(Handle) should force it to be sent.

Also, are you sure the Char(29) shouldn't be Char(27) instead ?

On top of that, I believe there is always a common ending to the string like a CR LF etc. I don't see you using WRITELN for this.

Most printers require a start and end frame byte.

Title: Re: impossible to cut paper in POS Printer via com Port
Post by: essam eddine adib on November 09, 2019, 11:09:14 pm
thank's for your replay

first : how can i reset printer command

second when i startup the program and set cut paper it not work i think there is no confusing command

than'k for all
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: marcov on November 09, 2019, 11:09:37 pm
Yeah, but the close would also flush it.
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: jamie on November 09, 2019, 11:15:43 pm
Would like to see the documentation of the command strings...


Also, it's possible to have a incorrect port setting and still have some of it working, a few chars may not work correctly and if this is the case, your command strings may not work too if they have the correct chars that get changed .
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: essam eddine adib on November 09, 2019, 11:16:44 pm
Hi,

This what i saw in ESC/POSĀ®  Mode Command Specifications



Code: Text  [Select][+][-]
  1. GS V m
  2. Name Cut paper
  3. Code ASCII GS V m
  4. Hex. :                1D 56 m
  5. Decimal             29 86 m
  6. Defined Region m = 0,1,48,49
  7. Function Executes specified paper cut.
  8.  
  9.  

when i send data i send this command  write(file,Chr(27)+chr(74)+chr(1)+'Test') Without  CR LF

how can I add it to my command

thank u for all
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: jamie on November 09, 2019, 11:19:01 pm
Use WRITELN instead or attached a Char(13) in the end,,.


I noticed the "m". that looks like a compound string that needs to be added to the end of all of them.

The compound string "m" has a char(0) in it. wouldn't that act as a null terminator ?

Try this for a string

 MyString := Char(29)+Char(86)+Char(0)+Char(1)+Char(48)+Char(49);
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: essam eddine adib on November 09, 2019, 11:38:11 pm
hi jamie,

in documentation they said we must choose one of  0,1,48,49

Code: Text  [Select][+][-]
  1. m Function
  2. 0, 48 Full cut
  3. 1, 49 Partial cut (one point uncut)
  4.  

the documentation is here
http://www.starmicronics.com/support/mannualfolder/escpos_cm_en.pdf (http://www.starmicronics.com/support/mannualfolder/escpos_cm_en.pdf)
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: jamie on November 10, 2019, 12:45:30 am
If I understand this correctly,,,,

 If you want a full cut you use 0 or 48

a partial cut  1 or 49

 a single printer does not support both so only one group will work

 also you need to be in STANDARD mode with the paper at the start or at the top of the next page with all data printed.

 refer to ESC i and ESC m
 basically, it looks like you can't just snip the paper at any location or time.
Title: Re: impossible to cut paper in POS Printer via com Port
Post by: winni on November 10, 2019, 01:14:07 am
Hi!

To make it clear:


 MyString := Chr(29)+Chr(86)+
                                                  Chr(0) or
                                                  Chr(1)  or
                                                  Chr(48) or
                                                  Chr(49);

And you can't cut the paper at any position -
you have to move it first in "cutting position".

That you have to do with:

65
 Feeds paper to (cutting position + [n x basic calculated pitch]) and performs a full cut
66
Feeds paper to (cutting position + [n x basic calculated pitch]) and performs a partial cut (one point uncut)

So:
MyString := Chr(29)+Chr(86)+Chr(65)    or
MyString  := Chr(29)+Chr(86)+Chr(66)
           

Here we are back to the 80s and matrix printers.
And endless paper ...

Winni
Title: [SOLVED] Re: impossible to cut paper in POS Printer via com Port
Post by: essam eddine adib on November 13, 2019, 06:55:25 am
hi, and thank's for all and specially to jamie i used writeln and it works


TinyPortal © 2005-2018