Program Test;

uses
  NumToStr,
  ChnVirt,
  {$ifdef DOS}
  ChnCom,
  {$else}
  ChnV40,
  {$endif}
  ChnITch1,
  Crt;

var
  Chn   : tChnItch;
  l     : Word;
  AByte : array[0..6] of Byte;

{$I sets.inc}

begin
  WriteLn;
  WriteLn('Test ITouch');
  with Chn do
  begin
  {$ifdef DOS}
    ChInitParam('NAM=COM COM=1 IRQ=4 BIT=8 STO=1 BD=4800 PAR=E LRB=100');
  {$else}
    ChInitParam('NAM=V40_ BIT=8 STO=1 BD=4800 PAR=E LRB=100');
  {$endif}
    ChOpen;
    ChConnect;
    ChReceiveBuffer(@AByte,SizeOf(AByte));

    repeat
      if ChReceiveReady=CHS_ReceiveReady then
      begin
        ChReceive(l);
        Write('Family code : '+ByteStrHex(AByte[0])+
                ', Serial number : ');
        for l:=1 to 6 do
          Write(ByteStrHex(AByte[l]));
        WriteLn;
      end;
    until KeyPressed;

    Read;

    ChDisconnect;
    ChClose;
    Done;
  end;
end.
