1

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) once

  • at 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.

Chiggiddi
  • 542
  • 1
  • 8
  • 26
  • There seems to be something wrong with that printer manufacturer's JavaPOS. Please try another manufacturer's printer. – kunif Jan 17 '18 at 12:50
  • @kunif thanks for your reply. What do you suggest could be wrong? Do you think that my approach to create 2 instances of POSPrinter is actually the right way to do it? – Chiggiddi Jan 17 '18 at 20:10
  • Under the JavaPOS specification, your way of doing it will be correct. In my experience, OPOS/POS for. NET can independently control two devices in the same way. – kunif Jan 17 '18 at 22:49
  • Just like StackOverfow's Related Q&A [Using two identical POS printers via JavaPOS](https://stackoverflow.com/questions/24930527/using-two-identical-pos-printers-via-javapos?rq=1) was listed. – kunif Jan 18 '18 at 06:18
  • I see. Thank you so much for your input. I contacted my hardware manufacturer. – Chiggiddi Jan 18 '18 at 13:02
  • I´m in the same situation. do you find any workaround?. It seems like JavaPOs can´t print in 2 pos-printers at the same time. It only works with sequential printing. – Andres Oct 16 '19 at 06:52
  • @Andres unfortunately this is caused by JavaPOS. We abandoned it and now we are using ESCPOS only. – Chiggiddi Oct 25 '19 at 13:04
  • you may try it from two different class loaders. Maybe they have just state problems with the driver. Just start the application twice and print simultanusly – thi gg Nov 30 '19 at 22:51

0 Answers0