Using the Check Reader Device Service

The following shows how to use the CheckReader service from an application in asynchronous mode:
CheckReader myChk = (CheckReader) getService("checkservice");

//Add a Handler to receive all the events signaled by the
//service notifier.
myChk.addHandler (this,"allEvents");

myChk.open();

//Instantiate a semaphore for the read operation.
readSemaphore = new Semaphore();

//Asynchronousread.
myChk.read();

//Wait for message read event.
readSemaphore.waitOn (150000,false,true);

myChk.close();

//Remove the registered handler.
myChk.removeHandler (this,"allEvents");

The event handler for the above code could be as follows:

public Handler dispatchEvent (DSEEventObject anEvent) 
{
CheckReader aReaderDevice = (CheckReader) anEvent.getSource();
messageRead = aReaderDevice.getDataRead();
readSemaphore.signalOn();
return this;
}