Checking status of KR403 with winspool in Java

Hi. I have problem with checking status of zebra KR403 in Java. I'm trying to use winspool from jna but still geting status 0 for PRINTER_INFO_2.

 

    public static Winspool2.PRINTER_INFO_2 getPrinterInfo2(String printerName) {         IntByReference pcbNeeded = new IntByReference();         IntByReference pcReturned = new IntByReference();         HANDLEByReference pHandle = new HANDLEByReference();           Winspool2.INSTANCE.OpenPrinter(printerName, pHandle, null);           Winspool2.INSTANCE.GetPrinter(pHandle.getValue(),                 2,                 null,                 0,                 pcbNeeded);         if (pcbNeeded.getValue() <= 0) {             return new Winspool2.PRINTER_INFO_2();         }           Winspool2.PRINTER_INFO_2 pinfo2 = new Winspool2.PRINTER_INFO_2(pcbNeeded.getValue());           Winspool2.INSTANCE.GetPrinter(pHandle.getValue(),                 2, pinfo2.getPointer(),                 pcbNeeded.getValue(),                 pcReturned);         pinfo2.read();           return pinfo2;     }

Gregory Pawlik
Hi Lukasz,Have you looked

Hi Lukasz,

Have you looked into the Link-OS™ Multiplatform SDK | Zebra​ ?

It offers JAVA libraries that can get status information from Zebra printers such as  the KR403.

Hope this helps,

Greg

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lukasz Byjos
Is is possible to check paper

Is is possible to check paper status with Link-OS? Btw, great name for sdk -.-

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Gregory Pawlik
Yes, the Link-OS SDK can

Yes, the Link-OS SDK can retrieve paper status from the printer.

It does contain sample code on how to do so.

Greg

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lukasz Byjos
This sounds great! Currently

This sounds great! Currently I have created status checker with ZPL and TCP connection.
But can you show me code where I can check all possible statuses for KR403?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Gregory Pawlik
In the documentation of the

In the documentation of the SDK, there is sample code under the PrinterStatus class that shows the following:


import com.zebra.sdk.comm.Connection;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.printer.PrinterStatus;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;

public class PrinterStatusExample {
  PrinterStatus printerStatus = printer.getCurrentStatus();
  if (printerStatus.isReadyToPrint) {
  System.out.println("Ready To Print");
  } else if (printerStatus.isPaused) {
  System.out.println("Cannot Print because the printer is paused.");
  } else if (printerStatus.isHeadOpen) {
  System.out.println("Cannot Print because the printer head is open.");
  } else if (printerStatus.isPaperOut) {
  System.out.println("Cannot Print because the paper is out.");
  } else {
  System.out.println("Cannot Print.");
  }
  } catch (ConnectionException e) {
  e.printStackTrace();
  } catch (ZebraPrinterLanguageUnknownException e) {
  e.printStackTrace();
  } finally {
  connection.close();
  }
  }
}

  public static void main(String[] args) throws Exception {   Connection connection = new TcpConnection("192.168.1.100", TcpConnection.DEFAULT_ZPL_TCP_PORT);   try {   connection.open();   ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lukasz Byjos
But as I saw in SDK I can't

But as I saw in SDK I can't check if paper is low or anything related to paper sensor.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Gregory Pawlik
True.The KR403 does have

True.

The KR403 does have features pertaining to paper statuses that the SDK does not contain methods for.

However, using the sendAndWaitForResponse method in the Connection class of the SDK you can send the ~HQES command to the printer and get back the status flags for the paper sensors including the "paper near end" sensor.

Greg

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments