Home arrow static arrow Java Programming [Archive] - How to pass and print files through LPT1 port using thermal printer
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - How to pass and print files through LPT1 port using thermal printer
This topic has 1 reply on 1 page.

Posts:6
Registered: 6/19/04
How to pass and print files through LPT1 port using thermal printer  
Jul 5, 2004 10:41 PM



 
hello,

We are developing POS for a retailer store and we most probably finished it. We are using the following hardware interfaces for the development.

1) Receipt Printer with Cash Drawer
Brand: POSIFLEX pp6000 serial thermal printer
Power Rated: DC 24v 2.0 A
Model no: 3902c492

2) Barcode Label Printer
Brand : Monarch Paxar
Model No: M09642PMU
Serial No: 20123152

3) POLE DISPLAY
Brand: CE
Model No: 07010517

4) Barcode Scanner
Brand: KB WEDGE
Model no: A307911

5) Programmable Keyboard
Brand: PREH COMMANDER MC 128
Model No: 90319-000/0000
Serial No: 014693

6) Touch Screen
Brand: 3M TOUCH SYSTEMS INC
Model No: 11-81371-129
The problem is , we never get the printout of the receipt .But we generaed the receipt. And the cash drawer is not opening.We use the following code for printing the receipt

[CODE]
import java.awt.print.*;
import java.io.*;
import java.util.*;

class PrintManager extends Thread
{
String STR_OUT="";
boolean CD_OPEN=true;

FileOutputStream fos;
PrintStream ps;

//char[] CMD_CUT={29,86,66,250}; //cuts paper
char[] CMD_CD_OPEN={27,112,0,25,250}; //kicks cash drawer 1

public PrintManager(){
setDaemon(true);
}
public void Init()
{

Init(true);
}

public void Init(boolean CDOPEN)
{

try{
fos = new FileOutputStream("LPT");
System.out.println("nnnnnnnnnnnnafter LPT2");
ps = new PrintStream(fos);
System.out.println("nnnnnnnnnnnnafter LPT2");
// System.setOut(new PrintStream(new FileOutputStream("LPT1.txt")));
//System.setOut(new PrintStream(new FileOutputStream("console.txt")));
System.out.println("SFWERWRW"+ps);
// STR_OUT=STR;
CD_OPEN=CDOPEN;
}catch(Exception ex)
{
System.out.println("Init:New::"+ex.toString());
}

}

public void run ()
{
try{
if(ps==null)
return;

//ps.println(STR_OUT);
//ps.print(CMD_CUT);
if(CD_OPEN)
{
System.out.println("ewqeqeqe");
ps.print(CMD_CD_OPEN);
System.out.println("ewqeqeq3453e");
}
ps.close();
fos.close();
}catch(Exception ex)
{
System.out.println("run::"+ex.toString());
}

}

public void Close()
{
try{
ps.close();
fos.close();
ps=null;
fos=null;
}catch(Exception ex)
{
System.out.println("Init:close::"+ex.toString());
}

}

}
public class PrintRcpt {

public static void main(String args[]) {
PrintManager objPM=new PrintManager();
//call Init always before calling start
objPM.Init(); //print and open cashdrawer
//objPM.Init("ZX",false); //print and do not open cashdrawer
objPM.start();
System.out.println("DONE");

//Below sleep is a simulation for time lapse between two sales- do not include this sleep in the final code
try{
Thread.sleep(1000);
System.out.println("DONE2");

}catch(Exception ex){}

//before starting second sale, close the port connection opened by first sales
//this close should be called when the user closes the receipt print preview screen
objPM.Close();
objPM=null;//destroy the print manager object

}
}

[/code]
You please post your suggestion for getting the printout from our POS system.

 

Posts:9,091
Registered: 8/15/01
Re: How to pass and print files through LPT1 port using thermal printer  
Jul 5, 2004 10:44 PM (reply 1 of 1)



 
[url http://forum.java.sun.com/thread.jsp?forum=31&thread=535737]Duel posted[/url]
 
This topic has 1 reply on 1 page.