- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我有 JavaPOS 和 XML 文件的示例代码,但是当我运行代码时,我在 printer.claim(1)
上遇到了异常,我使用了默认的 xml (pos.xml
) 示例文件 link
我已经在/usr/java/packages/lib/
中安装了必要的原生驱动,所以原生驱动应该没有问题。
import jpos.JposException;
import jpos.POSPrinter;
import jpos.POSPrinterConst;
import jpos.events.StatusUpdateEvent;
import jpos.events.StatusUpdateListener;
import jpos.util.JposPropertiesConst;
import java.util.StringTokenizer;
public class Printer {
public static void main(String[] args) {
System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "jpos.xml");
POSPrinter printer = new POSPrinter();
// constants
String ESC = ((char) 0x1b) + "";
String LF = ((char) 0x0a) + "";
try {
//Open Printer
printer.open("CUSTOM TG2480H POS Printer USB Linux");
printer.claim(1);
printer.setDeviceEnabled(true);
//Print a Text String
printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, "Print Test");
//Close Printer
printer.setDeviceEnabled(false);
printer.release();
printer.close();
} catch (JposException e) {
// display any errors that come up
e.printStackTrace();
} finally {
// close the printer object
try {
printer.close();
} catch (Exception e) {
}
}
System.exit(0);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE JposEntries PUBLIC "-//JavaPOS//DTD//EN" "jpos/res/jcl.dtd">
<JposEntries>
...
<JposEntry logicalName="CUSTOM TG2480H POS Printer USB Linux">
<creation factoryClass="custom.services.posprinter.SimpleJPOSServiceInstanceFactory" serviceClass="custom.services.posprinter.TG2480H.CUSTOM_TG2480HPrinterService"/>
<vendor name="CUSTOM" url="http://www.custom.biz"/>
<jpos category="POSPrinter" version="1.8"/>
<product description="Jpos printer driver" name="CUSTOM TG2480H POS Printer" url="http://www.custom.biz"/>
<prop name="PhysicalDevice" type="String" value="CUSTOM TG2480H POS Printer"/>
<prop name="PID" type="String" value="01A8"/>
<prop name="deviceBus" type="String" value="USB"/>
<!--"portname" for USB device is the "USB Address Number" (refer to the printer Setup)-->
<prop name="portName" type="String" value="0"/>
<!--"logging" values: "none", "file://[file path / name]" and "video" -->
<prop name="logging" type="String" value="Video"/>
<!--CUSTOM PROPERTIES:-->
<!--PrintTextAutoLF: If true, the driver sends a LF after every PrintNormal or PrintImmediate-->
<prop name="PrintTextAutoLF" type="String" value="true"/>
<!--EnableTOStsSignal: If true, and the printer supports it, the driver signals PTR_SUE_REC_CARTRIDGE_EMPTY if the ticket is present on output, otherwise PTR_SUE_REC_CARTDRIGE_OK-->
<prop name="EnableTOStsSignal" type="String" value="false"/>
</JposEntry>
...
</JposEntries>
[Friday, 14 August 2015 12:23:27][M]claim [1]
[Friday, 14 August 2015 12:23:27][I][BasePrinterService] claim Begin
[Friday, 14 August 2015 12:23:27][I]Opening USB device with Pid:<01A8> and Address Number <0> ...
[Friday, 14 August 2015 12:23:27][E]
[Friday, 14 August 2015 12:23:27][I]Retry Open...
[Friday, 14 August 2015 12:23:27][E][BasePrinterService] jpos.JposException : Claim timeout Error
jpos.JposException : Claim timeout Error
at custom.services.posprinter.BasePrinterService.claim(Unknown Source)
at jpos.BaseJposControl.claim(Unknown Source)
at .<init>(<console>:11)
at .<clinit>(<console>)
at .<init>(<console>:7)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
.....
[ 78.993713] usb 2-1.5: new full-speed USB device number 5 using ehci-pci
[ 79.067711] usb 2-1.5: device descriptor read/64, error -32
[ 79.231704] usb 2-1.5: device descriptor read/64, error -32
[ 79.405698] usb 2-1.5: new full-speed USB device number 6 using ehci-pci
[ 79.479695] usb 2-1.5: device descriptor read/64, error -32
[ 79.643657] usb 2-1.5: device descriptor read/64, error -32
[ 79.817685] usb 2-1.5: new full-speed USB device number 7 using ehci-pci
[ 80.219464] usb 2-1.5: device not accepting address 7, error -32
[ 80.418552] usb 2-1.5: new full-speed USB device number 9 using ehci-pci
[ 80.508162] usb 2-1.5: New USB device found, idVendor=0dd4, idProduct=0193
[ 80.508178] usb 2-1.5: New USB device strings: Mfr=4, Product=56, SerialNumber=210
[ 80.508180] usb 2-1.5: Product: TG2480
[ 80.508183] usb 2-1.5: Manufacturer: CUSTOM Engineering S.p.A.
[ 80.508185] usb 2-1.5: SerialNumber: TG2480 Num.: 0
[ 80.513602] usblp 2-1.5:1.0: usblp0: USB Bidirectional printer dev 9 if 0 alt 0 proto 2 vid 0x0DD4 pid 0x0193
最佳答案
根据dmesg
日志,您的设备是TG2480(不是TG2480H),根据技术支持的邮件不支持JavaPOS。
关于java - Linux 上的自定义 TG2480H USB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32005100/
我尝试在安装了多类型 MFC 库的 visual studio 2015 MFC 上运行以前编写的 MFC c++ 代码。 但是,我这里仍然有 12 个关于缺少函数的错误: IntelliSense:
我正在学习 OOP 并且有疑问。假设我有一个包含 ClassB.h 的文件 ClassA.h,并且在某些时候我的 ClassB.h 需要包含 ClassA .h。 这会产生一个错误,我想我明白为什么会
我开始使用 CUDA 进行编程,在一些示例中我找到了包含文件 cuda.h、cuda_runtime.h 和 cuda_runtime_api.h 包含在代码中。有人可以向我解释一下这些文件之间的区别
我有一些生成正则表达式的代码。那么下面的表达式实际上是: ^(?:\s*((exclude|include|hide|show|protect|risk|dir-merge|merge)),\s*((
我一直在查看一些源代码,以更好地了解我们使用的这款游戏的核心,并编写更可靠、更快速的插件。然后我发现了这段奇怪的代码...... public void setMaxH(double amount)
通常我们会使用标准类型作为 std::unordered_map 的键和值.但现在我需要自定义我自己的键和值类。 键类在block_cache_key.h 中定义如下: #ifndef BLOCK_C
例如,我想要两个头文件,它们可以依赖于另一个头文件中的函数。 //Header1.h file #include Header2.h void h1(){ //... func1(); } v
我正在研究来自 Sedgewick 的 Shell 排序 Algorithms in C part 1-4在第 172 页。 我使用 size (数组的长度),而不是 l和 r (开始和结束);所以我
我在 macOS BigSur 上通过 VMWare 使用 Ubuntu 20.04.2 LTS。我安装了最新版本的 tcl、tcl-dev、tk 和 tk-dev - 版本 8.6。我想编译 Arc
我用我的 glu 和 gl 头文件构建了一个 OpenGL 程序,默认包含在 windows 7 专业版中。现在,我买了一本描述 OpenGL 游戏开发的书。这本书的作者说,我必须在我的项目中包含 g
我想在 token 中保留特殊字符,同时仍对特殊字符进行 token 化。说我有话 "H&R Blocks" 我想将其标记为 "H", "R", "H&R", "Blocks" 我读了http://w
关于 hash 作为 trans 参数的另一个问题。在下面的代码中,简单地使用 hash 会给出不正确的结果,但是将其替换为 keys 和 values 会使其正确。怎么了? my @alph1 =
我已经编写了一个 C 程序,它获取屏幕像素的 RGB 值 (0-255),并知道其位置 (x,y)。它可以在 Linux 中运行,但是当我尝试在 Visual Studio (Windows) 中编译
我已经使用 Windows 7 专业版中默认包含的 glu 和 gl 头文件构建了一个 OpenGL 程序。现在,我买了一本描述 OpenGL 游戏开发的书。这本书的作者说,我必须将glew head
#include using namespace std; #include //#include int main() { initscr();
h:messages h:form 内的组件还显示与外部组件相关的消息。 如何限制它只显示与包含 h:form 内的组件相关的消息? 我不喜欢用单独的h:message来使我的代码膨胀。每个输入组件的
我下载了示例代码和 cpp 文件,其中包含 list.h、queue.h 和 vector.h 等头文件,如果我尝试构建,我会收到“ fatal error :没有这样的文件或目录编译终止”我想我应该
我有一个编译成功的桌面项目,但是在我向项目添加新配置以支持 Windows Mobile 平台后,我收到以下错误: error C2146: syntax error : missing ';' be
有很多关于这个错误的帖子,但我无法解决它,我希望你能拿出解决方案。我在 Ubuntu 机器上。 ~/graphmap2$ 在这个文件夹中,我下载了 zlib。可以看图 经过一番谷歌搜索后,我还注意到没
是否可以在 Visual C++ 中使用以下 header : 图.h dos.h bios.h 最佳答案 据我所知,无法在 Visual C++ 中使用它, 与此同时,我希望您关注 Open Wat
我是一名优秀的程序员,十分优秀!