REQUEST
I created a POS app (based on Java) that needs to be connected to at least 2 identical thermal printers using the same driver and the printers should do:
at application start >> each printer is to be
open(),claim(),setDeviceEnable(true)
onceat application stop >> each printer is to be
setDeviceEnable(false),release(),close()
food items to be printed on POSPrinter1
- drink items to be printed on POSPrinter2
WHAT I TRIED SO FAR
I created two POSPrinter objects
private POSPrinter posprinter = initUSBPrinter("POSPrinter1");
private POSPrinter posprinter2 = initUSBPrinter("POSPrinter2");
private static POSPrinter initUSBPrinter(String printerName) {
POSPrinter ptr = new POSPrinter();
try {
ptr.open(printerName);
ptr.claim(1000);
ptr.setDeviceEnabled(true);
} catch (JposException e) {
e.printStackTrace();
}
return ptr ;
}
- NO ERROR during application start when both printers were initiated/claimed
- WORKS FINE while printing food items with POSPrinter1
ERROR OCCURRED shown below while trying to print drink items with POSPrinter2:
jpos.JposException: 103 at com.sewoo.jpos.POSPrinterService.printNormal(POSPrinterService.java:4130) at jpos.POSPrinter.printNormal(Unknown Source) at util.PrintManager.printOrderingHeaderByPrinter(PrintManager.java:628) at util.PrintManager.printDrinkByPrinter(PrintManager.java:1359) at util.PrintManager.printOrdering(PrintManager.java:1931) at util.PrintManager.lambda$print$17(PrintManager.java:1668) at ...
ISSUE
So while both printers were found during init/claim, somehow POSPrinter1 could print perfectly fine while POSPrinter2 throws jpos.POSPrinter.printNormal(Unknown Source)
. I suspect that since POSPrinter1 was claimed before POSPrinter2, the JavaPOS driver is only connected to POSPrinter1. So is it possible that a single JavaPOS driver can only talk to a single device?
To be able to talk to 2 printing devices simultaneously do I need to have 2 JavaPOS drivers installed? If so, how can I configure my app to do so?
THIS WORKS BUT SLOWS PRINTING PROCESS
- connect to a either printer via
open(),claim(),setDeviceEnable(true)
before the printjob - and disconnect the printer via
setDeviceEnable(false),release(),close()
after the successful run of the printjob
BUT connect/disconnect after each print job slows down the printing process considerably. I usually need to wait 3-5 secs after the printjob was sent to see the printer finally printing the slip.