Hi ,
I am trying to connect to KR 403 printer in Windows 7 32 bit.
I am getting this error when try to write data to connection.
com.zebra.sdk.comm.ConnectionException: Error writing to connection: ZDesigner KR403
at com.zebra.sdk.comm.DriverPrinterConnection.write(Unknown Source)
at com.zebra.sdk.comm.ConnectionA.write(Unknown Source)
at com.zebra.sdk.comm.ConnectionA.sendAndWaitForValidResponse(Unknown Source)
at com.zebra.sdk.printer.SGD.GET(Unknown Source)
at com.zebra.sdk.printer.SGD.GET(Unknown Source)
at com.zebra.sdk.printer.internal.ZebraPrinterFactoryHelper.getApplNameHocusPocus(Unknown Source)
at com.zebra.sdk.printer.internal.ZebraPrinterFactoryHelper.getLanguage(Unknown Source)
at com.zebra.sdk.printer.internal.ZebraPrinterFactoryHelper.getInstance(Unknown Source)
at com.zebra.sdk.printer.internal.ZebraPrinterFactoryHelper.getInstance(Unknown Source)
at com.zebra.sdk.printer.ZebraPrinterFactory.getInstance(Unknown Source)
at PrintTest.main(PrintTest.java:40)
This is my sample code.
Connection connection = null;
try {
DiscoveredPrinterDriver[] zebraDriverPrinters = UsbDiscoverer.getZebraDriverPrinters();
String printerName = "";
int i=0;
for (DiscoveredPrinterDriver printer : zebraDriverPrinters) {
if (i==1) {
printerName = printer.printerName;
}
i++;
System.out.println(printer.printerName);
}
System.out.println(printerName);
connection = new DriverPrinterConnection(printerName);
connection.open();
Thread.sleep(3500);
ZebraPrinter zebraPrinter = ZebraPrinterFactory.getInstance(connection);
byte[] bytes = IOUtils.toByteArray(new FileInputStream("D:\\test.txt"));
connection.write(bytes);
Thread.sleep(3500);
} catch (ConnectionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (connection != null) {
connection.close();
}
}
1 Replies
Hi < please make sure your driver is set to bidirectional.
You may also want to provide a longer timeToWaitForResponse on the connection object as the KR403 has older USB support.