Kick Cash Drawer using Control Code - c#

I am working with Epson Thermal printer and Cash Drawer. Cash Drawer is connected with the printer. Reference to http://keyhut.com/popopen.htm, the code to kick cash drawer is 27,112,0,50,250. I tried to send this code to printer but nothing happens. I used POS for .NET and the printer is registed in SetupPos.
Here is my code:
deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
m_Printer.Open();
m_Printer.Claim(1000);
m_Printer.DeviceEnabled = true;
//command = "ESC|p|0|25|251";
command = "\x1B|\x70|\x00|\x19|\xFB";
m_Printer.PrintImmediate(PrinterStation.Receipt, command);
//m_Printer.CutPaper(100);
m_Printer.DeviceEnabled = false;
m_Printer.Release();
m_Printer.Close();
Print text is ok, but send code is not working. What can I do? Thanks.

POS for.NET(UnifiedPOS) specification does not support CashDrawer opening by the PrintNormal()/PrintImmediate() method of POSPrinter device.
Since there is a independent CashDrawer device associated with the POSPrinter device, please open() the corresponding device as a CashDrawer and open the drawer with the OpenDrawer() method.
However, depending on the vendor, there is a possibility of supporting usage like you.
I do not have information on whether EPSON POSPrinter supports such usage or not.
Please ask EPSON or your distributor whether or not you can use such a way.
In addition:
Instead of POS for.NET, there is a way to install and use a device driver as a regular Windows Printer.
Some vendors offer Windows Printer Driver for receipt printers and also support paper cutting and drawer opening functions.
In EPSON, it is provided under the name Advanced Printer Driver.
The questioner seems to have solved the problem using this.
However, this device driver is often used exclusively with POS for.NET/OPOS/JavaPOS, and when printing, it is necessary to use Windows standard printing API.

The third code from open drawer kick code "ESC|p|0|25|251" to send is actually a symbol to control cash drawer 1 or 2, which is using '0' or '1'. The 0 or 1 symbol in the ASCII table is mapped to decimal 48 or 49. So you need to use the Hex x30 or x31 not x00.
Just to add more info, the forth and the fifth code are the time when the signal kick is ON or OFF by sending decimal (value between 0 to 255) * 2ms.
I hope this solve the problem if you still want to use the cash drawer kick code and attach the device to the printer.

Related

Image capturing via SNAPI.dll API for Symbol barcode scanner DS4208

I want to capture image via SNAPI API from Symbol (currently Zebra) barcode scanner, model DS4208 (we're also using another but compatible models from Zebra).
Barcode capturing/recognition works pretty well, but looks like SnapiDLL.SNAPI_SnapShot(hScanner) call don't work correctly: no WM_XFERSTATUS message received at all.
Here is small & simplified code snippet:
// Set image format
short[] parms = new short[2] { (short)SnapiParamIds.ImageFileType, (short)SnapiImageTypes.Jpeg };
var retCode = SnapiDLL.SNAPI_SetParameters(parms, 2, _devHandles[0]);
Debug.WriteLine($"SNAPI_SetParameters retCode={retCode}");
Application.DoEvents();
Thread.Sleep(50);
retCode = SnapiDLL.SNAPI_SnapShot(_devHandles[0]);
Debug.WriteLine($"SNAPI_SnapShot retCode={retCode}");
Application.DoEvents();
Thread.Sleep(50);
retCode = SnapiDLL.SNAPI_PullTrigger(_devHandles[0]);
Debug.WriteLine($"SNAPI_PullTrigger retCode={retCode}");
Application.DoEvents();
Thread.Sleep(50);
Return codes always 0 (i.e. no error), but no WM_XFERSTATUS message received by my message handler.
P.S. C# application from Zebra's SDK which is using CoreScanner driver and OCX, is working fine and able to capture images and video. But I'd like to avoid CoreScanner driver installation for some reasons; for barcode scanning small and simple SNAPI.dll works pretty fine, and I expect to get it work for image capturing too - probably, I'm doing something wrong...
P.P.S. Guys, please DO NOT COMMENT if you have NO EXPERIENCE WORKING WITH SYMBOL BARCODE SCANNERS & SNAPI, and CAN NOT PROVIDE a working snippet!
After contacting Zebra tech support (they are successors of Symbol/Motorola barcode scanner business), I figured out that the imaging/video functionality is broken in SNAPI.dll for the x64 OSes (but most of the rest API calls are working properly). Unfortunately, SNAPI isn't supported by Zebra anymore, and I should use Zebra's CoreScanner API. The good news is: this API is working fine, as it supposed to be. Not a very good news: I should use additional installation package from Zebra.

Why would a Zebra QLn220 Printer ignore the first couple of commands sent to it after sending it a command to update some settings?

I am sending commands to a Zebra QLn220 for it to print labels (naturally). I also have code, though, that assigns values to certain printer settings, such as:
const string quote = "\"";
string keepPrinterOn = string.Format("! U1 setvar {0}power.dtr_power_off{0} {0}off{0}", quote);
string advanceToBlackBar = string.Format("! U1 setvar {0}media.sense_mode{0} {0}bar{0}", quote);
string advanceToGap = string.Format("! U1 setvar {0}media.sense_mode{0} {0}gap{0}", quote);
PrintUtils.SendCommandToPrinter(keepPrinterOn);
if (radbtnBar.Checked)
{
PrintUtils.SendCommandToPrinter(advanceToBlackBar);
}
else if (radbtnGap.Checked)
{
PrintUtils.SendCommandToPrinter(advanceToGap);
}
This works - after running that code with radbtnBar checked, those settings are now (as seen via running "! U1 getvar "allcv"" in the Zebra Setup Utilities app):
power.dtr_power_off : off , Choices: on,off
media.sense_mode : bar , Choices: bar,gap
The problem is that after setting those values via the code above, and then attempting to print labels (after a lapse of at least 20 seconds, and have tested up to more than a minute), the first couple of attempts to print a label silently fail (there is no err msg, it is just that no printing takes place). On the third attempt, the label prints. Why would setting these vals cause the printer to temporarily "go deaf," and is there anything I can do to shake it back to wakefulness following the programmatic application of those settings so that it will print immediately?
Once the QLn220 finally regains responsiveness, it continues to print immediately on subsequent executions of the app with no delays; it's only after sending those commands ("power.dtr_power_off" and "media.sense_mode") that the printer is knocked out of its orbit for a season. A real zebra would never be as stubborn as a mule like this.
UPDATE
Banno's idea did the trick, apparently (appending crlfs ("\r\n")) to the commands to set the printer vars.
So it seems that what was happening was something like this:
Command 1 was sent to the printer to set a val (with no crlf).
Command 2 was sent to the printer to set another val (also with no crlf)
A label was then attempted to be printed; it didn't print. Seeing that it did have a crlf, though, the printer seemed to say, "Oh, you finally gave me one of the crlfs you owe me! But you're not getting off that easy - you still owe me one!"
A second attempt to print a label caused the printer to say, in effect, "Okay, then, you've paid your crlf debt; from now on, I will listen to the commands you send (as long as you terminate them with the crlf I so ravenously crave)."
UPDATE 2
Sometimes it still doesn't work (inconsistent behavior); I found that I had to "poke it" to get it to quit its somnambulism; see What Zebra QLn220 settings do I need to set (and to what value[s]) to get a setting to "stick"?
append "\r\n\" to each command

POS for .Net can not detect printer

I am using POS for .Net framework version 1.12 for one of my project.
Microsoft POS for .NET is a class library that is part of Microsoft Windows Embedded for Point of Service.
http://msdn.microsoft.com/en-us/library/ms828083%28v=winembedded.10%29.aspx
private PosPrinter GetReceiptPrinter()
{
PosExplorer posExplorer = new PosExplorer(this);
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter);
return (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);
}
above is the sample code for find the printer. Now my issue is that POS is not able to detect the printer but only open simulator with data when i run my application.
can anyone please help me ?
I had developed an application for a POS running Windows CE as the operating System but for that POS, the manufacturer provided a custom dll for invoking the operations of the printer which I consumed in my C# code. Check with the POS manufacturer and see if they are providing custom dll for the same.
Your line of code
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter);
will return the default or first PosPrinter found, which in your case looks like it is the simulator.
You need to either (1) Iterate over the collection of printers and somehow select the one you want. i.e.
foreach (DeviceInfo deviceInfo in explorer.GetDevices(DeviceType.PosPrinter))
{
if (isThisThePrinterIWant(deviceInfo)) // user defined function (maybe lookup saved preference file)
{
return (PosPrinter)posExplorer.CreateInstance(deviceInfo );
}
} // Note: GetDevices() not GetDevice()
or (2) Set a logical name for your printer (using software that came with your printer, or the POSDM utility included with Pos for .Net SDK) and change the above line to
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "madeUpLogicalName");
or (3) Simply set the desired printer as the default printer, and leave your code the way it is.

how to print to Printronix Printer?

Does someone has already printed to a printronix printer (serie t5000r) using .NET (visual basic or C#) ?
We already have the file (txt) with the code to generate the label until I know the code it's PGL.
What've done was to use file.copy() to send the file to the LPT1 port (we use this method with Zebra printers and it works fine) but the printer print plain text instead of the label with it's format (barcode, titles, etc).
Any idea?
Here is the label code, thank you in advance:
^CONFIG
SFCC;94
END
^CONFIG
LEFT MARGIN;5
END
^PAPER;LENGTH 80
^PAPER;WIDTH 60
^PAPER;PORTRAIT
^CREATE;ds-label
FONT;FACE 92250
ALPHA
AF2;100;DARK;POINT;8;6;45;40
AF4;100;DARK;POINT;13;6;45;40
AF60;100;DARK;POINT;18;6;45;40
AF61;100;POINT;22;6;30;30
STOP
FONT;FACE 93779
ALPHA
POINT;5;6;10;0;Some data 1:
POINT;10;6;10;0;Some data 2:
POINT;15;6;10;0;Delivery Address:
POINT;20;6;10;0;NSC Name:
POINT;24;6;10;0;CODE barcode:
POINT;34;6;10;0;CODE number:
AF63;17;DARK;POINT;37;6;46;23
POINT;39;6;10;0;PID:
AF64;26;DARK;POINT;41;6;28;14
POINT;43;6;10;0;Label Code:
AF65;8;POINT;44;6;15;0
POINT;46;6;10;0;Date:
AF66;10;POINT;47;6;15;0
STOP
BARCODE
C3/9;X1;H10;BF10;17;26;8
STOP
END
^EXECUTE;ds-label
^AF2;ALVSBORGSH. YYY-XXX
^AF4;IMMINGHAM PORT IMPORTS
^AF60;THE CITY
^AF61;Great Britain
^BF10;11111111111111111
^AF63;11111111111111111
^AF64;AAAAAAY1T1MMA7290B11111111
^AF65;0067PXXX
^AF66;2008-10-15
^NORMAL
^CONFIG
RESET
END
I guess your text get intercepted somewhere on the way and rendered to a page instead of sent directly to the printer port. I found this article - How to send raw data to a printer by using Visual C# .NET - that may be of help.

PrintNormal() Issue 'It is not Initialized'

Current C# POS.NET Printing Issue:
PrintNormal() Throws Exception = 'It is not initialized'
CheckHealth = 'It is not initialized'
'It is not initialized' exception when Printing to Epson TM-T88IV
Using POS for .NET 1.12 and the Epson OPOS ADK for .NET (v1.11.9) service-objects
Successfully able to Open, Claim and Set the DeviceEnabled-true for PosPrinter
Issue sending anything to the printer after this
PrintNormal() results in a 'It is not initialized' exception being thrown.
CheckHealth Utility that came with the Epson OPOS ADK results in exactly the same error. When using PrintNormal(PrinterStation.Receipt the exception is 'The specified station is not mounted."
printer prints fine using direct parallel
printer itself prints
How can we not throw the exemption with the message - 'It is not initialized'?
void K8POSPrint()
{
/// <summary>
/// PosPrinter object
/// </summary>
PosPrinter m_Printer = null;
try
{
//Use a Logical Device Name which has been set on the SetupPOS.
string strLogicalName = "PosPrinter";
try
{
//Create PosExplorer
PosExplorer posExplorer = new PosExplorer();
DeviceInfo deviceInfo = null;
try
{
// Device Info is not null when the printer has the logical name
deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
}
catch (Exception ExDevice)
{
}
//Open the device
m_Printer.Open();
//Get the exclusive control right for the opened device. Then the device is disable from other application.
m_Printer.Claim(1000);
//Enable the device.
m_Printer.DeviceEnabled = true;
// ////CheckHealth.
//m_Printer.CheckHealth(Microsoft.PointOfService.HealthCheckLevel.Interactive);
// //As using the PrintNormal method, send strings to a printer, and print it [\n] is the standard code for starting a new line.
/// Current Issue Next Line thows an exception - 'It is not initialized'
m_Printer.PrintNormal(PrinterStation.Receipt, "Hey Now OPOS for .NET\n");
// the next line would throw the exception 'The specified station is not mounted.'
// m_Printer.PrintNormal(PrinterStation.Slip,"Hey Now Slip OPOS.NET\n");
}
catch (PosControlException)
{
}
}
catch (Exception ex)
{
}
}
Additional Information:
Programs installed while attempting to print on the pos printer are:
1. Installed APD4 Printer Driver Epson TI88IV
APD_412EWM.exe
https://www.epsonexpert.com/ee/techRes/index.htm?ProductId=570
After this set in control panel printers I can select the printer's properties & print a test to the printer successfully.
2. Installed Microsoft POS.NET 1.12
POSfor.NET.msi
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=eaae202a-0fcc-406a-8fde-35713d7841ca
3. Installed Epson OPOS ADK v2.67
ADK267ER4.exe
https://www.epsonexpert.com/ee/appDev/appDevOPOS.htm
4. Installed EPSON OPOS ADK for .NET 1.11.8
OPOSN 1 11 18.exe
https://www.epsonexpert.com/ee/appDev/appDevOPOS.htm
5. Installed OPOS Common Control Objects 1.13.001
OPOS_CCOs_1.13.001.msi
http://monroecs.com/oposccos_current.htm
6. SetupPOS - Added device & Logical Name
7. Check Health still throws the errors
It is not initialized
OPOS_E_ILLEGAL 10007 (0x00002717)
The problem might not be software, but hardware. I saw a similar question (at http://social.msdn.microsoft.com/Forums/vstudio/en-US/446fd4cc-db6b-4822-b3c8-7d9a98bf7eb4/it-is-not-initialized-when-trying-to-printnormal?forum=posfordotnet), where the developer was using an extension cable which was not parallel. As soon as he connected the parallel cable directly to the printer (without the extension cable), his software worked. This was after he called Epson and ordered a newer printer, because they told him his original printer was not compatible with .NET, so that could also be your problem.
I had the same error "It is not initialized" on brand new Epson TM-T88VI.
The printer came with IDN Card and default the ethernet card was partially blocked. You can use the ethernet card to connect to "Epson Net Config", but it did not work when you try to print by OPOS ADK for NET.
The solution was to set switches on IDN Card as:
DS1
DS2
DS3
DS4
DS5
DS6
DS7
OFF
OFF
OFF
OFF
ON
ON
ON
Make sure Power OFF when you changing the switches.

Categories

Resources