我正在尝试使用 JavaPos 将某些内容打印到 EPSON TM-T88IV。EPSON 附带一个 USB 转串口转换器。
这是我尝试的代码:
ptr.open("POSPrinter");
ptr.claim(1000);
ptr.setDeviceEnabled(true);
ptr.printNormal(1, "asd");
虽然这是 Eclipse 中的输出:
[JposServiceLoader]Custom manager is defined: className= jpos.loader.simple.SimpleServiceManager
[XercesRegPopulator]load(): isPopulatorFileDefined=false
[XercesRegPopulator]load: xmlFileName=jpos.xml
[JposServiceLoader]manager.getEntryRegistry().load() OK
[JposServiceLoader]findService: POSPrinter
[SimpleServiceConnection]Disconnected to service OK
它立即说:“断开服务”。我正确包含了所有 ESPON 驱动程序、dll 和库,因为否则会出现另一条错误消息。
Myjpos.xml
是由 EPSON 软件生成的。我尝试了 USB 和串行连接。在我的 Windows 管理器中,我将 USB 转串口转换器配置为 COM10,所以我尝试了 COM10 端口。
感谢您提供有关此主题的任何信息。
编辑
我尝试了另一段代码,它给出了相同的错误,但提供了更多信息。
编码:
// instantiate a new jpos.POSPrinter object
POSPrinter printer = new POSPrinter();
try
{
//open the printer by logical device name
printer.open("POSPrinter2");
//claim exclsive usage of the printer object
printer.claim(1);
// enable the device for input and output
printer.setDeviceEnabled(true);
// set map mode to metric - all dimensions specified in 1/100mm units
printer.setMapMode(POSPrinterConst.PTR_MM_METRIC); // unit = 1/100 mm - i.e. 1 cm = 10 mm = 10 * 100 units
...............
日志:
[JposServiceLoader]Custom manager is defined: className= jpos.loader.simple.SimpleServiceManager
[XercesRegPopulator]load(): isPopulatorFileDefined=false
[XercesRegPopulator]load: xmlFileName=jpos.xml
[JposServiceLoader]manager.getEntryRegistry().load() OK
[JposServiceLoader]findService: POSPrinter2
[SimpleServiceConnection]Disconnected to service OK
jpos.JposException: Could not create an instance.
at jp.co.epson.upos.core.v1_13_0001.pntr.CommonPrinterService.createCommInstance(Unknown Source)
at jp.co.epson.upos.core.v1_13_0001.pntr.CommonPrinterService.open(Unknown Source)
at jpos.BaseJposControl.open(BaseJposControl.java:530)
at Main.POSPrinterTest.main(POSPrinterTest.java:47)