Get print status of KR403 printer when connect via USB cable

// Expert user has replied.
S Sophie Huynh 11 months 2 weeks ago
148 2 0

My WPF app is using .NET 7 and it need to connect with KR403 printer to check connectivity and print status. I installed Zebra.Printer.SDK v2.16.2905 to Visual Stusdio 2022 from Nuget but I can't find the .dll files for .NET 7 to add my project. So I try to add the lib of .Net4.7.1 and I can check to connectivity but I always get below error when checking current status.

 Using this code:

string printerName ="";
List<DiscoveredPrinterDriver> discoPrinters = UsbDiscoverer.GetZebraDriverPrinters();
foreach (DiscoveredPrinterDriver device in discoPrinters)
{
	printerName = device.PrinterName;
}
Connection connection = new DriverPrinterConnection(printerName);
connection.Open();
ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);
PrinterStatus printerStatus = printer.GetCurrentStatus();

 Exception message:

Zebra.Sdk.Comm.ConnectionException: Malformed status response - unable to determine printer status
  at Zebra.Sdk.Printer.Internal.PrinterStatusZpl.GetStatusInfoFromPrinter()
  at Zebra.Sdk.Printer.Internal.PrinterStatusZpl.GetPrinterStatus()
  at Zebra.Sdk.Printer.Internal.PrinterStatusZpl.UpdateStatus()
  at Zebra.Sdk.Printer.PrinterStatus.GetStatusFromPrinter()
  at Zebra.Sdk.Printer.PrinterStatus..ctor(Connection printerConnection)
  at Zebra.Sdk.Printer.Internal.PrinterStatusZpl..ctor(Connection connection)
  at Zebra.Sdk.Printer.Internal.ZebraPrinterZpl.GetCurrentStatus()

So, how I get the status of the KR403? Anyone can help me to solve this error?

Besides, is it normal if I use Windows PrintDocument.PrintPage Event to print receipt?

Please Register or Login to post a reply

2 Replies

S Steven Si

What is the setting of the device.languages on the KR403? A KR403 can be either on ZPL or on CPCL. If the device.languages and the printer instance mismatch, the malformed status response error will show.

// Get a printer instance and assume the device.languages as ZPL by default
ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);
PrinterStatus printerStatus = printer.GetCurrentStatus();
// Get a printer instance explicitly using ZPL as the device.languages
ZebraPrinter printer = ZebraPrinterFactory.GetInstance(PrinterLanguage.ZPL, connection);
PrinterStatus printerStatus = printer.GetCurrentStatus();
S Sophie Huynh

I use the below command in Zebra Setup Utilities to check and result that the current language is ZPL. Then I use this code to get the status but it still gets the malformed status error. What do I need to do next?

ZebraPrinter printer = ZebraPrinterFactory.GetInstance(PrinterLanguage.ZPL, connection);
PrinterStatus printerStatus = printer.GetCurrentStatus();
! U1 getvar "device.languages"
! U1 getvar "device.pnp_option" <CR>
"hybrid_xml_zpl""zpl"
CONTACT
Can’t find what you’re looking for?