Command to open cash drawer

Asked

Viewed 693 times

2

I’m trying to make a button that sends a command to open the cash drawer connected to the Tanca TP-650 printer. Below is the method I’m trying.

    public static void abrirGaveta(bool flag)
    {
        if (flag == true && Properties.Settings.Default.ImpressoraGaveta == 1)
        {
            //Metoto para abrir a gaveta


            const int charCode = 27;
            const int charCode2 = 251;
            const int charCode3 = 227;
            var specialChar = Convert.ToChar(charCode);
            var specialChar2 = Convert.ToChar(charCode2);
            var specialChar3 = Convert.ToChar(charCode3);
            string cmdText = "" + specialChar + specialChar2 +"22|" + specialChar3;

            string driver = "TANCA TP-650";
            string comandoAbertura = cmdText;
            RawPrinterHelper.SendStringToPrinter(driver, comandoAbertura);
        }
    }

No error, but it also does not open the drawer.

  • Are you sure you’re sending the correct code for this?

  • so, this one I’ve tried with several codes I’ve been finding on the internet. I’m hoping that someone here has done.

  • And is it connected on the printer output anyway? It is not serial?

  • The drawer is connected to the printer. The printer is USB

  • 3

    Have you looked at the example in C# that they have on the page? http://www.tanca.com.br/drivers.php?cat=19&sub=54

  • 1

    @Bacco Consegui!

  • 1

    Good that solved. Post the solution in the field below, so help other visitors. It is good to put the code and explain where the error was, there in addition to collaborate with those who face the problem in the future, can still make some dots on the site to whisk the post.

Show 2 more comments

1 answer

2

I was able to solve it this way:

            public static void abrirGaveta(bool flag)
    {
        if (flag == true && Properties.Settings.Default.ImpressoraGaveta == 1)
        {

            string driver = "TANCA TP-650";
            string comandoAbertura = "\u001bp\0\nd";
            RawPrinterHelper.SendStringToPrinter(driver, comandoAbertura);
        }
    }

error was in code (char) in variable command.

  • After giving the minimum time you can mark the green V on the side of your points, so it is already marked as solved

Browser other questions tagged

You are not signed in. Login or sign up in order to post.