10
20
30 :
40 ON ERROR OSCLI"FX2":OSCLI"FX3":PRINTTAB(0,9):REPORT:PRINT" at ";ERL;:END
50 PRINT"Program has hung";
60 *FX2,2
70 CLS:PRINT"Serial Port Tester -- Press some keys:"
80 PRINT'"Sending out:"'"Coming in: "
90 PRINT'"Keyboard buffer: ";FNempt(ADVAL(-1))
100 PRINT"Serial Input Buffer: ";FNempt(ADVAL(-2))
110 PRINT"Serial Output Buffer:";FNfull(ADVAL(-3))
120 PRINT'"If output buffer fills up and input buffer stays"'"empty, there's a problem with the serial port."
130 REPEAT
140
150 a1%=ADVAL(-1):a2%=ADVAL(-2):a3%=ADVAL(-3):IFa3%<>0 a1%=0
160 REPEATUNTILADVAL(-1)<>a1% OR ADVAL(-2)<>0 OR ADVAL(-3)<>a3%
170 IFADVAL(-1)<>0 AND ADVAL(-3)<>0 THEN B%=GET:PRINTTAB(13,2);FNh(B%,2);" ";FNc(B%):OSCLI"FX3,7":VDUB%:*FX3
180 IFADVAL(-2)<>0 THEN OSCLI"FX2,1":B%=GET:OSCLI"FX2,2":PRINTTAB(13,3);FNh(B%,2);" ";FNc(B%)
190 PRINTTAB(21,5);FNempt(ADVAL(-1));TAB(21,6);FNempt(ADVAL(-2));TAB(21,7);FNfull(ADVAL(-3))
200 UNTILINKEY-1 AND INKEY-2 AND INKEY-3
210 END
220 DEFFNh(N%,D%)=RIGHT$("0000000"+STR$~N%,D%)
230 DEFFNc(N%):IF N%=127 OR N%<32:="." ELSE =CHR$N%
240 DEFFNfull(N%):IF N%=0:="0 Full" ELSE =STR$N%+" "
250 DEFFNempt(N%):IF N%=0:="0 Empty" ELSE =STR$N%+" "