question

AADHITHYAASV-3617 avatar image
0 Votes"
AADHITHYAASV-3617 asked Sean-Liming commented

How to Open Cashdrawer using POS for .NET v1.14 SDK ?

I'm creating an windows form (C#) to Open drawer and check if cashdrawer is open or close using POS for .NET v1.14 SDK.

Note : Cashdrawer is directly connected to system

Tried following code but no luck

 using Microsoft.PointOfService;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.IO.Ports;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
    
    
 namespace Appletay
 {
     public partial class Login : Form
     {
     
         public PosExplorer myExplorer;
         public CashDrawer myCashDrawer;
         public Login()
         {
             InitializeComponent();
             myExplorer = new PosExplorer(this);
             //myExplorer = new PosExplorer();
             DeviceInfo device = myExplorer.GetDevice("CashDrawer");
             myCashDrawer = (CashDrawer)myExplorer.CreateInstance(device);
    
         }
    
     
    
         private void i0_Click(object sender, EventArgs e)
         {
              myCashDrawer.Open();
             myCashDrawer.Claim(1000);
             myCashDrawer.DeviceEnabled = true;
             myCashDrawer.OpenDrawer();
             myCashDrawer.DeviceEnabled = false;
             myCashDrawer.Release();
             myCashDrawer.Close();
         }
    
        
               
           
     }
 }

getting following error during debug.
65982-snippet.png




Is it looking for specific device connected to my machine and it got failed as it was unable to detect it?

Can someone help me out to short out this please.

Thanks in Advance

windows-formswindows-embedded
snippet.png (26.6 KiB)
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Did you also try myExplorer.GetDevice(DeviceType.CashDrawer)?

0 Votes 0 ·

Thanks @Viorel-1 , I have tried above one and getting following error in next statement.

66357-snippet-1.png


0 Votes 0 ·
snippet-1.png (26.6 KiB)

It seems that GetDevice returns null.

Try using myExplorer.GetDevices() to investigate the list of available devices and their names.

See also similar problems: https://www.bing.com/search?q=PosExplorer+GetDevice+null.

0 Votes 0 ·
Show more comments

Are you still having trouble with this issue?

Did the answer help? If so, please mark it as an answer. Thank you.

0 Votes 0 ·

Hi @AADHITHYAASV-3617,
Do you have a OPOS cashdraw named CashDrawer set up? You can check in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS\CashDrawer. There should be a sub key named CashDrawer.
Best Regards,
Daniel Zhang

0 Votes 0 ·

Thanks @DanielZhang-MSFT , I have checked registry can't able to find OLEforRetail\ServiceOPOS\CashDrawer . I found below drivers which are installed on System.
66392-opos-drivers.png



CITIZEN is a Thermal Printer(Cash Draw is not connected to printer, it direct connect to system) and we don't know cash draw brand.
MetroOPOS 2 , and MS POS for .net 1.12. Not sure.


0 Votes 0 ·
opos-drivers.png (75.9 KiB)
MarkW-5190 avatar image
0 Votes"
MarkW-5190 answered Sean-Liming commented

Hi Sean,

I have a question related to this (slightly old) post. And also, let me prefix all of this with, I'm completely new to POS development.

Per your comment above, I don't see my USB connected CashDrawer in the list of nodes. When I get a list of CashDrawer devices (using PosExplorer's GetDevices) all I see is the MS simulator. Not sure where to go from here because my CashDrawers shows up in Device Manager and seems fine.

As a side step, I created a MyCashDrawer service object class deriving from CashDrawerBase (adorning it with my physical cash drawer's HardwareId [from device manager]). I also adorned with ServiceObject providing all the proper values (see further down). Then in my button click I have:

 _myCashDrawer = new CashDrawerServiceObject();
 //
 _myCashDrawer.Open();
 _myCashDrawer.DeviceEnabled = true;
 _myCashDrawer.Claim(1000);
 _myCashDrawer.OpenDrawer();
 _myCashDrawer.Close();

All is good except OpenDrawer does not 'open the drawer'. I understand why because it just calls the OpenDrawerImpl to which I can't just call OpenDrawer because it's recursive and will result in an overflow.

What should be in the overidden OpenDrawerImpl to actually open the cash drawer?

 [HardwareId("USB\\VID_0451&PID_0909", "USB\\VID_0451&PID_0909")]
 [ServiceObject(DeviceType.CashDrawer, "MyCashDrawer", "My cash drawer", 2, 0)]
 public class CashDrawerServiceObject : CashDrawerBase
 {
     public CashDrawerServiceObject()
     {
         DevicePath = "USB\\VID_0451&PID_0909\\D2E1F03469A7B5C803469A7B5C8D2E1F";
     }

     public override string CheckHealth(HealthCheckLevel level)
     {
         VerifyState(true, true);
         //
         return "Ok";
     }

     public override DirectIOData DirectIO(int command, int data, object obj)
     {
         VerifyState(false, false);
         //
         return new DirectIOData(data, obj);
     }

     public override string CheckHealthText { get; }

     protected override void OpenDrawerImpl()
     {
         //what to do here?
     }
 }


All I need to do is open the cash drawer at this time.

Thanks in advance, Sean.


-Mark

PS - I tried buying your book but your site kept telling me "Confirm Email is required" and I had it filled out with an exact match of my email.



· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You should NOT have to create a service object since MMF should have either an OPOS driver or a POS for .NET service object available. Please contact their technical support for more information: https://www.mmfpos.com/cash-drawers/val-u-line-cash-drawers.html

For the Annabooks Online Store, you should receive an e-mail with a password to activate the account: https://annabooksonlinestore.com/help/


0 Votes 0 ·

That's maybe the confusing part of this then because I installed their driver thinking their service object would be a part of that.

Is the driver that comes with devices not considered the OPOS driver; therefore, requiring a separate download?

I'll reach out to them. Appreciate the help.

0 Votes 0 ·

You will have to talk to MMF about their provided software. The MMF drawer I am using connects through a EPSON POS printer.

0 Votes 0 ·
Sean-Liming avatar image
0 Votes"
Sean-Liming answered

The trick is setting up the OPOS driver or PSO for .NET Service object first, before attempting to access via an application. To verify the OPOS driver is setup correctly, please run the TestApp.exe that is part of the POS for .NET SDK. The TestApp application is found here: C:\Program Files (x86)\Microsoft Point Of Service\SDK\Samples\Sample Application. If you see your cash drawer in the list, you can then attempt to open, claim, and open the cash drawer. If you do not see the cash drawer in the list, then you need to configure the OPOS driver using the manufacturer's utilities.

Is the cash drawer connected via USB, serial, or parallel?



69714-image.png


BTW - You will want to use the latest version of POS for .NET 1.14.1: https://www.microsoft.com/en-us/download/details.aspx?id=55



image.png (38.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.