103
Chapter 5 Command Transmission/Reception
5
Receiving Data
Use the EpsonIo class's read (p.110) to receive data from the printer. Please refer to the following code.
Closing the Device Port
Use the EpsonIo class's close (p.107) to close the device port. Please refer to the following code.
//Settings for receiving
byte[] data = new byte[256];
int offset = 0;
int size = 256;
int timeout = 5000;
int sizeRead = 0;
int errStatus = IoStatus.SUCCESS;
//Receive data
try {
sizeRead = mPort.read(data, offset, size, timeout);
//Exception handling
} catch ( EpsonIoException e ) {
errStatus = e.getStatus();
}
int errStatus = IoStatus.SUCCESS;
//Close the device port
try {
mPort.close();
//Exception handling
} catch ( EpsonIoException e ) {
errStatus = e.getStatus();
}