Program TSTSRDA;

{ Version
  File:[22,311]TSTSRDA.PAS       Last edit: 26-AUG-1987 09:42:12 
  Author: Philip Hannay.
  History:

     26-Aug-87.  Philip Hannay.  Created.


Testing P3UTIL module(s): SRDA
Prerequisite P3UTIL module(s): RDEF, CLEF, STSE
}

{$nolist}
{[a+,b+,l-,k+,r+] Pasmat }
%include ex:[22,320]general3.typ;
%include ex:[22,320]srda.ext;
%include ex:[22,320]rdef.ext;
%include ex:[22,320]clef.ext;
%include ex:[22,320]stse.ext;

{$list}

VAR
  i: integer;
  f: event_flag;
  flgset: boolean;
  resp: char;

BEGIN
Write('SRDA test. Enter flag number to use, 0 to exit.');
readln(i);
if i > 0 
  then begin
    if (i > 96)
      then begin
        writeln('illegal flag, must be between 1 and 96, try again');
        end
      else begin
        f := loophole(event_flag,i);
        writeln;
        writeln('First we try clearing the AST before even having set it up');
        SRDA(f0);
        writeln('SRDA(f0) done, $DSW = ',$DSW:1);
        writeln;
        writeln('Now we set up (arm) AST using specified event flag');
        SRDA(f);
        writeln('SRDA(f',i:1,') done, $DSW = ',$DSW:1);
	writeln;
        writeln('Now we will let you look at the flag, and send a packet');
        repeat
          writeln;
          writeln('Look at flag? (Y,N - enter N to go on)> ');
          readln(resp);
          if (resp='Y') or (resp='y')
            then begin
              flgset:= RDEF(f);
              writeln('RDEF(f',i:1,') done, $DSW = ',$DSW:1);
              if flgset
                then writeln('Flag f',i:1,' is set')
                else writeln('Flag f',i:1,' is clear');
              end;
          until (resp<>'Y') and (resp<>'y');
	writeln;
        writeln('Now clear flag if not already clear');
        CLEF(f);
        writeln('CLEF(f',i:1,') done, $DSW = ',$DSW:1);
        writeln;
        writeln('Now we go to sleep, waiting on event flag f',i:1);
        writeln('Send us a message packet to wake us up');
        writeln;
        STSE(f);
        writeln('STSE(f',i:1,') done, $DSW = ',$DSW:1);
        writeln('Leaving stopped state, event flag set okay');
        writeln;
        writeln('Now clear flag if not already clear');
        CLEF(f);
        writeln('CLEF(f',i:1,') done, $DSW = ',$DSW:1);
        writeln;
        writeln('Now we clear AST service');
        SRDA(f0);
        writeln('SRDA(f0) done, $DSW = ',$DSW:1);
	writeln;
        writeln('Now we will let you look at the flag, and send a packet');
        repeat
          writeln;
          writeln('Look at flag? (Y,N - enter N to go on)> ');
          readln(resp);
          if (resp='Y') or (resp='y')
            then begin
              flgset:= RDEF(f);
              writeln('RDEF(f',i:1,') done, $DSW = ',$DSW:1);
              if flgset
                then writeln('Flag f',i:1,' is set')
                else writeln('Flag f',i:1,' is clear');
              end;
          until (resp<>'Y') and (resp<>'y');
 	writeln;
        end;
    end;
writeln('end of test')
end.	
