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;
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;
Open Source
ReplyDeletehttps://github.com/TurboPack/AsyncPro/
Commercial
http://www.tmssoftware.com/site/async32.asp
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.
ReplyDeleteYour code would only work for a LPT device in that way, providing it was in line printer mode.
ReplyDeleteThere 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.
Off topic: Serial and parallel ports should die. Really.
ReplyDeleteI think parallel ports are pretty much dead. I havent seen anything with a Centronics interface in years.
ReplyDeleteCOM ports are alive and well in industrial automation and it will be years before they vanish, especially RS485.
1. for unicode (Delphi=>xe) use TComPort free component. CPort.pas
ReplyDelete2. 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
Lars Fosdal is there any documentation for TurboPack/AsyncPro ?
ReplyDeletewhat is the type of your buffer variable? If you're on a recent delphi version, it should be an ansistring and not a string.
ReplyDeleteTim Stroobandt See my above answer. CPort.pas takes care of this problem
ReplyDeleteunicode
R Gosp Except from Sample code, I am not sure if the old pre-open-source manuals can be found anywhere.
ReplyDelete