I am creating a POS app. I started with the POS printer and it is working. After that I added the "open cash drawer" functionality. But it interferes with the POS printer somehow.
So what is happening?
When I only claim a POS printer, printing works fine. Also when I only claim a Cash drawer, the drawer opens fine. So no problem there.
But when I claim both (POS printer and drawer) at the same time, the printing gets stuck or freezes. The drawer still opens fine. Most of the time when I claimed both, the first print looks fine, but it doesn't cut the paper. When I print again the program freezes.
Somehow I can not use these two objects at the same time:
OPOSPrinter oposprinter = new OPOSPrinter(); // Has the Windows.Devices.PointOfService.PosPrinter class
OposCashDrawer oposcashdrawer = new OposCashDrawer(); // Has the Windows.Devices.PointOfService.CashDrawer class
When I claimed the ClaimedCashDrawer
then this line gives ClaimedPrinter = await CurrentPrinter.ClaimPrinterAsync();
a null
.
I have a sample project uploaded here: https://github.com/hellyeahniels/TestPrintAndDrawer
Could please someone explain to me what is wrong and how to fix this?
Thanks in advance.
It consists of two factors.
Such a configuration is called a hydra device.
Some printer vendors have a specification that allows the printer and cash drawer to operate independently even in such a configuration.
You don't have to be careful if you switch to a printer from that vendor, or switch the cache drawer to one that works independently, not via a printer.
If you want to use it as it is, it seems that the usage is described in the notes of OPOS service object provided by the printer vendor, so please follow it.
Probably, the printer and the cache drawer cannot be used at the same time, and if they are used, the exclusive control right is acquired by the Claim method, and when it is finished, the exclusive control right is released by the Release method.
By the way, it seems that the API you are using is Windows.Devices.PointOfService
, not POS for.NET
.
Please correct the description of the question and the contents of the tag to suit you.
And if so, replace the method name I presented with a suitable name.