斯康企业,条码一站式解决方案欢迎您的访问!
服务热线
400-000-7712
当前位置: > 常见问题解答 >

通过Link-OS SDK开发,连接USB驱动时,反应时间超过30秒,如何解

文章出处:苏州斯康作者:苏州斯康人气:发表时间:2018-12-27 22:14【
通过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) {
            }
        }
    }

 

 

最新资讯