Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ibm 9068 vs olivetti pr2 printer

Status
Not open for further replies.

yytan

Programmer
Joined
May 8, 2002
Messages
113
Location
MY
hi there;

does anyone know how to get the device events from ibm 9068 printer or olivetti printer?

below is the code to do simple printing on the printer, it provide from java comm.

import java.io.*;
import java.util.*;
import javax.comm.*;

public class SimpleWrite {
static Enumeration portList;
static CommPortIdentifier portId;
static String messageString = "Hello, world!\nHi Tan.";
static SerialPort serialPort;
static OutputStream outputStream;

public static void main(String[] args) {
portList = CommPortIdentifier.getPortIdentifiers();

while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM1")) {
System.out.println("port name = " + portId.getName());
//if (portId.getName().equals("/dev/term/a")) {
try {
serialPort = (SerialPort)
portId.open("SimpleWriteApp", 2000);
//System.out.println("1");
} catch (PortInUseException e) {}
try {
outputStream = serialPort.getOutputStream();
//System.out.println("2");
} catch (IOException e) {}
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
//System.out.println("3");
} catch (UnsupportedCommOperationException e) {}
try {
outputStream.write(messageString.getBytes());
//System.out.println("4");
} catch (IOException e) {}
}
}
}
}
}
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top