Board index » delphi » LPT, COM

LPT, COM

Hi! I have got some problems. I do not know, how to send/receive data from
serial ports (Parallel, ... - LPT, COM). So, if I connect two computers with
cable, I can manipulate with data. I need LPT, if you know, you can tell
COM too (if there is no difference).

LPT NEEDED!!!!

--
Sorry for bad english (I'm from Slovenia)!
Matija Polajnar

 

Re:LPT, COM


you can use the interrupt $21 or the MsDos command wish is the same like
intr($21,xxx). There all commands available for reading and writing datas
to and from a Port. For more information you should use a guide for handling
the universal interrupt $21. I hope this help. If you have more questions
feel free to sen a e-mail to Beh...@hbg.dpa.de
Best regards
Gerhard Behnke

Open_File       = $3D00;
Close_File      = $3E00;
Write_InDatei   = $4000;
Read_FromDatei  = $3F00;

PrinterFN       : ARRAY[0..65] OF Byte;
St              : String;
i               : Integer;
PRegs          : Registers;
PrinterPort     : Integer;

(* First, you must open the Port *)
St := 'LPT1';
i := Length(St);
Move(St[1],PrinterFn[0],i);      { copy filename into Array              }
PrinterFn[i] := 0;               { set the Byte after the filename to $0 }
WITH PRegs DO
BEGIN
  AX := Open_File;
  AL := $41;                         { set file attribute write         }
  DS := Seg (PrinterFn [0]);             { indicate location of
         }
  DX := Ofs (PrinterFn [0]);
  MsDos (PRegs);                   { Do the Function call                  }
  IF (Flags AND 1) = 1 THEN       { If carry set, then there is an error  }
  Begin
    Writeln('PRINTER NOT FOUND');
    Close(PrintFile);

    If Ioresult <> 0 then;
    With PRegs do
    Begin
      AX := Close_File;
      BX := PrinterPort;
      MsDos (PRegs);
    End;
  End
  Else
    PrinterPort := AX;
End;

(* Write to LPT *)
    WITH PRegs DO
    BEGIN
      pch := PrintChar;                   { get the next character to
nt    }
      IF pch <> #0 THEN                   { wenn 0 dann keine zu druckenden
Zeichen wie SOH,STX usw. }
      BEGIN
        AX := Write_InDatei;            { MS-DOS Function $40 - Write to
file   }
        BX := PrinterPort;                  { pass file handle
           }
        CX := 1;                        { ein byte }
        DS := Seg (pch);                { indicate address of
       }
        DX := Ofs (pch);
        MsDos (PRegs);                   { Do the
      }
     End;
    End;

(* don't forget to close the port *)

Quote
Matija polajnar wrote in message <6rhgcm$48...@planja.arnes.si>...
>Hi! I have got some problems. I do not know, how to send/receive data from
>serial ports (Parallel, ... - LPT, COM). So, if I connect two computers
with
>cable, I can manipulate with data. I need LPT, if you know, you can tell
>COM too (if there is no difference).

>LPT NEEDED!!!!

>--
>Sorry for bad english (I'm from Slovenia)!
>Matija Polajnar

Other Threads