RSDEMO.LST 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. Listing:
  2. 1 (*========================================================
  3. 2 == JPI-TopSpeed Modula-2 V2 ==
  4. 3 == demo program: ==
  5. 4 == ==
  6. 5 == Simple RS232 Demo showing rs module ==
  7. 6 == ==
  8. 7 ========================================================*)
  9. 8 MODULE RsDemo;
  10. 9 (*======*)
  11. 10
  12. 11 IMPORT Window,rs,IO,Str,Lib;
  13. 12
  14. 13 TYPE ConnectType = RECORD
  15. 14 ConnectStr : ARRAY [0..15] OF CHAR;
  16. ***** ^ not supported yet
  17. ***** ^ not supported yet
  18. 15 NoCon1Str : ARRAY [0..15] OF CHAR;
  19. ***** ^ not supported yet
  20. ***** ^ not supported yet
  21. 16 NoCon2Str : ARRAY [0..15] OF CHAR;
  22. ***** ^ not supported yet
  23. ***** ^ not supported yet
  24. 17 NoCon3Str : ARRAY [0..15] OF CHAR;
  25. ***** ^ not supported yet
  26. ***** ^ not supported yet
  27. 18 NoCon4Str : ARRAY [0..15] OF CHAR;
  28. ***** ^ not supported yet
  29. ***** ^ not supported yet
  30. 19 NoCon5Str : ARRAY [0..15] OF CHAR;
  31. ***** ^ not supported yet
  32. ***** ^ not supported yet
  33. 20 END;
  34. ***** ^ not supported yet
  35. 21
  36. 22
  37. 23 CONST PortNr = 1; BaudRate = 1200;
  38. 24 WT = Window.WinDef ( 0,0, Window.ScreenWidth-1,23,
  39. ***** ^ not supported yet
  40. ***** ^ not supported yet
  41. ***** ^ not supported yet
  42. ***** ^ not supported yet
  43. 25 Window.White,Window.Black,TRUE,TRUE,FALSE,TRUE,
  44. ***** ^ not supported yet
  45. ***** ^ not supported yet
  46. ***** ^ not supported yet
  47. ***** ^ not supported yet
  48. 26 Window.SingleFrame,Window.White,Window.Black );
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. ***** ^ not supported yet
  52. ***** ^ not supported yet
  53. ***** ^ not supported yet
  54. ***** ^ not supported yet
  55. 27
  56. 28 WT2 = Window.WinDef ( 0,0, 50,2,
  57. ***** ^ not supported yet
  58. ***** ^ not supported yet
  59. 29 Window.White,Window.Black,TRUE,TRUE,FALSE,TRUE,
  60. ***** ^ not supported yet
  61. ***** ^ not supported yet
  62. ***** ^ not supported yet
  63. ***** ^ not supported yet
  64. 30 Window.SingleFrame,Window.White,Window.Black );
  65. ***** ^ not supported yet
  66. ***** ^ not supported yet
  67. ***** ^ not supported yet
  68. ***** ^ not supported yet
  69. ***** ^ not supported yet
  70. ***** ^ not supported yet
  71. 31
  72. 32 HangupStr = '~~~~+++~~~AT H0!';
  73. ***** ^ not supported yet
  74. 33
  75. 34 InitString= 'AT E1 S7=60 S0=0 V1 X1 !~~AT D ';
  76. ***** ^ not supported yet
  77. 35
  78. 36 Connect = ConnectType('CONNECT','NO CARRIER','BUSY','NO DIAL TONE',
  79. ***** ^ not supported yet
  80. ***** ^ not supported yet
  81. ***** ^ not supported yet
  82. ***** ^ not supported yet
  83. 37 'NO ANSWER','');
  84. ***** ^ not supported yet
  85. ***** ^ not supported yet
  86. 38
  87. 39
  88. 40 VAR W,W2 : Window.WinType;
  89. ***** ^ not supported yet
  90. 41
  91. 42 PROCEDURE SendModemContr( str : ARRAY OF CHAR );
  92. ***** ^ not supported yet
  93. 43 VAR i : CARDINAL;
  94. 44 BEGIN
  95. 45 FOR i := 0 TO Str.Length(str)-1 DO
  96. ***** ^ not supported yet
  97. ***** ^ not supported yet
  98. ***** ^ not supported yet
  99. ***** ^ FOR needs integer variable and bounds
  100. 46 IF str[i]='~' THEN
  101. ***** ^ not supported yet
  102. ***** ^ not supported yet
  103. 47 Lib.Delay(500);
  104. ***** ^ not supported yet
  105. ***** ^ not supported yet
  106. ***** ^ not supported yet
  107. 48 ELSIF str[i]='!' THEN
  108. ***** ^ not supported yet
  109. ***** ^ not supported yet
  110. 49 rs.Send( CHR(13),1 );
  111. ***** ^ not supported yet
  112. ***** ^ not supported yet
  113. ***** ^ undeclared identifier
  114. ***** ^ not supported yet
  115. ***** ^ not supported yet
  116. 50 ELSIF str[i]='`' THEN
  117. ***** ^ not supported yet
  118. ***** ^ not supported yet
  119. 51 rs.Break( 500 );
  120. ***** ^ not supported yet
  121. ***** ^ not supported yet
  122. ***** ^ not supported yet
  123. 52 ELSE
  124. 53 rs.Send( str[i],1 );
  125. ***** ^ not supported yet
  126. ***** ^ not supported yet
  127. ***** ^ not supported yet
  128. ***** ^ not supported yet
  129. ***** ^ not supported yet
  130. 54 Lib.Delay(100);
  131. ***** ^ not supported yet
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. 55 END;
  135. 56 END;
  136. 57 END SendModemContr;
  137. ***** ^ not supported yet
  138. 58
  139. 59
  140. 60
  141. 61 PROCEDURE HangUp;
  142. 62 BEGIN
  143. 63 IO.WrLn;
  144. ***** ^ not supported yet
  145. ***** ^ not supported yet
  146. 64 IO.WrStr('Hanging up please wait');
  147. ***** ^ not supported yet
  148. ***** ^ not supported yet
  149. ***** ^ not supported yet
  150. 65 IO.WrLn;
  151. ***** ^ not supported yet
  152. ***** ^ not supported yet
  153. 66 SendModemContr( HangupStr );
  154. ***** ^ not supported yet
  155. ***** ^ not supported yet
  156. 67 IO.WrStr('ok');
  157. ***** ^ not supported yet
  158. ***** ^ not supported yet
  159. ***** ^ not supported yet
  160. 68 END HangUp;
  161. ***** ^ not supported yet
  162. 69
  163. 70 PROCEDURE DoConnect(ns:ARRAY OF CHAR):BOOLEAN;
  164. ***** ^ not supported yet
  165. 71 VAR str : ARRAY[0..100] OF CHAR; p : CARDINAL; c : CHAR;
  166. ***** ^ not supported yet
  167. ***** ^ not supported yet
  168. 72 BEGIN
  169. 73 IO.WrStr('Dialing');
  170. ***** ^ not supported yet
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. 74 SendModemContr( InitString );
  174. ***** ^ not supported yet
  175. ***** ^ not supported yet
  176. 75 SendModemContr( ns );
  177. ***** ^ not supported yet
  178. ***** ^ not supported yet
  179. 76 SendModemContr( '!' );
  180. ***** ^ not supported yet
  181. ***** ^ not supported yet
  182. 77 p :=0;
  183. 78 LOOP
  184. 79 IF rs.RxCount()#0 THEN
  185. ***** ^ not supported yet
  186. ***** ^ not supported yet
  187. ***** ^ not supported yet
  188. 80 rs.Receive(str[p],1);
  189. ***** ^ not supported yet
  190. ***** ^ not supported yet
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. ***** ^ not supported yet
  194. 81 IF str[p]=CHR(13) THEN
  195. ***** ^ not supported yet
  196. ***** ^ not supported yet
  197. ***** ^ undeclared identifier
  198. ***** ^ not supported yet
  199. 82 str[p] := 0C;
  200. ***** ^ not supported yet
  201. ***** ^ not supported yet
  202. 83 p := 0;
  203. 84 IO.WrLn;
  204. ***** ^ not supported yet
  205. ***** ^ not supported yet
  206. 85 IO.WrStr(str);
  207. ***** ^ not supported yet
  208. ***** ^ not supported yet
  209. ***** ^ not supported yet
  210. 86 IF Str.Pos(str,Connect.ConnectStr)#MAX(CARDINAL) THEN
  211. ***** ^ not supported yet
  212. ***** ^ not supported yet
  213. ***** ^ not supported yet
  214. ***** ^ not supported yet
  215. ***** ^ undeclared identifier
  216. ***** ^ not supported yet
  217. 87 RETURN TRUE;
  218. 88 ELSIF (Str.Pos(str,Connect.NoCon1Str)#MAX(CARDINAL)) AND (Connect.NoCon1Str[0]#0C) OR
  219. ***** ^ not supported yet
  220. ***** ^ not supported yet
  221. ***** ^ not supported yet
  222. ***** ^ not supported yet
  223. ***** ^ undeclared identifier
  224. ***** ^ not supported yet
  225. ***** ^ not supported yet
  226. ***** ^ not supported yet
  227. 89 (Str.Pos(str,Connect.NoCon2Str)#MAX(CARDINAL)) AND (Connect.NoCon2Str[0]#0C) OR
  228. ***** ^ not supported yet
  229. ***** ^ not supported yet
  230. ***** ^ not supported yet
  231. ***** ^ not supported yet
  232. ***** ^ undeclared identifier
  233. ***** ^ not supported yet
  234. ***** ^ not supported yet
  235. ***** ^ not supported yet
  236. 90 (Str.Pos(str,Connect.NoCon3Str)#MAX(CARDINAL)) AND (Connect.NoCon3Str[0]#0C) OR
  237. ***** ^ not supported yet
  238. ***** ^ not supported yet
  239. ***** ^ not supported yet
  240. ***** ^ not supported yet
  241. ***** ^ undeclared identifier
  242. ***** ^ not supported yet
  243. ***** ^ not supported yet
  244. ***** ^ not supported yet
  245. 91 (Str.Pos(str,Connect.NoCon4Str)#MAX(CARDINAL)) AND (Connect.NoCon4Str[0]#0C) OR
  246. ***** ^ not supported yet
  247. ***** ^ not supported yet
  248. ***** ^ not supported yet
  249. ***** ^ not supported yet
  250. ***** ^ undeclared identifier
  251. ***** ^ not supported yet
  252. ***** ^ not supported yet
  253. ***** ^ not supported yet
  254. 92 (Str.Pos(str,Connect.NoCon5Str)#MAX(CARDINAL)) AND (Connect.NoCon5Str[0]#0C) THEN
  255. ***** ^ not supported yet
  256. ***** ^ not supported yet
  257. ***** ^ not supported yet
  258. ***** ^ not supported yet
  259. ***** ^ undeclared identifier
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. ***** ^ not supported yet
  263. 93 Lib.Delay(1000);
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. ***** ^ not supported yet
  267. 94 RETURN FALSE;
  268. 95 END;
  269. 96 ELSE
  270. 97 p := p+1;
  271. 98 END;
  272. 99 END;
  273. 100 END;
  274. 101 END DoConnect;
  275. ***** ^ not supported yet
  276. 102
  277. 103
  278. 104 VAR c : CHAR;
  279. 105 ns : ARRAY[0..29] OF CHAR;
  280. ***** ^ not supported yet
  281. ***** ^ not supported yet
  282. 106 BEGIN
  283. 107 rs.Install(PortNr);
  284. ***** ^ not supported yet
  285. ***** ^ not supported yet
  286. ***** ^ not supported yet
  287. 108 rs.Init( BaudRate,8,rs.None,TRUE,FALSE );
  288. ***** ^ not supported yet
  289. ***** ^ not supported yet
  290. ***** ^ not supported yet
  291. ***** ^ not supported yet
  292. ***** ^ not supported yet
  293. 109 W2 := Window.Open(WT2);
  294. ***** ^ not supported yet
  295. ***** ^ not supported yet
  296. ***** ^ not supported yet
  297. ***** ^ not supported yet
  298. 110
  299. 111 IO.WrStr('Number to dial: ');
  300. ***** ^ not supported yet
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. 112 ns := '';
  304. ***** ^ not supported yet
  305. ***** ^ incompatible assignment
  306. 113 Window.InputStr(ns);
  307. ***** ^ not supported yet
  308. ***** ^ not supported yet
  309. ***** ^ not supported yet
  310. 114 IO.WrLn;
  311. ***** ^ not supported yet
  312. ***** ^ not supported yet
  313. 115 IF NOT DoConnect(ns) THEN
  314. ***** ^ not supported yet
  315. ***** ^ not supported yet
  316. 116 IO.WrStr('No connection');
  317. ***** ^ not supported yet
  318. ***** ^ not supported yet
  319. ***** ^ not supported yet
  320. 117 HangUp;
  321. ***** ^ not supported yet
  322. 118 HALT;
  323. ***** ^ undeclared identifier
  324. 119 END;
  325. 120 Window.Close(W2);
  326. ***** ^ not supported yet
  327. ***** ^ not supported yet
  328. ***** ^ not supported yet
  329. 121 Window.GotoXY(1,25);IO.WrStr('Press F2 To Hang-up and exit program');
  330. ***** ^ not supported yet
  331. ***** ^ not supported yet
  332. ***** ^ not supported yet
  333. ***** ^ not supported yet
  334. ***** ^ not supported yet
  335. ***** ^ not supported yet
  336. 122 W := Window.Open(WT);
  337. ***** ^ not supported yet
  338. ***** ^ not supported yet
  339. ***** ^ not supported yet
  340. ***** ^ not supported yet
  341. 123 LOOP
  342. 124 IF IO.KeyPressed() THEN
  343. ***** ^ not supported yet
  344. ***** ^ not supported yet
  345. ***** ^ not supported yet
  346. 125 c := IO.RdKey();
  347. ***** ^ not supported yet
  348. ***** ^ not supported yet
  349. ***** ^ not supported yet
  350. 126
  351. 127 (*Exit on F2*)
  352. 128
  353. 129 IF (c=0C) AND (CHR(60)=IO.RdKey()) THEN
  354. ***** ^ undeclared identifier
  355. ***** ^ not supported yet
  356. ***** ^ not supported yet
  357. ***** ^ not supported yet
  358. ***** ^ not supported yet
  359. 130 HangUp;
  360. ***** ^ not supported yet
  361. 131 EXIT
  362. 132 END;
  363. 133 WHILE rs.TxFree()=0 DO END;
  364. ***** ^ not supported yet
  365. ***** ^ not supported yet
  366. ***** ^ not supported yet
  367. 134 rs.Send( c,1 );
  368. ***** ^ not supported yet
  369. ***** ^ not supported yet
  370. ***** ^ not supported yet
  371. 135 END;
  372. 136 IF rs.RxCount()#0 THEN
  373. ***** ^ not supported yet
  374. ***** ^ not supported yet
  375. ***** ^ not supported yet
  376. 137 rs.Receive(c,1);
  377. ***** ^ not supported yet
  378. ***** ^ not supported yet
  379. ***** ^ not supported yet
  380. 138 IF c>=CHR(80H) THEN DEC(c,80H) END; (* strip top bit *)
  381. ***** ^ undeclared identifier
  382. ***** ^ not supported yet
  383. ***** ^ undeclared identifier
  384. ***** ^ not supported yet
  385. 139 IO.WrChar(c);
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. ***** ^ not supported yet
  389. 140 END;
  390. 141 END;
  391. 142
  392. 143 END RsDemo.
  393. 248 errors