.NET Framework Developer Center > .NET Development Forums > POS for .NET > How to open a Cash Drawer using C#.NET..?
Ask a questionAsk a question
 

AnswerHow to open a Cash Drawer using C#.NET..?

  • Wednesday, August 12, 2009 11:36 AMPavan kumar Pabothu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi all,

    I am developing a POS Application. Here I want to Open a Cash Drawer. Is it different procedures to Open different types of Cash drawers.

    Can anybody help me on this...

    Can I use MS .NET POS SDK for this purpose...

    Thanks in Advance

Answers

  • Wednesday, August 12, 2009 8:31 PMYortAnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    If you do not use the Pos .Net SDK you will find you need to send different commands to different printers/cash drawers (some cash drawers connect to a printer rather than direct to the PC). Some printers and cash drawers I have worked with just need a fixed, short character string sent to them others had more complex strings where you had to specify pulse length, drawer number etc.

    If you use the Pos .Net SDK then your code will work with any printer/cash drawer that you have a service object for (either a Pos .Net service object or a legacy OPOS service objecct). Pos .Net is by far the best way to go, in my opinion.

    Go ahead and download the Pos .Net SDK and have a look at how to use it, the documentation is quite good and there is a cash drawer class specifically for dealing with cash drawers.

    One of the other benefits to using the Pos .Net SDK is that not only can you open the drawer,  but  you can also get the status of the drawer (whether it's open or not) if the hardware supports it.

    Good luck, and post again if you get stuck.
  • Thursday, August 13, 2009 4:19 AMSean LimingMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer


    Yes, POS for .NET follows the UPOS specification. The idea is to write an application that uses the cash drawer class to call OpenCashdrawer. The key to this is finding hardware that has a service object or OPOS driver, which carries out the OpenCashdrawer call. Different manufacturers support different interface and levels of driver support. Which cash drawer are you using?

    For the WASP cash drawer example in the book, I created an SO that used the escape code squence - Chr(&H1B) & Chr(&H70) & Chr(0) & Chr(25) & Chr(30) to open the drawer. The cash drawer interfaces to the POS printer, which has a serial interface to the PC.

    Sample code can be found here: http://www.sjjmicro.com/WEPOS.html

    -Sean


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
  • Friday, August 14, 2009 4:50 PMSean LimingMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    So long as you have a service object for the cash drawer and you only have one cash drawer attached (since you are calling for the default device), the application code should work. That is the basic idea behind UPOS.

    -Sean

    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
  • Friday, August 14, 2009 12:20 PMPavan kumar Pabothu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Sir,

    I got a code to open a cash drawer using the POS for .NET.


    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.PointOfService;

    namespace POS
    {
        public class CashDrawerClass
        {
            CashDrawer myCashDrawer;
            PosExplorer explorer;

            public CashDrawerClass()
            {
                explorer = new PosExplorer(this);
                DeviceInfo ObjDevicesInfo = explorer.GetDevice("CashDrawer");
                myCashDrawer = explorer.CreateInstance(ObjDevicesInfo);
            }

            public void OpenCashDrawer()
            {
                myCashDrawer.Open();
                myCashDrawer.Claim(1000);
                myCashDrawer.DeviceEnabled = true;
                myCashDrawer.OpenDrawer();
                myCashDrawer.DeviceEnabled = false;
                myCashDrawer.Release();
                myCashDrawer.Close();
            }
        }
    }

    Will it works for all Cash drawers to Open them...?

    Thanks in Advance

All Replies

  • Wednesday, August 12, 2009 8:31 PMYortAnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    If you do not use the Pos .Net SDK you will find you need to send different commands to different printers/cash drawers (some cash drawers connect to a printer rather than direct to the PC). Some printers and cash drawers I have worked with just need a fixed, short character string sent to them others had more complex strings where you had to specify pulse length, drawer number etc.

    If you use the Pos .Net SDK then your code will work with any printer/cash drawer that you have a service object for (either a Pos .Net service object or a legacy OPOS service objecct). Pos .Net is by far the best way to go, in my opinion.

    Go ahead and download the Pos .Net SDK and have a look at how to use it, the documentation is quite good and there is a cash drawer class specifically for dealing with cash drawers.

    One of the other benefits to using the Pos .Net SDK is that not only can you open the drawer,  but  you can also get the status of the drawer (whether it's open or not) if the hardware supports it.

    Good luck, and post again if you get stuck.
  • Thursday, August 13, 2009 4:19 AMSean LimingMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer


    Yes, POS for .NET follows the UPOS specification. The idea is to write an application that uses the cash drawer class to call OpenCashdrawer. The key to this is finding hardware that has a service object or OPOS driver, which carries out the OpenCashdrawer call. Different manufacturers support different interface and levels of driver support. Which cash drawer are you using?

    For the WASP cash drawer example in the book, I created an SO that used the escape code squence - Chr(&H1B) & Chr(&H70) & Chr(0) & Chr(25) & Chr(30) to open the drawer. The cash drawer interfaces to the POS printer, which has a serial interface to the PC.

    Sample code can be found here: http://www.sjjmicro.com/WEPOS.html

    -Sean


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
  • Friday, August 14, 2009 12:20 PMPavan kumar Pabothu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Sir,

    I got a code to open a cash drawer using the POS for .NET.


    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.PointOfService;

    namespace POS
    {
        public class CashDrawerClass
        {
            CashDrawer myCashDrawer;
            PosExplorer explorer;

            public CashDrawerClass()
            {
                explorer = new PosExplorer(this);
                DeviceInfo ObjDevicesInfo = explorer.GetDevice("CashDrawer");
                myCashDrawer = explorer.CreateInstance(ObjDevicesInfo);
            }

            public void OpenCashDrawer()
            {
                myCashDrawer.Open();
                myCashDrawer.Claim(1000);
                myCashDrawer.DeviceEnabled = true;
                myCashDrawer.OpenDrawer();
                myCashDrawer.DeviceEnabled = false;
                myCashDrawer.Release();
                myCashDrawer.Close();
            }
        }
    }

    Will it works for all Cash drawers to Open them...?

    Thanks in Advance

  • Friday, August 14, 2009 4:50 PMSean LimingMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    So long as you have a service object for the cash drawer and you only have one cash drawer attached (since you are calling for the default device), the application code should work. That is the basic idea behind UPOS.

    -Sean

    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
  • Thursday, October 29, 2009 11:24 AMBaditala Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Pavan,

    Can you please post the code for CashDrawer. how to create custom SO for CashDrawer. 
    Please help me in creating the SO for any POS Device.

    Please respond to prasad.pioneer@gmail.com 


    Thanks in advance.
  • Thursday, October 29, 2009 1:10 PMSean LimingMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    There is an example in my book - source can be downloaded from the book site: http://www.sjjmicro.com/WEPOS.html

    -Sean

    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step