I am developing a POS using c# with WPF. I need to check if the cash drawer is open or not to tell the user that it needs to be closed before the next sell.
My cash drawer is a dynapos connected to a receipt printer ECLine (I have no drivers installed, just using the generics from windows), this printer is connected by USB to the PC. So far I am able to print using RawPrinterHelper and open the cashdrawer using:
byte[] codeOpenCashDrawer = new byte[] { 27, 112, 48, 55, 121 };
IntPtr pUnmanagedBytes = new IntPtr(0);
pUnmanagedBytes = Marshal.AllocCoTaskMem(5);
Marshal.Copy(codeOpenCashDrawer, 0, pUnmanagedBytes, 5);
RawPrinterHelper.SendBytesToPrinter(stringPrinterName, pUnmanagedBytes, 5);
Marshal.FreeCoTaskMem(pUnmanagedBytes);
In the same way I am able to open the cash drawer, I was hoping to get the status of it by sending some bytes. I found this solution in which says:
To get the status of the drawer I need to use DLE EOT n
The problem is that I can't get to know if the bytes are the good ones since I can't get a response from the RawPrinterHelper
when using the SendBytesToPrinter
method.
Questions:
1) Is there a way to get this status using RawPrinterHelper?
2) If the bytes I am sending are not the correct ones, how can i determine which ones are the correct ones?
3) Do I need to install a driver for the printer? I have read about some people that does it, but I would not like to do this because each place in where my POS is installed has different hardware.