What errors are you getting?
Also not all Zebra printers support a low paper sensor. Most will only give a paper out error. Which printer are you using?
The printers we are using in all of our kiosks is the KR403 unit with the paper sensor option.
The errors we are getting occur in the Zebra.Printing.UsbPrinterConnector.Read function. It is telling us the buffer is not large enough. I have tried making buffer size as large as 8192 when I call this function. Is my approach even correct? I am really looking for a proper example how to read the status in C# using this.
The code from the UsbPrinterConnector.Read function is below.
public override int Read(byte buffer, int offset, int count)
// USB 1.1 ReadFile in block chunks of 64 bytes
// USB 2.0 ReadFile in block chunks of 512 bytes
if (readBuffer == null)
readBuffer = new byte[ReadBufferSize];
AutoResetEvent sg = new AutoResetEvent(false);
NativeOverlapped ov = new NativeOverlapped();
ov.OffsetLow = 0;
ov.OffsetHigh = 0;
ov.EventHandle = sg.Handle;
if (!FileIO.ReadFile(usbHandle, readBuffer, ReadBufferSize, out read, ref ov))
if (Marshal.GetLastWin32Error() == FileIO.ERROR_IO_PENDING)
throw new Win32Exception(Marshal.GetLastWin32Error());
FileIO.GetOverlappedResult(usbHandle, ref ov, out read, true);
Array.Copy(readBuffer, 0, buffer, offset, read);
Has an example of how to retrieve the KR403 low paper status in C# been found? We are still not sure if our approach is correct?
Sorry for the delay.
You are correct that the ZPL ~HQES command is the proper one to use for this on the KR403.
The process should be:
// Read paper status
string spaperout = "~HQES";
string terminator = 0x03; // hex ETX
byte buffer2 = ASCIIEncoding.ASCII.GetBytes(spaperout);
byte buffer3 = connector.SendAndWaitForResponse(buffer2,3000,500,terminator);
if ((0 == buffer3.length) || (2 != buffer3))
// read failed or read in extra data from some other command.
// location of paper low bit I believe is 134, check if this byte is ASCII '8'
if ( 56 <= buffer3)
// show paper low message
P.S. "Paper out" is byte 88 == 1 or is odd
Hope this helps!
Thank you for your continued help.
It appears that the Zebra.Printing.UsbPrinterConnector does not have a method called SendAndWaitForResponse.
Is it possible a newer version of PrinterConnector is available?
Have you been able to identify the correct Zebra.Printing.UsbPrinterConnector that has the SendAndWaitFor Response method?