简体   繁体   中英

JavaPOS can't claim device

I'm developing an application which implements JavaPOS. I have configured the setting correctly but I still not able to print the receipt. (I can make a print from CITIZEN JavaPOS TEST PRO Ver.1.3.4 but not from my program)

Here is some part of my code:

import jpos.*;
import jpos.util.JposPropertiesConst;

...

System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME,"C:\\path_to_config\\jpos.xml");

...

POSPrinter printer = new POSPrinter();
try {
  printer.open("CITIZEN S310II USB Windows");
  printer.claim(100);
  printer.setDeviceEnabled(true);
  printer.setMapMode(POSPrinterConst.PTR_MM_METRIC);

  printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_TRANSACTION);

  String LF     = ((char) 0x0a) + "";
  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, "TEST" + LF + LF + LF);
  printer.cutPaper(100);
} catch (Exception e) {
  e.printStackTrace();
} finally {
  try {
    printer.setDeviceEnabled(false);
    printer.release();
    printer.close();
  } catch (Exception e) {
    e.printStackTrace();
  }
}

....

The error occurred when I tried to call printer.claim(1000); stating

jpos.JposException: CSJjposCom access error.
    at com.citizen.jpos.b.e.d(Unknown Source)
    at com.citizen.jpos.b.e.claim(Unknown Source)
    at jpos.BaseJposControl.claim(Unknown Source)
    at simplepos.billUI.printBill(billUI.java)
    ....

My library are:

./CBMjpos.jar
./lib/comm.jar
./lib/jna.jar
./lib/xerces-2.6.0.jar
./lib/xerces2.jar
./lib/

Please help, I can't find any resource to fix this problem

It is occurred because of special permission needed.

Add this in manifest file and try. Help for me.

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM