program Eprom_EMULATOR;
uses crt,dos;

var serial   :text;
    infile   :file of char;
    crka     :char;
    napaka   :byte;
    n        :word;

procedure CheckIO;
  begin
    napaka := IOresult;
    If napaka <> 0 then
                     begin
                       Writeln('DOS error #',napaka);
                       HALT(napaka);
                     end;
  end;

begin
  assign(serial,'com1');
  rewrite(serial);
  if paramcount = 1 then assign(infile,paramstr(1))
                     else begin
                          Writeln('Usage : [path]EPREMUL <transmitted file>');
                          HALT(6)
                         end;

  assign(infile,paramstr(1));
{$I-}
  reset(infile);
  CheckIO;

  write(serial,'RESET');
  CheckIO;
  while not EOF(infile) do
     begin
       Read(Infile,crka);
       Write(Serial,crka);
       CheckIO;
     end;
 Close(Serial);
 CheckIO;
{$I+}
end.