Opening cash drawer

1

I'm trying to send a command to open my cash drawer automatically by my application, but without success so far. I contacted the manufacturer of the drawer and printer (non-fiscal) Bematech and they indicated a download with a dll that I have to use and an info file where I have some information that follow below ...

Parameters: Command: STRING with the command you want to execute. Command Size: INTEGER with the size of the command that will be sent.

Example: 'Example in Visual Basic 'Cash Drawer Trigger Command sCommand = chr (27) + chr (118) + chr (140) iRetorno = TxCommand (sCommand, Len (sCommand)

// Example in Delphi // Cash Drawer Triggering Command

s Command: = # 27 + # 118 + # 140; iRetorno: = TxCommand (sCommand, Length (sCommand);

The return of this function is given by an integer value, where if the return is: 1 (one): Success. The function ran smoothly.

0 (zero): Communication error.

But now I have difficulty understanding the logic of how to send this command to the printer for it to open the drawer. Can I submit similar as I send the receipt printing?

Example of how I print ...

insira o código aqui
                //--------------------------------Impressão do recibo ---------------------------//
                // popular relatório
                var report = from p in _objListProduct
                             select p;

                var rpDepartament = new crSaleDepartament();
                rpDepartament.SetDataSource(report);


                rpDepartament.SetParameterValue("NameUser", _nameUser);
                rpDepartament.SetParameterValue("NameDepartament", 

                //impressão direta do .rpt sem conversão
                rpDepartament.PrintToPrinter(1, false, 0, 0);
    
asked by anonymous 16.07.2014 / 15:50

1 answer

4

I was able to ...

Class

[DllImport("MP2032.dll")]
public static extern int ComandoTX(String comando, int tComando);

Chamei no botão              

const int charCode = 27;
const int charCode2 = 118;
const int charCode3 = 140;
var specialChar = Convert.ToChar(charCode);
var specialChar2 = Convert.ToChar(charCode2);
var specialChar3 = Convert.ToChar(charCode3);
string cmdText = "" + specialChar + specialChar2 + specialChar3;
iRetorno = MP2032.ComandoTX(cmdText, cmdText.Length);
    
16.07.2014 / 18:39