DECLARE SUB TimeWait () DECLARE SUB MakeBox () DECLARE SUB SmallBox (y%, x%, text1$, text2$) DECLARE SUB GetKey (a$) DECLARE SUB OpenPort (PortNumber!, PokePlace, Speed!) DECLARE SUB SendFCMessage (Message$, PokePlace, Speed!) DECLARE SUB Title () DIM DEST1, DEST2, DEST3, DEST4 AS INTEGER REM ============================================================= REM FireCracker Interface Test Program REM W. Venable - 3 April 2001 REM This program tests simple output to the FireCracker REM Program FC-TEST.BAS is copyright 2001 by Wallace Venable REM ================ Variables for Control Operations ============================= REM == Additional information on the FireCracker codes is found on === REM == http://www.x10.com and several other locations. REM For FIRECRACKER Header$ = "1101010110101010" FOOTER$ = "10101101" REM For test purposes HCODE$ = "0110" 'House Code A GPN$ = "0000" 'UNIT! <9 I've divided Units into High and Low groups REM GPN$ = "0100" for UNIT! => 9 REM Action Codes REM 1 ON = 0000 0000 for FIRECRACKER REM 1 OFF = 0010 0000 REM BRIGHT = 1000 1000 '5% power change REM DIM = 1001 1000 '5% power change REM COMMAND = Header$(16) + HCODE$(4) + GPN$(4) + ACTION$(8) + FOOTER$(8) REM PortTestStuff: REM COM 1 03F8 to 03FF INT 4 REM COM 2 02F8 to 02FF INT 3 REM COM 3 03E8 to 03EF INT 4 REM COM 4 02E8 to 02EF INT 3 REM LPT1 0378 to 037B INT 7 REM Base addresses for the COM ports can be read from the BIOS Data Area. REM COM1's Base Address 0000:0400 HEX REM COM2's Base Address 0000:0402 REM COM3's Base Address 0000:0404 REM COM4's Base Address 0000:0406 REM Message to FireCracker is sent to Base Address + 4 REM "Ready" = 3 REM "Reset" = 0 REM Logical "1" = 2 REM Logical "0" = 1 REM ================ START of ACTION ============================= CALL MakeBox CALL Title text1$ = "CAUTION - This program makes hardware calls which may" text2$ = "lock up your computer and require a RESET " CALL SmallBox(14, 10, text1$, text2$) CALL GetKey(a$) REM ================ START of MAIN PROGRAM ============================= REM ==================== Choose Serial Port =========================== SetPort: CALL MakeBox a$ = "" Delay$ = "" LOCATE 3, 6 PRINT "Which Serial Port do you wish to test? <1>, <2>, <3> or <4>" DO UNTIL a$ = "1" OR a$ = "2" OR a$ = "3" OR a$ = "4" a$ = INKEY$ PortNumber! = VAL(a$) LOOP a$ = "" LOCATE 5, 6 PRINT "Do you want a time delay?" LOCATE 6, 8 PRINT " No - probably not needed for old PCs" LOCATE 7, 8 PRINT " Yes - might be needed for Pentiums" DO UNTIL Delay$ = "N" OR Delay$ = "Y" Delay$ = UCASE$(INKEY$) IF Delay$ = "N" THEN Speed! = 0 IF Delay$ = "Y" THEN Speed! = 1 LOOP IF PortNumber! = 1 THEN PokePlace = &H3FC IF PortNumber! = 2 THEN PokePlace = &H2FC REM The following are not universal - Will NOT work for IBM PS2? IF PortNumber! = 3 THEN PokePlace = &H3EC IF PortNumber! = 4 THEN PokePlace = &H2EC CALL OpenPort(PortNumber!, PokePlace, Speed!) REM ==================== Send TEST SIGNALS ====================================== CALL MakeBox SendTests: a$ = "" LOCATE 3, 6 'test print PRINT "Port = COM"; PortNumber!; " Delay = "; Delay$ LOCATE 5, 6 PRINT "Press to toggle the test output ON." LOCATE 6, 6 PRINT " to toggle the test output OFF." LOCATE 7, 6 PRINT " to DIM the test output." LOCATE 8, 6 PRINT " to BRIGHTEN the test output." LOCATE 9, 6 PRINT "

to try another port setting." LOCATE 12, 6 PRINT " to EXIT." DO UNTIL a$ = "O" OR a$ = "B" OR a$ = "D" OR a$ = "F" OR a$ = "E" OR a$ = "P" a$ = UCASE$(INKEY$) LOOP REM Action Codes REM "1 ON" = 0000 0000 for FIRECRACKER IF a$ = "O" THEN ACTION$ = "00000000" REM "1 OFF" = 0010 0000 IF a$ = "F" THEN ACTION$ = "00100000" REM "BRIGHT" = 1000 1000 'said to be 5% power change IF a$ = "B" THEN ACTION$ = "10001000" REM "DIM" = 1001 1000 'said to be 5% power change IF a$ = "D" THEN ACTION$ = "10011000" IF a$ = "P" GOTO SetPort IF a$ = "E" THEN GOTO Finish REM ======================================================= Message$ = Header$ + HCODE$ + GPN$ + ACTION$ + FOOTER$ CALL SendFCMessage(Message$, PokePlace, Speed!) GOTO SendTests: REM =============================================== Finish: CLOSE #2 SCREEN 0 CLS END REM =========================== END of MAIN PROGRAM ============================= SUB GetKey (a$) REM ======================== SUB GetKey ================================== REM Waits for and returns a key character NotYet: a$ = INKEY$ IF a$ = "" THEN GOTO NotYet END SUB SUB MakeBox REM ============================= SUB MakeBox ============================= CLS LOCATE 1, 1 PRINT "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "º º" PRINT "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ FC-TEST ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" END SUB SUB OpenPort (PortNumber!, PokePlace, Speed!) CLOSE #2 IF PortNumber! = 1 THEN OPEN "COM1:600,N,7,2,RS,CS,DS,CD" FOR RANDOM AS #2 IF PortNumber! = 2 THEN OPEN "COM2:600,N,7,2,RS,CS,DS,CD" FOR RANDOM AS #2 IF PortNumber! = 4 THEN OPEN "COM3:600,N,7,2,RS,CS,DS,CD" FOR RANDOM AS #2 IF PortNumber! = 4 THEN OPEN "COM4:600,N,7,2,RS,CS,DS,CD" FOR RANDOM AS #2 REM Reset FireCracker OUT PokePlace, 3 IF Speed! = 1 THEN CALL TimeWait OUT PokePlace, 0 IF Speed! = 1 THEN CALL TimeWait OUT PokePlace, 3 IF Speed! = 1 THEN CALL TimeWait END SUB SUB SendFCMessage (Message$, PokePlace, Speed!) REM === This is the actual transmission to the FireCracker interface ==== FOR j = 1 TO LEN(Message$) c$ = MID$(Message$, j, 1) IF c$ = "0" THEN OUT PokePlace, 1 IF Speed! = 1 THEN CALL TimeWait OUT PokePlace, 3 IF Speed! = 1 THEN CALL TimeWait END IF IF c$ = "1" THEN OUT PokePlace, 2 IF Speed! = 1 THEN CALL TimeWait OUT PokePlace, 3 IF Speed! = 1 THEN CALL TimeWait END IF NEXT j END SUB SUB SmallBox (y%, x%, text1$, text2$) LOCATE y%, x% PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿" LOCATE y% + 1, x% PRINT "³ ³" LOCATE y% + 2, x% PRINT "³ ³" LOCATE y% + 3, x% PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ" LOCATE y% + 1, x% + 2 PRINT text1$ LOCATE y% + 2, x% + 2 PRINT text2$ 'LOCATE y%, x% 'PRINT "" END SUB SUB TimeWait REM Maintain state for at least .5 ms T1# = TIMER DO UNTIL T2# > T1# + .00055 T2# = TIMER IF T2# < T1# THEN T1# = TIMER REM Midnight passed LOOP END SUB SUB Title LOCATE 4, 10 PRINT "Program FC-TEST sends signals to an X10 FireCracker interface." LOCATE 7, 10 PRINT "Its purpose is to help identify a Serial (COM) port connection" LOCATE 8, 6 PRINT "and to demonstrate that the interface is active." LOCATE 9, 10 PRINT "The program sends simple ON-OFF, DIM, and BRIGHT output to" LOCATE 10, 6 PRINT "the FireCracker." LOCATE 11, 10 PRINT "Set the X-10 Receiver to House A, and any modules to A-1" LOCATE 18, 28 PRINT "Press any key to continue." LOCATE 20, 16 PRINT "Program FC-TEST is copyright 2001 by Wallace Venable" END SUB