0

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.

Alexis enp
  • 55
  • 7
  • "H0H1" (a string of length 4) is not the same as Chr$(&H0) & Chr$(&H1) (a string of length 2). Get your debugger out! – Joe Jan 07 '17 at 19:11

1 Answers1

0

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");
H.G. Sandhagen
  • 772
  • 6
  • 13
  • thanks, it work perfect!! can you helpme a little more please? hoy i can know the conversion ? for example you convert this: (Chr$(&H0) & Chr$(&H1)) in this: ("\x00\x01"); The project has more command that i dont know how to convert to C#, for example: EpsonFPHostControl1.AddDataField 1 EpsonFPHostControl1.AddDataField Chr(0) + Chr(0) EpsonFPHostControl1.AddDataField Chr$(&HE) & Chr$(&H6) EpsonFPHostControl1.AddDataField Chr$(&H30) & Chr$(&H6) Following the same logic, i think the last two in some like this ("\x0E\x06"); and ("\x030\x06");, but the firsts ones i dont know – Alexis enp Jan 08 '17 at 14:35
  • that was the first i tried @KamranShahid with no positive results :/ – Alexis enp Jan 08 '17 at 18:21
  • I don't know either the printer nor the control, but it seems that it build strings to be send to the printer. Then you could use the same strings as in basic. Example: `AddDataField ("1")` – H.G. Sandhagen Jan 09 '17 at 05:15