0

Good morning,

I am developing a kiosk application. In that application i need to send some commands to a printer with ESC/POS protocol.

I have some commands that give me information about printer (printer status, end of paper status). For sending command I use this function, but I need also to read the printer reply. How can I do it? (The printer is connected in USB mode).

I'm developing on delphi xe2

Thanks

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
dvdan
  • 53
  • 1
  • 2
  • 10
  • Looks like the last parameter to [Escape](https://msdn.microsoft.com/en-us/library/windows/desktop/dd162701%28v=vs.85%29.aspx) should be a pointer to the data structure (nil in your linked example) to receive the output. – Ondrej Kelle May 15 '15 at 12:51
  • @TOndrej thanks, but i don't how is structured in delphi lpvOutData.. I tried like TPassThroughData of the example but without success.. – dvdan May 15 '15 at 13:43
  • Welcome. The structure probably depends on the printer and should be described in its documentation. – Ondrej Kelle May 15 '15 at 15:11
  • I'm not sure about it.. On the manual there isn't information. And I tried a lot of solution (array of byt, shortstring, string, integer..) but nothing is working – dvdan May 15 '15 at 15:18
  • I'm not talking about a user manual, you need technical documentation aimed at developers. – Ondrej Kelle May 15 '15 at 16:07
  • @TOndrej i was talking about developer manual. The type that the printer returns are byte. – dvdan May 15 '15 at 16:33

2 Answers2

0

The example is assuming that your string type is simple such as shortstring. Try declaring s as shortstring. It can not work with widestring or unicode.

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
  • procedure stampa(s: shortstring); type TPassThroughData = record nLen: Integer; Data: array [0 .. 255] of Byte; end; var PTBlock: TPassThroughData; PTReply: TPassThroughData; begin Printer.BeginDoc; PTBlock.nLen := Length(s); StrPCopy(@PTBlock.Data, s); Escape(Printer.Handle, PASSTHROUGH, 0, @PTBlock, @PTReply); Printer.EndDoc; end; Something change, but nothing change... – dvdan May 15 '15 at 14:42
0

Did you check if the USB connection makes a new serial port?

If a new serial port displayed in device manager, I can help you to send the ESC command with a Delphi Comport component.

But if there is no serial port shown up, I have no idea about how to control the thermal printer.

Dennies Chang
  • 564
  • 5
  • 15