WXMODEM.LST 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  1. Listing:
  2. 1 (* Release 3.10 *)
  3. 2 (*-------------------------------------------------------------------------*
  4. 3 * *
  5. 4 * WXMODEM.MOD - COMMS Toolkit file protocols *
  6. 5 * *
  7. 6 * COPYRIGHT (C) 1988..1992 Clarion Software Corporation. *
  8. 7 * All Rights Reserved *
  9. 8 * *
  10. 9 *--------------------------------------------------------------------------*)
  11. 10
  12. 11 IMPLEMENTATION MODULE WXModem;
  13. 12 IMPORT CommUtil,FIO,FTSupport,Lib,RS232,Str;
  14. 13 FROM FTSupport IMPORT ACK,NAK,SOH,EOT,CAN,SYN,WNDREQ;
  15. ***** ^ duplicate identifier
  16. 14
  17. 15 CONST
  18. 16 DLE = CHR(16);
  19. ***** ^ undeclared identifier
  20. ***** ^ not supported yet
  21. 17 XON = CHR(17);
  22. ***** ^ undeclared identifier
  23. ***** ^ not supported yet
  24. 18 XOFF = CHR(19);
  25. ***** ^ undeclared identifier
  26. ***** ^ not supported yet
  27. 19
  28. 20 VAR
  29. 21 f : FIO.File;
  30. ***** ^ not supported yet
  31. 22 Response : ARRAY[0..1] OF CHAR;
  32. ***** ^ not supported yet
  33. ***** ^ not supported yet
  34. 23 LastBlockNo,BlockNo,
  35. 24 BlockSize : CARDINAL;
  36. 25
  37. 26 (*..................................................*)
  38. 27
  39. 28 PROCEDURE InitVars(VAR Filename:ARRAY OF CHAR);
  40. ***** ^ not supported yet
  41. 29 BEGIN
  42. 30 FTSupport.Errors:=0;
  43. ***** ^ not supported yet
  44. ***** ^ not supported yet
  45. 31 FTSupport.LastMessage:='';
  46. ***** ^ not supported yet
  47. ***** ^ not supported yet
  48. 32 FTSupport.XferMode := 'CRC';
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. ***** ^ not supported yet
  52. 33 FTSupport.Transferred:=0;
  53. ***** ^ not supported yet
  54. ***** ^ not supported yet
  55. 34 FTSupport.Aborted := FALSE;
  56. ***** ^ not supported yet
  57. ***** ^ not supported yet
  58. 35 FTSupport.SizeInBytes:=0;
  59. ***** ^ not supported yet
  60. ***** ^ not supported yet
  61. 36 Str.Copy(FTSupport.FileSpec,Filename);
  62. ***** ^ not supported yet
  63. ***** ^ not supported yet
  64. ***** ^ not supported yet
  65. ***** ^ not supported yet
  66. ***** ^ not supported yet
  67. 37 BlockNo:=1;
  68. 38 LastBlockNo:=0FFFFH;
  69. 39 BlockSize:=128;
  70. 40 END InitVars;
  71. ***** ^ not supported yet
  72. 41
  73. 42 (*...............................................*)
  74. 43
  75. 44 PROCEDURE SendResponse;
  76. 45 BEGIN
  77. 46 IF (Response[0]=ACK) OR (Response[0]=NAK) THEN
  78. ***** ^ not supported yet
  79. ***** ^ not supported yet
  80. ***** ^ not supported yet
  81. ***** ^ not supported yet
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. 47 Response[1] := CHR(ORD(Response[1]) MOD 4);
  85. ***** ^ not supported yet
  86. ***** ^ not supported yet
  87. ***** ^ undeclared identifier
  88. ***** ^ undeclared identifier
  89. ***** ^ not supported yet
  90. ***** ^ not supported yet
  91. ***** ^ not supported yet
  92. 48 RS232.SerialWrite(Response,2)
  93. ***** ^ not supported yet
  94. ***** ^ not supported yet
  95. ***** ^ not supported yet
  96. ***** ^ not supported yet
  97. 49 ELSIF Response[0]<>0C THEN
  98. ***** ^ not supported yet
  99. ***** ^ not supported yet
  100. 50 RS232.SerialWrite(Response,1)
  101. ***** ^ not supported yet
  102. ***** ^ not supported yet
  103. ***** ^ not supported yet
  104. ***** ^ not supported yet
  105. 51 END;
  106. 52 END SendResponse;
  107. ***** ^ not supported yet
  108. 53
  109. 54 (*...............................................*)
  110. 55
  111. 56 PROCEDURE RcvNoDLE(VAR c:CHAR; Timeout:CARDINAL):BOOLEAN;
  112. 57 (* Strip DLE sequences from incoming data *)
  113. 58 BEGIN
  114. 59 IF RS232.SerialRead(c,Timeout) THEN
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. ***** ^ not supported yet
  118. 60 IF c=DLE THEN
  119. 61 IF RS232.SerialRead(c,Timeout) THEN
  120. ***** ^ not supported yet
  121. ***** ^ not supported yet
  122. ***** ^ not supported yet
  123. 62 c := CHR(CARDINAL(BITSET(ORD(c))/BITSET(64)))
  124. ***** ^ undeclared identifier
  125. ***** ^ undeclared identifier
  126. ***** ^ undeclared identifier
  127. ***** ^ not supported yet
  128. ***** ^ undeclared identifier
  129. ***** ^ not supported yet
  130. 63 ELSE
  131. 64 RETURN FALSE;
  132. 65 END;
  133. 66 END;
  134. 67 RETURN TRUE;
  135. 68 ELSE
  136. 69 RETURN FALSE;
  137. 70 END;
  138. 71 END RcvNoDLE;
  139. ***** ^ not supported yet
  140. 72
  141. 73 (*...............................................*)
  142. 74
  143. 75 PROCEDURE ReceiveData():CARDINAL;
  144. 76 (* Attempt to receive a single packet, returning an error code. Zero *)
  145. 77 (* means that a packet was successfully received. *)
  146. 78 VAR
  147. 79 c : CHAR;
  148. 80 RxBlk,CRC,RxCRC,
  149. 81 Result,Cnt,
  150. 82 CRCIndex : CARDINAL;
  151. 83 RxState : (Start,Blk,Compl,Data,CRCH,CRCL);
  152. ***** ^ not supported yet
  153. 84 BEGIN
  154. 85 (* Already had the first character - SYN *)
  155. 86 RxState:=Start;
  156. ***** ^ not supported yet
  157. ***** ^ not supported yet
  158. 87 CRC:=0;
  159. 88 Cnt:=0;
  160. 89 Result:=0;
  161. 90 LOOP
  162. 91 IF FTSupport.AbortRequested() THEN
  163. ***** ^ not supported yet
  164. ***** ^ not supported yet
  165. ***** ^ not supported yet
  166. 92 RETURN(128+6);
  167. 93 END;
  168. 94 IF NOT RcvNoDLE(c,50) THEN
  169. ***** ^ not supported yet
  170. ***** ^ not supported yet
  171. 95 FTSupport.LastMessage := 'Timeout';
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. ***** ^ not supported yet
  175. 96 RETURN(3);
  176. 97 END;
  177. 98 CASE RxState OF
  178. ***** ^ not supported yet
  179. 99 Start : IF c=SOH THEN
  180. ***** ^ not supported yet
  181. ***** ^ not supported yet
  182. 100 RxState:=Blk;
  183. ***** ^ not supported yet
  184. ***** ^ not supported yet
  185. 101 BlockSize:=128
  186. 102 ELSIF c=EOT THEN
  187. ***** ^ not supported yet
  188. 103 RETURN 127;
  189. 104 END; |
  190. 105 Blk : RxBlk := ORD(c);
  191. ***** ^ not supported yet
  192. ***** ^ undeclared identifier
  193. ***** ^ not supported yet
  194. 106 RxState := Compl; |
  195. ***** ^ not supported yet
  196. ***** ^ not supported yet
  197. 107 Compl : IF 255-ORD(c)<>RxBlk THEN
  198. ***** ^ not supported yet
  199. ***** ^ undeclared identifier
  200. ***** ^ not supported yet
  201. 108 FTSupport.LastMessage:='Bad Block No';
  202. ***** ^ not supported yet
  203. ***** ^ not supported yet
  204. ***** ^ not supported yet
  205. 109 RETURN 11;
  206. 110 ELSIF RxBlk=BlockNo THEN
  207. 111 RxState := Data;
  208. ***** ^ not supported yet
  209. ***** ^ not supported yet
  210. 112 ELSE
  211. 113 Result := 15;
  212. 114 FTSupport.LastMessage := 'Block Resent';
  213. ***** ^ not supported yet
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. 115 RxState := Data;
  217. ***** ^ not supported yet
  218. ***** ^ not supported yet
  219. 116 END; |
  220. 117 Data : FTSupport.FBuff[Cnt] := c;
  221. ***** ^ not supported yet
  222. ***** ^ not supported yet
  223. ***** ^ not supported yet
  224. ***** ^ not supported yet
  225. 118 CRCIndex := CARDINAL(BITSET(CRC>>8)/BITSET(ORD(c)));
  226. ***** ^ undeclared identifier
  227. ***** ^ not supported yet
  228. ***** ^ undeclared identifier
  229. ***** ^ undeclared identifier
  230. ***** ^ not supported yet
  231. 119 CRC := CARDINAL(BITSET(FTSupport.CRCTable[CRCIndex])/BITSET(CRC<<8));
  232. ***** ^ undeclared identifier
  233. ***** ^ not supported yet
  234. ***** ^ not supported yet
  235. ***** ^ not supported yet
  236. ***** ^ undeclared identifier
  237. ***** ^ not supported yet
  238. 120 INC(Cnt);
  239. ***** ^ undeclared identifier
  240. ***** ^ not supported yet
  241. 121 IF Cnt=BlockSize THEN
  242. 122 RxState:=CRCH;
  243. ***** ^ not supported yet
  244. ***** ^ not supported yet
  245. 123 END; |
  246. 124 CRCH : RxCRC := ORD(c)<<8;
  247. ***** ^ not supported yet
  248. ***** ^ undeclared identifier
  249. ***** ^ not supported yet
  250. ***** ^ arithmetic operand must be numeric
  251. 125 RxState := CRCL; |
  252. ***** ^ not supported yet
  253. ***** ^ not supported yet
  254. 126 CRCL : RxCRC := RxCRC+ORD(c);
  255. ***** ^ not supported yet
  256. ***** ^ undeclared identifier
  257. ***** ^ not supported yet
  258. 127 IF CRC=RxCRC THEN
  259. 128 RETURN Result
  260. 129 ELSE
  261. 130 FTSupport.LastMessage := 'Bad CRC';
  262. ***** ^ not supported yet
  263. ***** ^ not supported yet
  264. ***** ^ not supported yet
  265. 131 RETURN 9;
  266. 132 END; |
  267. 133 END; (* case *)
  268. 134 END; (* loop *)
  269. 135 END ReceiveData;
  270. ***** ^ not supported yet
  271. 136
  272. 137 (*...............................................*)
  273. 138
  274. 139 PROCEDURE WXMReceive():CARDINAL;
  275. 140 VAR
  276. 141 c : CHAR;
  277. 142 Result : CARDINAL;
  278. 143 IncomingData,
  279. 144 Negotiating,
  280. 145 EndOfFile : BOOLEAN;
  281. 146 BEGIN
  282. 147 Negotiating:=TRUE;
  283. 148 EndOfFile:=FALSE;
  284. 149 REPEAT
  285. 150 IncomingData := FALSE;
  286. 151 REPEAT
  287. 152 FTSupport.UpdateStatus;
  288. ***** ^ not supported yet
  289. ***** ^ not supported yet
  290. 153 IF FTSupport.AbortRequested() THEN
  291. ***** ^ not supported yet
  292. ***** ^ not supported yet
  293. ***** ^ not supported yet
  294. 154 RETURN(6);
  295. 155 END;
  296. 156 LOOP
  297. 157 SendResponse;
  298. ***** ^ not supported yet
  299. 158 IF RS232.SerialRead(c,150) THEN
  300. ***** ^ not supported yet
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. 159 IF (c=SYN) OR (c=EOT) THEN
  304. ***** ^ not supported yet
  305. ***** ^ not supported yet
  306. 160 FTSupport.LastMessage:='';
  307. ***** ^ not supported yet
  308. ***** ^ not supported yet
  309. 161 Negotiating:=FALSE;
  310. 162 IncomingData := TRUE;
  311. 163 EXIT;
  312. 164 END
  313. 165 ELSE
  314. 166 FTSupport.LastMessage := 'Timeout';
  315. ***** ^ not supported yet
  316. ***** ^ not supported yet
  317. ***** ^ not supported yet
  318. 167 INC(FTSupport.Errors);
  319. ***** ^ undeclared identifier
  320. ***** ^ not supported yet
  321. ***** ^ not supported yet
  322. 168 IF (FTSupport.Errors>1) THEN
  323. ***** ^ not supported yet
  324. ***** ^ not supported yet
  325. 169 IF Negotiating THEN
  326. 170 RETURN(1);
  327. 171 ELSE
  328. 172 RETURN(2);
  329. 173 END;
  330. 174 END;
  331. 175 EXIT;
  332. 176 END;
  333. 177 END;
  334. 178 UNTIL IncomingData;
  335. 179 IF c=EOT THEN
  336. ***** ^ not supported yet
  337. 180 Result := 127
  338. 181 ELSE
  339. 182 Result := ReceiveData();
  340. ***** ^ not supported yet
  341. ***** ^ not supported yet
  342. 183 END;
  343. 184 IF Result=127 (* end of file *) THEN
  344. 185 FTSupport.LastMessage := 'End of File';
  345. ***** ^ not supported yet
  346. ***** ^ not supported yet
  347. ***** ^ not supported yet
  348. 186 EndOfFile := TRUE;
  349. 187 Response[0]:=ACK;
  350. ***** ^ not supported yet
  351. ***** ^ not supported yet
  352. ***** ^ not supported yet
  353. 188 RS232.SerialWrite(Response,1)
  354. ***** ^ not supported yet
  355. ***** ^ not supported yet
  356. ***** ^ not supported yet
  357. ***** ^ not supported yet
  358. 189 ELSIF Result=0 THEN (* good block received *)
  359. 190 Response[0]:=ACK;
  360. ***** ^ not supported yet
  361. ***** ^ not supported yet
  362. ***** ^ not supported yet
  363. 191 Response[1]:=CHR(BlockNo);
  364. ***** ^ not supported yet
  365. ***** ^ not supported yet
  366. ***** ^ undeclared identifier
  367. ***** ^ not supported yet
  368. 192 LastBlockNo := BlockNo;
  369. 193 BlockNo := (BlockNo+1) MOD 100H;
  370. 194 FIO.WrBin(f,FTSupport.FBuff,BlockSize);
  371. ***** ^ not supported yet
  372. ***** ^ not supported yet
  373. ***** ^ not supported yet
  374. ***** ^ not supported yet
  375. ***** ^ not supported yet
  376. ***** ^ not supported yet
  377. 195 IF FIO.IOresult()<>0 THEN
  378. ***** ^ not supported yet
  379. ***** ^ not supported yet
  380. ***** ^ not supported yet
  381. 196 FTSupport.LastMessage := 'Disk Write Error';
  382. ***** ^ not supported yet
  383. ***** ^ not supported yet
  384. ***** ^ not supported yet
  385. 197 FTSupport.UpdateStatus;
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. 198 RETURN(4);
  389. 199 END;
  390. 200 FTSupport.Transferred := FTSupport.Transferred+LONGCARD(BlockSize);
  391. ***** ^ not supported yet
  392. ***** ^ not supported yet
  393. ***** ^ not supported yet
  394. ***** ^ not supported yet
  395. ***** ^ undeclared identifier
  396. ***** ^ not supported yet
  397. 201 FTSupport.Errors:=0;
  398. ***** ^ not supported yet
  399. ***** ^ not supported yet
  400. 202 FTSupport.LastMessage:='';
  401. ***** ^ not supported yet
  402. ***** ^ not supported yet
  403. 203 FTSupport.UpdateStatus;
  404. ***** ^ not supported yet
  405. ***** ^ not supported yet
  406. 204 ELSIF Result=15 THEN (* Sender resent a block - ignore *)
  407. 205 Response[0] := 0C;
  408. ***** ^ not supported yet
  409. ***** ^ not supported yet
  410. 206 FTSupport.Errors := 0;
  411. ***** ^ not supported yet
  412. ***** ^ not supported yet
  413. 207 FTSupport.LastMessage := '';
  414. ***** ^ not supported yet
  415. ***** ^ not supported yet
  416. 208 FTSupport.UpdateStatus;
  417. ***** ^ not supported yet
  418. ***** ^ not supported yet
  419. 209 ELSE (* protocol error of some kind *)
  420. 210 INC(FTSupport.Errors);
  421. ***** ^ undeclared identifier
  422. ***** ^ not supported yet
  423. ***** ^ not supported yet
  424. 211 FTSupport.UpdateStatus;
  425. ***** ^ not supported yet
  426. ***** ^ not supported yet
  427. 212 IF Result>127 (* fatal *) THEN
  428. 213 FTSupport.Aborted := TRUE;
  429. ***** ^ not supported yet
  430. ***** ^ not supported yet
  431. 214 RETURN(Result MOD 100H)
  432. 215 END;
  433. 216 Response[0]:=NAK;
  434. ***** ^ not supported yet
  435. ***** ^ not supported yet
  436. ***** ^ not supported yet
  437. 217 Response[1]:=CHR(BlockNo);
  438. ***** ^ not supported yet
  439. ***** ^ not supported yet
  440. ***** ^ undeclared identifier
  441. ***** ^ not supported yet
  442. 218 IF FTSupport.Errors>5 (* too many *) THEN RETURN(Result) END;
  443. ***** ^ not supported yet
  444. ***** ^ not supported yet
  445. 219 END;
  446. 220 UNTIL EndOfFile OR FTSupport.Aborted;
  447. ***** ^ not supported yet
  448. ***** ^ not supported yet
  449. 221 IF FTSupport.Aborted THEN
  450. ***** ^ not supported yet
  451. ***** ^ not supported yet
  452. 222 RETURN(6);
  453. 223 ELSE
  454. 224 RETURN(0);
  455. 225 END;
  456. 226 END WXMReceive;
  457. ***** ^ not supported yet
  458. 227
  459. 228 (*...............................................*)
  460. 229
  461. 230 PROCEDURE WXModemReceive(VAR Filename:ARRAY OF CHAR):CARDINAL;
  462. ***** ^ not supported yet
  463. 231 VAR
  464. 232 Result : CARDINAL;
  465. 233 BEGIN
  466. 234 InitVars(Filename);
  467. ***** ^ not supported yet
  468. ***** ^ not supported yet
  469. 235 FTSupport.CompleteFilename;
  470. ***** ^ not supported yet
  471. ***** ^ not supported yet
  472. 236 f := FIO.Create(Filename);
  473. ***** ^ not supported yet
  474. ***** ^ not supported yet
  475. ***** ^ not supported yet
  476. ***** ^ not supported yet
  477. 237 IF FIO.IOresult()=0 THEN
  478. ***** ^ not supported yet
  479. ***** ^ not supported yet
  480. ***** ^ not supported yet
  481. 238 FTSupport.OpenStatusWindow('WXModem Download');
  482. ***** ^ not supported yet
  483. ***** ^ not supported yet
  484. ***** ^ not supported yet
  485. 239 FTSupport.NewFilename;
  486. ***** ^ not supported yet
  487. ***** ^ not supported yet
  488. 240 Response := WNDREQ;
  489. ***** ^ not supported yet
  490. ***** ^ not supported yet
  491. 241 Result := WXMReceive();
  492. ***** ^ not supported yet
  493. ***** ^ not supported yet
  494. 242 FIO.Close(f);
  495. ***** ^ not supported yet
  496. ***** ^ not supported yet
  497. ***** ^ not supported yet
  498. 243 IF FTSupport.Aborted THEN
  499. ***** ^ not supported yet
  500. ***** ^ not supported yet
  501. 244 FTSupport.Cancel;
  502. ***** ^ not supported yet
  503. ***** ^ not supported yet
  504. 245 END;
  505. 246 FTSupport.CloseStatusWindow;
  506. ***** ^ not supported yet
  507. ***** ^ not supported yet
  508. 247 RETURN Result
  509. 248 ELSE
  510. 249 CommUtil.ErrorMessage('Could not open file!');
  511. ***** ^ not supported yet
  512. ***** ^ not supported yet
  513. ***** ^ not supported yet
  514. 250 RETURN 12;
  515. 251 END;
  516. 252 END WXModemReceive;
  517. ***** ^ not supported yet
  518. 253
  519. 254 (*..................................................*)
  520. 255
  521. 256 PROCEDURE GetResponse(VAR c:CHAR):CARDINAL;
  522. 257 VAR
  523. 258 CANCount : CARDINAL;
  524. 259 GotResponse : BOOLEAN;
  525. 260 BEGIN
  526. 261 CANCount := 0;
  527. 262 REPEAT
  528. 263 IF FTSupport.AbortRequested() THEN
  529. ***** ^ not supported yet
  530. ***** ^ not supported yet
  531. ***** ^ not supported yet
  532. 264 RETURN(6);
  533. 265 END;
  534. 266 GotResponse := RS232.SerialRead(c,100);
  535. ***** ^ not supported yet
  536. ***** ^ not supported yet
  537. ***** ^ not supported yet
  538. 267 IF GotResponse THEN
  539. 268 IF c=CAN THEN
  540. ***** ^ not supported yet
  541. 269 INC(CANCount);
  542. ***** ^ undeclared identifier
  543. ***** ^ not supported yet
  544. 270 IF CANCount=3 THEN
  545. 271 RETURN(13);
  546. 272 END;
  547. 273 END
  548. 274 ELSE
  549. 275 FTSupport.LastMessage := 'Timeout';
  550. ***** ^ not supported yet
  551. ***** ^ not supported yet
  552. ***** ^ not supported yet
  553. 276 INC(FTSupport.Errors);
  554. ***** ^ undeclared identifier
  555. ***** ^ not supported yet
  556. ***** ^ not supported yet
  557. 277 FTSupport.UpdateStatus;
  558. ***** ^ not supported yet
  559. ***** ^ not supported yet
  560. 278 IF FTSupport.Errors=5 THEN
  561. ***** ^ not supported yet
  562. ***** ^ not supported yet
  563. 279 RETURN(2);
  564. 280 END;
  565. 281 END;
  566. 282 UNTIL GotResponse AND ((c=NAK) OR (c=ACK) OR (c=WNDREQ));
  567. ***** ^ not supported yet
  568. ***** ^ not supported yet
  569. ***** ^ not supported yet
  570. 283 FTSupport.LastMessage := '';
  571. ***** ^ not supported yet
  572. ***** ^ not supported yet
  573. 284 FTSupport.UpdateStatus;
  574. ***** ^ not supported yet
  575. ***** ^ not supported yet
  576. 285 RETURN 0;
  577. 286 END GetResponse;
  578. ***** ^ not supported yet
  579. 287
  580. 288 (*..................................................*)
  581. 289
  582. 290 PROCEDURE SendBlock(VAR Block:ARRAY OF CHAR; BlockNo:CARDINAL);
  583. ***** ^ not supported yet
  584. 291 (* Send a block out the serial port while calculating a CRC in *)
  585. 292 (* parallel, then send the CRC. *)
  586. 293 VAR
  587. 294 i,TxCRC,CRC : CARDINAL;
  588. 295
  589. 296 (*. . . . . . . . . . . . . . . . . . . . . . . .*)
  590. 297
  591. 298 PROCEDURE Send(c:CHAR);
  592. 299 VAR
  593. 300 CRCIndex : CARDINAL;
  594. 301 BEGIN
  595. 302 CRCIndex := CARDINAL(BITSET(CRC>>8)/BITSET(ORD(c)));
  596. ***** ^ undeclared identifier
  597. ***** ^ not supported yet
  598. ***** ^ undeclared identifier
  599. ***** ^ undeclared identifier
  600. ***** ^ not supported yet
  601. 303 CRC := CARDINAL(BITSET(FTSupport.CRCTable[CRCIndex])/BITSET(CRC<<8));
  602. ***** ^ undeclared identifier
  603. ***** ^ not supported yet
  604. ***** ^ not supported yet
  605. ***** ^ not supported yet
  606. ***** ^ undeclared identifier
  607. ***** ^ not supported yet
  608. 304 IF (c=DLE) OR (c=SYN) OR (c=XON) OR (c=XOFF) THEN
  609. ***** ^ not supported yet
  610. 305 RS232.SerialWrite(DLE,1);
  611. ***** ^ not supported yet
  612. ***** ^ not supported yet
  613. ***** ^ not supported yet
  614. 306 c := CHR(CARDINAL(BITSET(ORD(c))/BITSET(64)))
  615. ***** ^ undeclared identifier
  616. ***** ^ undeclared identifier
  617. ***** ^ undeclared identifier
  618. ***** ^ not supported yet
  619. ***** ^ undeclared identifier
  620. ***** ^ not supported yet
  621. 307 END;
  622. 308 RS232.SerialWrite(c,1);
  623. ***** ^ not supported yet
  624. ***** ^ not supported yet
  625. ***** ^ not supported yet
  626. 309 END Send;
  627. ***** ^ not supported yet
  628. 310
  629. 311 (*. . . . . . . . . . . . . . . . . . . . . . . .*)
  630. 312
  631. 313 BEGIN (* SendBlock *)
  632. 314 RS232.SerialWrite(SYN,1);
  633. ***** ^ not supported yet
  634. ***** ^ not supported yet
  635. ***** ^ not supported yet
  636. ***** ^ not supported yet
  637. 315 RS232.SerialWrite(SYN,1);
  638. ***** ^ not supported yet
  639. ***** ^ not supported yet
  640. ***** ^ not supported yet
  641. ***** ^ not supported yet
  642. 316 RS232.SerialWrite(SOH,1);
  643. ***** ^ not supported yet
  644. ***** ^ not supported yet
  645. ***** ^ not supported yet
  646. ***** ^ not supported yet
  647. 317 Send(CHR(BlockNo));
  648. ***** ^ not supported yet
  649. ***** ^ undeclared identifier
  650. ***** ^ not supported yet
  651. 318 Send(CHR(255-BlockNo));
  652. ***** ^ not supported yet
  653. ***** ^ undeclared identifier
  654. ***** ^ not supported yet
  655. 319 CRC := 0;
  656. 320 FOR i:=0 TO 127 DO
  657. 321 Send(Block[i]);
  658. ***** ^ not supported yet
  659. ***** ^ not supported yet
  660. ***** ^ not supported yet
  661. 322 END;
  662. 323 TxCRC := CRC;
  663. 324 Send(CHR(TxCRC DIV 100H));
  664. ***** ^ not supported yet
  665. ***** ^ undeclared identifier
  666. ***** ^ not supported yet
  667. 325 Send(CHR(TxCRC MOD 100H));
  668. ***** ^ not supported yet
  669. ***** ^ undeclared identifier
  670. ***** ^ not supported yet
  671. 326 END SendBlock;
  672. ***** ^ not supported yet
  673. 327
  674. 328 (*..................................................*)
  675. 329
  676. 330 PROCEDURE GetStartChar(VAR c:CHAR):CARDINAL;
  677. 331 VAR
  678. 332 Result : CARDINAL;
  679. 333 BEGIN
  680. 334 REPEAT
  681. 335 Result := GetResponse(c);
  682. ***** ^ not supported yet
  683. ***** ^ not supported yet
  684. 336 IF Result<>0 THEN
  685. 337 RETURN(Result);
  686. 338 END;
  687. 339 UNTIL (c=WNDREQ);
  688. ***** ^ not supported yet
  689. 340 RS232.FlushInBuf;
  690. ***** ^ not supported yet
  691. ***** ^ not supported yet
  692. 341 RETURN 0;
  693. 342 END GetStartChar;
  694. ***** ^ not supported yet
  695. 343
  696. 344 (*..................................................*)
  697. 345
  698. 346 PROCEDURE WXMSend():CARDINAL;
  699. 347 CONST
  700. 348 WindowSize = 4;
  701. 349 VAR
  702. 350 c,Resp : CHAR;
  703. 351 Result,BytesRead,
  704. 352 BlockNo,LastAcked : CARDINAL;
  705. 353 Buffer : ARRAY[0..127] OF CHAR;
  706. ***** ^ not supported yet
  707. ***** ^ not supported yet
  708. 354
  709. 355 (*. . . . . . . . . . . . . . . . . . . . . . . . .*)
  710. 356
  711. 357 PROCEDURE CheckWindow(Resp,c:CHAR):CARDINAL;
  712. 358 VAR
  713. 359 Temp : CARDINAL;
  714. 360 BEGIN
  715. 361 Temp := LastAcked;
  716. 362 WHILE ((LastAcked+1) MOD 4)<>ORD(c) DO
  717. ***** ^ undeclared identifier
  718. ***** ^ not supported yet
  719. 363 INC(LastAcked);
  720. ***** ^ undeclared identifier
  721. ***** ^ not supported yet
  722. 364 END;
  723. 365 IF Resp=ACK THEN
  724. ***** ^ not supported yet
  725. 366 INC(LastAcked);
  726. ***** ^ undeclared identifier
  727. ***** ^ not supported yet
  728. 367 END;
  729. 368 IF LastAcked>BlockNo THEN
  730. 369 (* got ACK for block I havent sent yet!! (eg double ack), forget it *)
  731. 370 LastAcked := Temp;
  732. 371 RETURN 0;
  733. 372 END;
  734. 373 IF Resp=NAK THEN
  735. ***** ^ not supported yet
  736. 374 FTSupport.LastMessage := 'Got NAK';
  737. ***** ^ not supported yet
  738. ***** ^ not supported yet
  739. ***** ^ not supported yet
  740. 375 BlockNo:=LastAcked+1;
  741. 376 FIO.Seek(f,128*LONGCARD(BlockNo-1));
  742. ***** ^ not supported yet
  743. ***** ^ not supported yet
  744. ***** ^ not supported yet
  745. ***** ^ undeclared identifier
  746. ***** ^ not supported yet
  747. 377 INC(FTSupport.Errors);
  748. ***** ^ undeclared identifier
  749. ***** ^ not supported yet
  750. ***** ^ not supported yet
  751. 378 IF FTSupport.Errors=10 THEN
  752. ***** ^ not supported yet
  753. ***** ^ not supported yet
  754. 379 FTSupport.Aborted := TRUE;
  755. ***** ^ not supported yet
  756. ***** ^ not supported yet
  757. 380 RETURN(6)
  758. 381 END;
  759. 382 ELSE
  760. 383 FTSupport.Errors := 0;
  761. ***** ^ not supported yet
  762. ***** ^ not supported yet
  763. 384 FTSupport.LastMessage := '';
  764. ***** ^ not supported yet
  765. ***** ^ not supported yet
  766. 385 END;
  767. 386 FTSupport.Transferred := LONGCARD(LastAcked)*128;
  768. ***** ^ not supported yet
  769. ***** ^ not supported yet
  770. ***** ^ undeclared identifier
  771. ***** ^ not supported yet
  772. 387 FTSupport.UpdateStatus;
  773. ***** ^ not supported yet
  774. ***** ^ not supported yet
  775. 388 RETURN 0;
  776. 389 END CheckWindow;
  777. ***** ^ not supported yet
  778. 390
  779. 391 (*. . . . . . . . . . . . . . . . . . . . . . . . .*)
  780. 392
  781. 393 BEGIN (* WXMSend *)
  782. 394 Result := GetStartChar(c);
  783. ***** ^ not supported yet
  784. ***** ^ not supported yet
  785. 395 IF Result<>0 THEN
  786. 396 RETURN(Result);
  787. 397 END;
  788. 398 LastAcked := 0;
  789. 399 BlockNo := 1;
  790. 400 FTSupport.UpdateStatus;
  791. ***** ^ not supported yet
  792. ***** ^ not supported yet
  793. 401 WHILE NOT FIO.EOF DO
  794. ***** ^ not supported yet
  795. ***** ^ not supported yet
  796. 402 WHILE BlockNo-LastAcked>=WindowSize DO
  797. 403 FTSupport.UpdateStatus;
  798. ***** ^ not supported yet
  799. ***** ^ not supported yet
  800. 404 REPEAT
  801. 405 REPEAT
  802. 406 Result := GetResponse(c);
  803. ***** ^ not supported yet
  804. ***** ^ not supported yet
  805. 407 IF (Result<>0) AND (Result<>2) THEN
  806. 408 RETURN(Result); (* dont return on timeout *)
  807. 409 END;
  808. 410 UNTIL (c=ACK) OR (c=NAK) OR (Result=2);
  809. ***** ^ not supported yet
  810. ***** ^ not supported yet
  811. 411 IF Result=0 THEN
  812. 412 Resp:=c;
  813. 413 IF NOT RS232.SerialRead(c,150) THEN
  814. ***** ^ not supported yet
  815. ***** ^ not supported yet
  816. ***** ^ not supported yet
  817. 414 Result:=2;
  818. 415 END;
  819. 416 END;
  820. 417 UNTIL (ORD(c)>=0) AND (ORD(c)<=3) OR (Result=2);
  821. ***** ^ undeclared identifier
  822. ***** ^ not supported yet
  823. ***** ^ undeclared identifier
  824. ***** ^ not supported yet
  825. 418 IF Result=0 THEN
  826. 419 Result := CheckWindow(Resp,c);
  827. ***** ^ not supported yet
  828. ***** ^ not supported yet
  829. 420 IF Result<>0 THEN
  830. 421 RETURN(Result);
  831. 422 END;
  832. 423 ELSE
  833. 424 (* handle timeout by resending last block *)
  834. 425 DEC(BlockNo);
  835. ***** ^ undeclared identifier
  836. ***** ^ not supported yet
  837. 426 FIO.Seek(f,128*LONGCARD(BlockNo-1));
  838. ***** ^ not supported yet
  839. ***** ^ not supported yet
  840. ***** ^ not supported yet
  841. ***** ^ undeclared identifier
  842. ***** ^ not supported yet
  843. 427 END;
  844. 428 END;
  845. 429 BytesRead := FIO.RdBin(f,Buffer,128);
  846. ***** ^ not supported yet
  847. ***** ^ not supported yet
  848. ***** ^ not supported yet
  849. ***** ^ not supported yet
  850. ***** ^ not supported yet
  851. 430 IF FIO.IOresult()<>0 THEN
  852. ***** ^ not supported yet
  853. ***** ^ not supported yet
  854. ***** ^ not supported yet
  855. 431 RETURN(5);
  856. 432 END;
  857. 433 IF BytesRead<128 THEN
  858. 434 Lib.Fill(ADR(Buffer[BytesRead]),128-BytesRead,CHR(26));
  859. ***** ^ not supported yet
  860. ***** ^ not supported yet
  861. ***** ^ undeclared identifier
  862. ***** ^ not supported yet
  863. ***** ^ not supported yet
  864. ***** ^ undeclared identifier
  865. ***** ^ not supported yet
  866. 435 END;
  867. 436 SendBlock(Buffer,BlockNo MOD 100H);
  868. ***** ^ not supported yet
  869. ***** ^ not supported yet
  870. ***** ^ not supported yet
  871. 437 INC(BlockNo);
  872. ***** ^ undeclared identifier
  873. ***** ^ not supported yet
  874. 438 FTSupport.UpdateStatus;
  875. ***** ^ not supported yet
  876. ***** ^ not supported yet
  877. 439 LOOP
  878. 440 IF (RS232.SerialRead(c,0)) AND ((c=ACK) OR (c=NAK)) THEN
  879. ***** ^ not supported yet
  880. ***** ^ not supported yet
  881. ***** ^ not supported yet
  882. ***** ^ not supported yet
  883. ***** ^ not supported yet
  884. 441 Resp := c;
  885. 442 IF (RS232.SerialRead(c,150)) AND (c>=0C) AND (c<=3C) THEN
  886. ***** ^ not supported yet
  887. ***** ^ not supported yet
  888. ***** ^ not supported yet
  889. 443 Result := CheckWindow(Resp,c);
  890. ***** ^ not supported yet
  891. ***** ^ not supported yet
  892. 444 IF Result<>0 THEN
  893. 445 RETURN(Result);
  894. 446 END;
  895. 447 ELSE
  896. 448 EXIT;
  897. 449 END;
  898. 450 ELSE
  899. 451 EXIT;
  900. 452 END;
  901. 453 END;
  902. 454 END;
  903. 455 FTSupport.LastMessage := 'End of File';
  904. ***** ^ not supported yet
  905. ***** ^ not supported yet
  906. ***** ^ not supported yet
  907. 456 FTSupport.UpdateStatus;
  908. ***** ^ not supported yet
  909. ***** ^ not supported yet
  910. 457 REPEAT
  911. 458 REPEAT
  912. 459 RS232.SerialWrite(EOT,1);
  913. ***** ^ not supported yet
  914. ***** ^ not supported yet
  915. ***** ^ not supported yet
  916. ***** ^ not supported yet
  917. 460 Result := GetResponse(c);
  918. ***** ^ not supported yet
  919. ***** ^ not supported yet
  920. 461 IF Result<>0 THEN
  921. 462 RETURN(Result);
  922. 463 END;
  923. 464 UNTIL (c=NAK) OR (c=ACK);
  924. ***** ^ not supported yet
  925. ***** ^ not supported yet
  926. 465 UNTIL c=ACK;
  927. ***** ^ not supported yet
  928. 466 RETURN 0;
  929. 467 END WXMSend;
  930. ***** ^ not supported yet
  931. 468
  932. 469 (*..................................................*)
  933. 470
  934. 471 PROCEDURE WXModemSend(VAR Filename:ARRAY OF CHAR):CARDINAL;
  935. ***** ^ not supported yet
  936. 472 VAR
  937. 473 Result : CARDINAL;
  938. 474 BEGIN
  939. 475 IF FIO.Exists(Filename) THEN
  940. ***** ^ not supported yet
  941. ***** ^ not supported yet
  942. ***** ^ not supported yet
  943. 476 InitVars(Filename);
  944. ***** ^ not supported yet
  945. ***** ^ not supported yet
  946. 477 f := FIO.Open(Filename);
  947. ***** ^ not supported yet
  948. ***** ^ not supported yet
  949. ***** ^ not supported yet
  950. ***** ^ not supported yet
  951. 478 FIO.EOF := FALSE;
  952. ***** ^ not supported yet
  953. ***** ^ not supported yet
  954. 479 FTSupport.SizeInBytes := FIO.Size(f);
  955. ***** ^ not supported yet
  956. ***** ^ not supported yet
  957. ***** ^ not supported yet
  958. ***** ^ not supported yet
  959. ***** ^ not supported yet
  960. 480 FTSupport.OpenStatusWindow('WXModem Upload');
  961. ***** ^ not supported yet
  962. ***** ^ not supported yet
  963. ***** ^ not supported yet
  964. 481 FTSupport.NewFilename;
  965. ***** ^ not supported yet
  966. ***** ^ not supported yet
  967. 482 Result := WXMSend();
  968. ***** ^ not supported yet
  969. ***** ^ not supported yet
  970. 483 FTSupport.CloseStatusWindow;
  971. ***** ^ not supported yet
  972. ***** ^ not supported yet
  973. 484 FIO.Close(f);
  974. ***** ^ not supported yet
  975. ***** ^ not supported yet
  976. ***** ^ not supported yet
  977. 485 RETURN Result;
  978. 486 ELSE
  979. 487 CommUtil.ErrorMessage('Could not open file!');
  980. ***** ^ not supported yet
  981. ***** ^ not supported yet
  982. ***** ^ not supported yet
  983. 488 RETURN 7;
  984. 489 END;
  985. 490 END WXModemSend;
  986. ***** ^ not supported yet
  987. 491
  988. 492 (*..................................................*)
  989. 493
  990. 494 END WXModem.
  991. ***** ^ not supported yet
  992. 495
  993. 496 errors