Search code examples
c#printingepsonfiscal

Send command in Fiscal Epson tmT81 C#


I trying to print in a fiscal printer EPSON TMT81 i have example code in VB and i need to do the same in C#, im using EpsonFPHostControl. OCX 1.9

The basic to work is sendcommand to the printer by COM port, i connect to the port with no problem but i cant send command by the port.

To send commnad in VB the code is:

        '*** PROBAR CONEXION CON IMPRESOR FISCAL ***
        '*** CHEQUEA  ESTADO  DE IMPRESOR FISCAL ***
        EpsonFPHostControl1.AddDataField (Chr$(&H0) & Chr$(&H1))
        EpsonFPHostControl1.AddDataField (Chr$(&H0) & Chr$(&H0))

        '*** ENVIA COMANDO FISCAL ***
        EpsonFPHostControl1.SendCommand

Im trying to do the same in C#:

        //*** PROBAR CONEXION CON IMPRESOR FISCAL ***
        //*** CHEQUEA  ESTADO  DE IMPRESOR FISCAL ***
        EpsonFPHostControl1.AddDataField("H0H1");
        EpsonFPHostControl1.AddDataField("H0H0");

        //*** ENVIA COMANDO FISCAL ***
        EpsonFPHostControl1.SendCommand()

But it doesnt Work well :/, the fiscal printer receibe the command but return code 513 invalid frame of comand (frame de comando invalido)

i apreciate some help.


Solution

  • The commands in c# are wrong. You have to send a string with control characters. Basic Chr$($H0) means "\x00" in c#. This should work.

    EpsonFPHostControl1.AddDataField("\x00\x01");
    EpsonFPHostControl1.AddDataField("\x00\x00");