I have a Fiscal Thermal Printer Epson FP-260SV GPRS connected to PC with RS232 cable (or a USB to serial port adapter).

I have a Fiscal Thermal Printer Epson FP-260SV GPRS connected to PC with RS232 cable (or a USB to serial port adapter).
How to print to that printer directly to COM port?
I've been using the simple code but nothing prints out:

try
AssignFile(prnfile, aFile);
Reset(prnfile);
AssignFile(port, 'COM4');
Rewrite(port);
while not eof(prnfile) do
begin
Readln(prnfile, buffer);
Writeln(port, buffer);
end;
finally
CloseFile(port);
CloseFile(prnfile);
end;

Comments

  1. Also TComPort is open source. Firtsly I'd confirm the output is working to a second serial port. Could be your baud rate is wrong for the printer. The printer might require specific hex codes as well.

    ReplyDelete
  2. Your code would only work for a LPT device in that way, providing it was in line printer mode.

    There are WinAPI functions for sending data directly to COM ports but you have to get a handle for the port and set its baud and parity and also set the length of the input/output buffers. Win COM drivers do not guarantee default baud or parity on open. But some USB to serial drivers do.

    Note also that the Epson driver that installed for the printer should have a port selection. It may have an auto detect as well. Configuring it this way will let you write to the printer via the printer object but it will probably not be in line printer mode. To do that you will need to send the printer an escape code via the GDI.

    ReplyDelete
  3. Off topic: Serial and parallel ports should die. Really.

    ReplyDelete
  4. I think parallel ports are pretty much dead. I havent seen anything with a Centronics interface in years.

    COM ports are alive and well in industrial automation and it will be years before they vanish, especially RS485.

    ReplyDelete
  5. 1. for unicode (Delphi=>xe) use TComPort free component. CPort.pas
    2. and use ComPort.ReadStr(Str, Count);
    3 for Delphi < then xe use TCommPortDriver
    4. Use>>> procedure TMainForm.CommPortDriver1ReceiveData(Sender: TObject;
    DataPtr: Pointer; DataSize: Integer);

    both excellent components
    If you need help get in touch

    ReplyDelete
  6. Lars Fosdal is there any documentation for TurboPack/AsyncPro ?

    ReplyDelete
  7. what is the type of your buffer variable? If you're on a recent delphi version, it should be an ansistring and not a string.

    ReplyDelete
  8. Tim Stroobandt See my above answer. CPort.pas takes care of this problem
    unicode

    ReplyDelete
  9. R Gosp Except from Sample code, I am not sure if the old pre-open-source manuals can be found anywhere.

    ReplyDelete

Post a Comment