产品介绍
通过Link-OS SDK开发,连接USB驱动时,反应时间超过30秒,如何解?
Link-OS SDK中提供了一个DEMO,使用"ZebraPrinter printer = ZebraPrinterFactory.getInstance(printerConnection)"来从驱动中获取连接,但该方法速度比较慢,目前提供了"com.zebra.sdk.comm.DriverPrinterConnection"来替代"ZebraPrinterFactory.getInstance"方法,例子如下:
private void sendAndWaitDate() {
Connection conn = null;
try {
conn = new DriverPrinterConnection("ZDesigner ZT410-300dpi ZPL");
conn.open();
byte[] zpl = "^XA^FN1^RFR,H,0,12,2^FS^FH_^HV1,256^FS^RFW,H,1,14,1^FD3000313233343536373839414243^FS^XZ".getBytes();
byte[] tid = null;
tid = conn.sendAndWaitForResponse(zpl, 500, 500, null);
DemoDialog.showErrorDialog(SendFileDemo.this, tid.toString(), tid.toString());
} catch (ConnectionException e) {
DemoDialog.showErrorDialog(SendFileDemo.this, e.getMessage(), "Connection Error!");
} finally {
try {
if (conn != null)
conn.close();
} catch (ConnectionException e) {
}
}
}