Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send and Recieve by parallel port.

Status
Not open for further replies.

smorteza

Technical User
Feb 19, 2004
3
DE
Hi.
I need an example program to send and recieve data using parallel port.
Thanks.
 
Educated guess here.... Have you tried assigning a file variable to LPT1? I don't have a device to plug in to see if it responds with this method, but it's worth a try.

Code:
{$I+}
var
  lpt1 : file;
  s : String;
begin
  AssignFile(lpt1, 'LPT1');
  Reset(lpt1);
  { to write to the parallel port }
  s := 'this is going out';
  BlockWrite(lpt1, s, Length(s));
  { to read from the parallel port }
  try
    BlockRead(lpt1, s, 255);
  except
  end;
end.
To be honest, I'd be surprised if it worked. And you'd want to tailor it more to your needs. Have a read on the BlockRead and BlockWrite help topics in Delphi.

You may have more luck searching for something on Torry's.
 
Try using the component "TCom321"
I have used it some times and it works
You can set the speed,compressing etc.
Compatitable with telnet
I guaranty for it.

Spent
mail:teknet@mail.orbitel.bg
 
For anyone else who ends up searching here for how to send commands through a parallel connection, the following worked for me and is based on the post from Griffyn.

Code:
procedure TForm2.btnFeedLPT1Click(Sender: TObject);
var
   sl: TstringList;
 
begin
 
   sl := TstringList.Create;
 
   try
      sl.Add(#02 + 'F');
 
      sl.SaveToFile('LPT1');
   finally
      sl.Free;
   end;
end;

It just saves the command string to the port as if it was a file (like 'type'ing from DOS).

If anyone is interested I use this code for sending commands to thermal barcode printers. The minimal example above simply contains the command for the printer to 'feed'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top