Diagnostic Programs
BASIC Code Listings
Test Serial Ports

3200 REM ==== ====
3205 REM ==== TEST SERIAL PORTS ====
3210 PRINT : PRINT
3220 INPUT "Test serial ports (Y/N)? ", A$
3225 IF A$ <> "Y" AND A$ <> "y" THEN 3900
3300 PRINT : PRINT "Test plug should be attached": PRINT
3310 INPUT "Enter port to test: 0) Quit 1) COM1 2) COM2 3) COM3 4) COM4 "; N%
3315 IF N% < 0 OR N% > 4 THEN 3310
3320 IF N% = 0 THEN 3900
3330 DEF SEG = &H0: J% = (PEEK(&H400 + N% + N% - 1)) * 256 + PEEK(&H400 + N% + N% - 2)
3332 IF J% = 0 THEN PRINT : PRINT "Port"; N%; " not installed": GOTO 3900
3400 REM ==== TEST TRANSMIT/RECEIVE ====
3410 PRINT : PRINT "Testing transmit/receive - ";
3415 E% = 0
3420 FOR I% = 32 TO 96
3422 OUT J%, I%
3423 K% = 0
3424 WHILE K% < 64
3426 L% = INP(J% + 5): IF L% - INT(L% / 2) * 2 = 1 THEN K% = 999
3428 K% = K% + 1
3430 WEND
3436 IF INP(J%) <> I% THEN E% = E% + 1
3438 NEXT I%
3440 IF E% >= 64 THEN PRINT "Failed": GOTO 3500
3445 PRINT E%; "errors"
3500 REM ==== TEST INTERRUPT PROCESSING ====
3505 PRINT : PRINT "Testing interrupt - ";
3508 ON ERROR GOTO 3544
3510 IF N% = 1 THEN OPEN "COM1:9600,N,8,1" FOR RANDOM AS #1
3515 IF N% = 2 THEN OPEN "COM2:9600,N,8,1" FOR RANDOM AS #1
3520 T$ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ": U$ = ""
3522 ON COM(N%) GOSUB 3580
3524 COM(N%) ON
3526 FOR K% = 1 TO 1024: NEXT K%
3528 U$ = ""
3530 PRINT #1, T$;
3535 FOR K% = 1 TO 1024: NEXT K%
3540 IF U$ = T$ THEN PRINT "OK": GOTO 3590
3542 PRINT "Failed": GOTO 3590
3544 PRINT "Failed": GOTO 3610
3580 L% = LOC(1): IF L% = 0 THEN RETURN
3582 U$ = U$ + INPUT$(L%, #1)
3586 RETURN
3590 COM(N%) OFF: ON ERROR GOTO 0
3600 REM ==== TEST RTS/CTS ====
3610 PRINT : PRINT "Testing RTS/CTS - ";
3615 E% = 0
3620 FOR I% = 1 TO 16
3630 OUT J% + 4, 2
3632 FOR K% = 1 TO 256: NEXT K%
3634 L% = INT(INP(J% + 6) / 16)
3636 IF L% - INT(L% / 2) * 2 <> 1 THEN E% = 1
3640 OUT J% + 4, 0
3642 FOR K% = 1 TO 256: NEXT K%
3644 L% = INT(INP(J% + 6) / 16)
3646 IF L% - INT(L% / 2) * 2 <> 0 THEN E% = 1
3648 NEXT I%
3650 IF E% = 0 THEN PRINT "OK": GOTO 3700
3655 PRINT "Failed"
3700 REM ==== TEST DTR/DSR ====
3710 PRINT : PRINT "Testing DTR/DSR - ";
3715 E% = 0
3720 FOR I% = 1 TO 16
3730 OUT J% + 4, 1
3732 FOR K% = 1 TO 256: NEXT K%
3734 L% = INT(INP(J% + 6) / 32)
3736 IF L% - INT(L% / 2) * 2 <> 1 THEN E% = 1
3740 OUT J% + 4, 0
3742 FOR K% = 1 TO 256: NEXT K%
3744 L% = INT(INP(J% + 6) / 32)
3746 IF L% - INT(L% / 2) * 2 <> 0 THEN E% = 1
3748 NEXT I%
3750 IF E% = 0 THEN PRINT "OK": GOTO 3900
3755 PRINT "Failed"
3900 END