Java SDK getCurrentStatus on USB direct takes 10 seconds to return


I have downloaded the JAVA SDK and tried to pritn to a ZEBRA ZD620 using direct USB communication without driver
Printing labels is immediate while getting the printer status take about 10 seconds.
As you can see in the code I have used two ways to get the Host Status:

Connection.sendAndWaitForResponse("~Hs".getBytes(), 2000, 2000, "V");

Any suggestion?

public static void usbDriverlessTest() throws ConnectionException {
System.out.println("Discovered USB printer list:\r\n");

DiscoveredUsbPrinter discoveredPrinter = null;
for (DiscoveredUsbPrinter printer : UsbDiscoverer.getZebraUsbPrinters(new ZebraPrinterFilter())) {
discoveredPrinter = printer;
System.out.println("End USB printer list\r\n");

Connection imz =;
try {;
byte[] hi_return = null;
ZebraPrinter printer = ZebraPrinterFactory.getInstance(imz);

String label = "^XA^FO17,16^GB379,371,8^FS^FT65,255^A0N,135,134^FDTEST^FS^PQ1,0,1,N^XZ";

// printer.sendCommand(label);

SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

System.out.println(sdf.format(new Date()));

PrinterStatus printerStatus = printer.getCurrentStatus();
System.out.println("printerStatus.labelLengthInDots=" + printerStatus.labelLengthInDots);
System.out.println("printerStatus.labelsRemainingInBatch=" + printerStatus.labelsRemainingInBatch);
System.out.println("printerStatus.numberOfFormatsInReceiveBuffer=" + printerStatus.numberOfFormatsInReceiveBuffer);
System.out.println("printerStatus.isReadyToPrint=" + printerStatus.isReadyToPrint);
System.out.println("printerStatus.isReceiveBufferFull=" + printerStatus.isReceiveBufferFull);

System.out.println(sdf.format(new Date()));

hi_return = imz.sendAndWaitForResponse("~Hs".getBytes(), 2000, 2000, "V");

System.out.println(new String(hi_return));

System.out.println(sdf.format(new Date()));

hi_return = imz.sendAndWaitForResponse("~HQES".getBytes(), 2000, 2000, "V");

System.out.println(new String(hi_return));

System.out.println(sdf.format(new Date()));

} catch (ZebraPrinterLanguageUnknownException e) {
// TODO Auto-generated catch block
} finally {

Submitted by SSi1 on November 19, 2021 Permalink

Using the getCurrentStatus() is the correct way to obtain the printer status. Instead of using printer.getCurrentStatus(), I'd suggest to use either PrinterUtil.getCurrentStatus() or printerLinkOs.getCurrentStatus(). This way, you save about 5 seconds. See the code snippet below.;

ZebraPrinter printer = ZebraPrinterFactory.getInstance(PrinterLanguage.ZPL, imz);


// Take 10sec to return. Slowest
PrinterStatus printerStatus = printer.getCurrentStatus();


// Take 5sec to return. Saved 5sec over printer.getCurrentStatus()
PrinterStatus printerStatus = PrinterUtil.getCurrentStatus(imz, PrinterLanguage.ZPL);


// To use Link-OS printer object
ZebraPrinterLinkOs printerLinkOs = ZebraPrinterFactory.createLinkOsPrinter(printer);

// Take 5sec to return. Same as PrinterUtil.getCurrentStatus()
PrinterStatus printerStatus = printerLinkOs.getCurrentStatus();

Alternatively, we can modify the MaxTimeoutForRead on the connection object. The default is 5 seconds. To shorten the value, we call the setMaxTimeoutForRead() on the connection object. For example, if we want to change the default 5 seconds to a half second, we do the following. So that we shorten the time of the return from getCurrentStatus() .

// Shorten the timeout to 0.5 second.