• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thermal printer commands: Cutter control

 
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am trying to send a cutter control command (ESC/P) to a thermal printer (Star TSP100).

The documentation says that you can send the command:
ESC d n

- where n is a function:

n Auto-cutter
0, 48 Full cut at the current position.
This command is ignored on tear-bar models.
1, 49 Partial cut at the current position.
This command is ignored on tear-bar models.
2, 50 Paper is fed to cutting position, then a full cut is executed. (*!)
On tear-bar models, paper is fed to the tear-bar position. (*2)
3, 51 Paper is fed to cutting position, then a partial cut is executed. (*1)
On tear-bar models, paper is fed to the tear-bar position. (*2)
(*1) Paper feed to cutting position: Executes a 1 inch

Please see documentation at:
http://www.starmicronics.com/support/Mannualfolder/dotcom_epm.pdf
Page 48: Cutter control

I am not sure how the function "n" works. What is meant by "0, 48"?

Here is my code:
str.append(ESC);
str.append( ( char ) 'd' );
str.append( ( char ) 0 );
str.append( ( char ) 48 );

or

str.append(ESC);
str.append( ( char ) 'd' );
str.append( ( char ) 0 );
str.append( ( char ) ',' );
str.append( ( char ) 48 );

- but it doesn't work? How do we understand the function n "0, 48"?
 
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The commands exist of ASCII characters. In the document the ascii decimal values are listed with the commands. n may be either the numerical value of the command you want to perform, or the character code representing that number.

48 is the decimal value for ascii '0'.

You can easily create the correct String like so: (char) 27 + 'd' + '0';
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You want to send what are normally called "escape sequences" They have been used for printer, modem, and CRT controls since the early 1970s. Maybe earlier, that's when I first started using them.

How is this printer connected to your computer? In the olden days, the printers were connected with either parallel or serial connections. Serial connections required manual setup of a lot of very low level communications parameters that we just let the network handle for us these days. Things like parity, number of bits in a byte, etc. were important and had to be managed in the application software. Stuff we usually ignore, like the highest order bit in a character, can cause serious headaches over a serial line.
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:The commands exist of ASCII characters. In the document the ascii decimal values are listed with the commands. n may be either the numerical value of the command you want to perform, or the character code representing that number.

48 is the decimal value for ascii '0'.

You can easily create the correct String like so: (char) 27 + 'd' + '0';



Thank, it works.
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pat Farrell wrote:You want to send what are normally called "escape sequences" They have been used for printer, modem, and CRT controls since the early 1970s. Maybe earlier, that's when I first started using them.

How is this printer connected to your computer? In the olden days, the printers were connected with either parallel or serial connections. Serial connections required manual setup of a lot of very low level communications parameters that we just let the network handle for us these days. Things like parity, number of bits in a byte, etc. were important and had to be managed in the application software. Stuff we usually ignore, like the highest order bit in a character, can cause serious headaches over a serial line.



Stephans commands works.

I am using USB connection. I am wondering about if you know any java api to call ESC commands (something like setBoldFontOn(), setBoldFontOff(), setFontSize(12), etc.) or do you know any API where you can just send HTML and it will convert it to ESC commands?
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright I am facing a more complicated issue when printing QR barcode.

According to the manual:
http://www.starmicronics.com/support/Mannualfolder/linemode_cm_en.pdf
Page 3-128:

My code looks like, but its doesn't work. It's just printing the QR text, no QR image is shown. Do I make any mistakes in my code below?:


The following is an example showing the sending of the commands.

(1) Set bar code type
<ESC> <GS> "y" "S" "0" 1 Sets to model 1.
<ESC> <GS> "y" "S" "1" 0 Sets mistake correction level to L.
<ESC> <GS> "y" "S" "2" 3 Sets cell size to 3 dots.

(2) Set bar code data
<ESC> <GS> "y" "D" "1" 0 20 0 "2005, January, 1 (SAT)" <LF>
Sets bar code data (Data automatic analysis)
Sets bar code data (Data manual analysis)

<ESC> <GS> "y" "D" "2" 10 1 4 0 "2005" ","
4 2 0 "Year" ","
1 1 0 "1" ","
4 2 0 "Month" ","
1 1 0 "1" ","
4 2 0 "Day" ","
4 2 0 "(" ","
2 3 0 "SAT" ","
4 2 0 ")" ","
3 1 0 <LF>

(3) Print bar code
To verify whether to print with the current settings, check the bar code expansion information.
<ESC> <GS> "y" "I" Check bar code expansion information
<ESC> <GS> "y" "p" Print
 
Pat Farrell
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeppe Sommer wrote: I am wondering about if you know any java api to call ESC commands (something like setBoldFontOn(), setBoldFontOff(), setFontSize(12), etc.) or do you know any API where you can just send HTML and it will convert it to ESC commands?



I've never see an API for it, other than the many that I wrote over the years. In later years, the Unix folks provided termcap to handle some of it, and of course X-windows extends the idea around the basic idea.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeppe Sommer wrote:Alright I am facing a more complicated issue when printing QR barcode.

According to the manual:
http://www.starmicronics.com/support/Mannualfolder/linemode_cm_en.pdf
Page 3-128:

My code looks like, but its doesn't work. It's just printing the QR text, no QR image is shown. Do I make any mistakes in my code below?:


The following is an example showing the sending of the commands.

(1) Set bar code type
<ESC> <GS> "y" "S" "0" 1 Sets to model 1.
<ESC> <GS> "y" "S" "1" 0 Sets mistake correction level to L.
<ESC> <GS> "y" "S" "2" 3 Sets cell size to 3 dots.

(2) Set bar code data
<ESC> <GS> "y" "D" "1" 0 20 0 "2005, January, 1 (SAT)" <LF>
Sets bar code data (Data automatic analysis)
Sets bar code data (Data manual analysis)

<ESC> <GS> "y" "D" "2" 10 1 4 0 "2005" ","
4 2 0 "Year" ","
1 1 0 "1" ","
4 2 0 "Month" ","
1 1 0 "1" ","
4 2 0 "Day" ","
4 2 0 "(" ","
2 3 0 "SAT" ","
4 2 0 ")" ","
3 1 0 <LF>

(3) Print bar code
To verify whether to print with the current settings, check the bar code expansion information.
<ESC> <GS> "y" "I" Check bar code expansion information
<ESC> <GS> "y" "p" Print



Well did you ever find a sollution to this : D? I have the same problem right now.
 
reply
    Bookmark Topic Watch Topic
  • New Topic