| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- Listing:
- 1 (*========================================================
- 2 == TopSpeed Modula-2 V3.102 ==
- 3 == demo program: ==
- 4 == ==
- 5 == Simple RS232 Demo showing rs module ==
- 6 == ==
- 7 ========================================================*)
- 8 MODULE RsDemo;
- 9 (*======*)
- 10
- 11 IMPORT Window,rs,IO,Str,Lib;
- 12
- 13 TYPE ConnectType = RECORD
- 14 ConnectStr : ARRAY [0..15] OF CHAR;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 15 NoCon1Str : ARRAY [0..15] OF CHAR;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 16 NoCon2Str : ARRAY [0..15] OF CHAR;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 17 NoCon3Str : ARRAY [0..15] OF CHAR;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 18 NoCon4Str : ARRAY [0..15] OF CHAR;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 19 NoCon5Str : ARRAY [0..15] OF CHAR;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 20 END;
- ***** ^ not supported yet
- 21
- 22
- 23 CONST PortNr = 1; BaudRate = 1200;
- 24 WT = Window.WinDef ( 0,0, Window.ScreenWidth-1,23,
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 25 Window.White,Window.Black,TRUE,TRUE,FALSE,TRUE,
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 26 Window.SingleFrame,Window.White,Window.Black );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 27
- 28 WT2 = Window.WinDef ( 0,0, 50,2,
- ***** ^ not supported yet
- ***** ^ not supported yet
- 29 Window.White,Window.Black,TRUE,TRUE,FALSE,TRUE,
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 30 Window.SingleFrame,Window.White,Window.Black );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 31
- 32 HangupStr = '~~~~+++~~~AT H0!';
- ***** ^ not supported yet
- 33
- 34 InitString= 'AT E1 S7=60 S0=0 V1 X1 !~~AT D ';
- ***** ^ not supported yet
- 35
- 36 Connect = ConnectType('CONNECT','NO CARRIER','BUSY','NO DIAL TONE',
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 37 'NO ANSWER','');
- ***** ^ not supported yet
- ***** ^ not supported yet
- 38
- 39
- 40 VAR W,W2 : Window.WinType;
- ***** ^ not supported yet
- 41
- 42 PROCEDURE SendModemContr( str : ARRAY OF CHAR );
- ***** ^ not supported yet
- 43 VAR i : CARDINAL;
- 44 BEGIN
- 45 FOR i := 0 TO Str.Length(str)-1 DO
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ FOR needs integer variable and bounds
- 46 IF str[i]='~' THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- 47 Lib.Delay(500);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 48 ELSIF str[i]='!' THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- 49 rs.Send( CHR(13),1 );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ not supported yet
- 50 ELSIF str[i]='`' THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- 51 rs.Break( 500 );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 52 ELSE
- 53 rs.Send( str[i],1 );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 54 Lib.Delay(100);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 55 END;
- 56 END;
- 57 END SendModemContr;
- ***** ^ not supported yet
- 58
- 59
- 60
- 61 PROCEDURE HangUp;
- 62 BEGIN
- 63 IO.WrLn;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 64 IO.WrStr('Hanging up please wait');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 65 IO.WrLn;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 66 SendModemContr( HangupStr );
- ***** ^ not supported yet
- ***** ^ not supported yet
- 67 IO.WrStr('ok');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 68 END HangUp;
- ***** ^ not supported yet
- 69
- 70 PROCEDURE DoConnect(ns:ARRAY OF CHAR):BOOLEAN;
- ***** ^ not supported yet
- 71 VAR str : ARRAY[0..100] OF CHAR; p : CARDINAL; c : CHAR;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 72 BEGIN
- 73 IO.WrStr('Dialing');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 74 SendModemContr( InitString );
- ***** ^ not supported yet
- ***** ^ not supported yet
- 75 SendModemContr( ns );
- ***** ^ not supported yet
- ***** ^ not supported yet
- 76 SendModemContr( '!' );
- ***** ^ not supported yet
- ***** ^ not supported yet
- 77 p :=0;
- 78 LOOP
- 79 IF rs.RxCount()#0 THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 80 rs.Receive(str[p],1);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 81 IF str[p]=CHR(13) THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 82 str[p] := 0C;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 83 p := 0;
- 84 IO.WrLn;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 85 IO.WrStr(str);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 86 IF Str.Pos(str,Connect.ConnectStr)#MAX(CARDINAL) THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 87 RETURN TRUE;
- 88 ELSIF (Str.Pos(str,Connect.NoCon1Str)#MAX(CARDINAL)) AND (Connect.NoCon1Str[0]#0C) OR
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 89 (Str.Pos(str,Connect.NoCon2Str)#MAX(CARDINAL)) AND (Connect.NoCon2Str[0]#0C) OR
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 90 (Str.Pos(str,Connect.NoCon3Str)#MAX(CARDINAL)) AND (Connect.NoCon3Str[0]#0C) OR
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 91 (Str.Pos(str,Connect.NoCon4Str)#MAX(CARDINAL)) AND (Connect.NoCon4Str[0]#0C) OR
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 92 (Str.Pos(str,Connect.NoCon5Str)#MAX(CARDINAL)) AND (Connect.NoCon5Str[0]#0C) THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 93 Lib.Delay(1000);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 94 RETURN FALSE;
- 95 END;
- 96 ELSE
- 97 p := p+1;
- 98 END;
- 99 END;
- 100 END;
- 101 END DoConnect;
- ***** ^ not supported yet
- 102
- 103
- 104 VAR c : CHAR;
- 105 ns : ARRAY[0..29] OF CHAR;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 106 BEGIN
- 107 rs.Install(PortNr);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 108 rs.Init( BaudRate,8,rs.None,TRUE,FALSE );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 109 W2 := Window.Open(WT2);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 110
- 111 IO.WrStr('Number to dial: ');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 112 ns := '';
- ***** ^ not supported yet
- ***** ^ incompatible assignment
- 113 Window.InputStr(ns);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 114 IO.WrLn;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 115 IF NOT DoConnect(ns) THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- 116 IO.WrStr('No connection');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 117 HangUp;
- ***** ^ not supported yet
- 118 HALT;
- ***** ^ undeclared identifier
- 119 END;
- 120 Window.Close(W2);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 121 Window.GotoXY(1,25);IO.WrStr('Press F2 To Hang-up and exit program');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 122 W := Window.Open(WT);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 123 LOOP
- 124 IF IO.KeyPressed() THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 125 c := IO.RdKey();
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 126
- 127 (*Exit on F2*)
- 128
- 129 IF (c=0C) AND (CHR(60)=IO.RdKey()) THEN
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 130 HangUp;
- ***** ^ not supported yet
- 131 EXIT
- 132 END;
- 133 WHILE rs.TxFree()=0 DO END;
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 134 rs.Send( c,1 );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 135 END;
- 136 IF rs.RxCount()#0 THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 137 rs.Receive(c,1);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 138 IF c>=CHR(80H) THEN DEC(c,80H) END; (* strip top bit *)
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 139 IO.WrChar(c);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 140 END;
- 141 END;
- 142
- 143 END RsDemo.
- 248 errors
|