10! OUTPUT 2 USING "#,K";"<lf>REN<cr>INDENT<cr>RE-STORE ""HW""<cr>" 20 ! 30 END 40 ! PAGE -> 50 !************************************************************************ 60 ! 70 Hw_hw:SUB Hw_hw 80 ! 90 ! This subprogram is used to initialize the HP3565S demo programs 100 ! hardware interface file. Note that Hw_hw does not initialize the 110 ! device selector address of the HP3565S hardware. 120 ! 130 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 140 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 150 Io_error=0 160 Hpib_addr=0 170 Sel_code=7 180 ASSIGN @Hpib_mod TO 700 190 ASSIGN @Bin_hpib_mod TO 700;FORMAT OFF 200 SUBEND 210 ! 220 Hw_cmd:SUB Hw_cmd(Op_string$,OPTIONAL Timeout_time) 230 ! 240 ! This subprogram is used to send a command string to the HP-IB 250 ! module. The command string sent is specified by <Op_string$>. 260 ! <Timeout_time> is an optional timeout parameter in seconds. 270 ! 280 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 290 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 300 Io_error=0 310 ON ERROR GOTO Hw_io_error 320 IF NPAR=2 THEN 330 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 340 END IF 350 OUTPUT @Hpib_mod;Op_string$ 360 IF 0 THEN 370 Hw_io_error:Io_error=1 380 END IF 390 SUBEND 400 ! 410 Hw_rsp:DEF FNHw_rsp$(OPTIONAL Timeout_time) 420 ! 430 ! This function is used to read a response from HP-IB module. This 440 ! function returns the response to the caller in the function result 450 ! string. <Timeout_time> is an optional timeout parameter in 460 ! seconds. 470 ! 480 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 490 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 500 DIM Temp$[255] 510 Io_error=0 520 ON ERROR GOTO Hw_io_error 530 IF NPAR=1 THEN 540 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 550 END IF 560 ENTER @Hpib_mod;Temp$ 570 IF 0 THEN 580 Hw_io_error:! 590 Io_error=1 600 Temp$="" 610 END IF 620 RETURN Temp$ 630 FNEND 640 ! 650 Hw_cmd_rsp:DEF FNHw_cmd_rsp$(Op_string$,OPTIONAL Timeout_time) 660 ! 670 ! This function is used to send a command string to the HP-IB module 680 ! and read a response string back from then HP-IB module. First the 690 ! command string, specified by <Op_string$>, is sent to the HP-IB 700 ! module. Then a response is read back from then HP-IB module. 710 ! This function returns the response to the caller in the function 720 ! result string. <Timeout_time> is an optional timeout parameter in 730 ! seconds. 740 ! 750 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 760 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 770 DIM Temp$[255] 780 Io_error=0 790 ON ERROR GOTO Hw_io_error 800 IF NPAR=2 THEN 810 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 820 END IF 830 OUTPUT @Hpib_mod;Op_string$ 840 ENTER @Hpib_mod;Temp$ 850 IF 0 THEN 860 Hw_io_error:! 870 Io_error=1 880 Temp$="" 890 END IF 900 RETURN Temp$ 910 FNEND 920 ! 930 Hw_mod_cmd:SUB Hw_mod_cmd(Mf_mod,Op_string$,OPTIONAL Timeout_time) 940 ! 950 ! This function is used to send a command string to an input module 960 ! or an source module. The module address is specified by <mf_mod>. 970 ! The command string to be sent is specified by <op_string$>. 980 ! <Timeout_time> is an optional timeout parameter in seconds. 990 ! 1000 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 1010 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 1020 Io_error=0 1030 ON ERROR GOTO Hw_io_error 1040 IF NPAR=3 THEN 1050 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 1060 END IF 1070 OUTPUT @Hpib_mod;"WCM ";Mf_mod;",'";Op_string$;"'" 1080 IF 0 THEN 1090 Hw_io_error:! 1100 Io_error=1 1110 END IF 1120 SUBEND 1130 ! 1140 Hw_mod_rsp:DEF FNHw_mod_rsp$(Mf_mod,OPTIONAL Timeout_time) 1150 ! 1160 ! This function is used to read a response string from an input 1170 ! module or an source module. The module is specified by <mf_mod>. 1180 ! The response is returned to the caller in the function result 1190 ! string. <Timeout_time> is an optional timeout parameter in 1200 ! seconds. 1210 ! 1220 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 1230 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 1240 DIM Temp$[255] 1250 Io_error=0 1260 ON ERROR GOTO Hw_io_error 1270 IF NPAR=2 THEN 1280 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 1290 END IF 1300 OUTPUT @Hpib_mod;"RRSP ";Mf_mod 1310 ENTER @Hpib_mod;Temp$ 1320 IF 0 THEN 1330 Hw_io_error:! 1340 Io_error=1 1350 Temp$="" 1360 END IF 1370 RETURN Temp$ 1380 FNEND 1390 ! 1400 Hw_mod_cmd_rsp:DEF FNHw_mod_cmd_rsp$(Mf_mod,Op_string$,OPTIONAL Timeout_time) 1410! 1420! This function is used to send a command string to an input module 1430! or an source module, and read a string response back from the 1440! specified module. The module address is specified by <mf_mod>. 1450! First, the specified module is sent the command string 1460! <op_string$>. Then, the response string is read from the 1470! specified module and returned to the host in the function result 1480! string. <Timeout_time> is an optional timeout parameter in 1490! seconds. 1500! 1510 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 1520 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 1530 DIM Temp$[255] 1540 Io_error=0 1550 ON ERROR GOTO Hw_io_error 1560 IF NPAR=3 THEN 1570 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 1580 END IF 1590 OUTPUT @Hpib_mod;"WCM ";Mf_mod;",'";Op_string$;"'" 1600 OUTPUT @Hpib_mod;"RRSP ";Mf_mod 1610 ENTER @Hpib_mod;Temp$ 1620 IF 0 THEN 1630 Hw_io_error:! 1640 Io_error=1 1650 Temp$="" 1660 END IF 1670 RETURN Temp$ 1680 FNEND 1690 ! 1700 Hw_gbl_cmd:SUB Hw_gbl_cmd(Class,Op_string$,OPTIONAL Timeout_time) 1710 ! 1720 ! This subprogram is used to send a global class command string to 1730 ! all modules in a specified class. All modules in the fast bus 1740 ! class specified by <class> will be sent the command string 1750 ! <op_string$>. For information on global classes, see HP3565S 1760 ! module documentation. <Timeout_time> is an optional timeout 1770 ! parameter in seconds. 1780 ! 1790 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 1800 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 1810 Io_error=0 1820 ON ERROR GOTO Hw_io_error 1830 IF NPAR=3 THEN 1840 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 1850 END IF 1860 OUTPUT @Hpib_mod;"WGCM ";Class;",'";Op_string$;"'" 1870 IF 0 THEN 1880 Hw_io_error:! 1890 Io_error=1 1900 END IF 1910 SUBEND 1920 ! 1930 Hw_write_blk:SUB Hw_write_blk(Block_id,INTEGER Block_array(*),OPTIONAL Timeout_time) 1940 ! 1950 ! This function is used to write a short integer data array into a 1960 ! HP-IB module data RAM block. All short integer data in the array 1970 ! <block_array(*)> will be downloaded into the HP-IB module data RAM 1980 ! block specified by <block_id>. <Timeout_time> is an optional 1990 ! timeout parameter in seconds. 2000 ! 2010 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 2020 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 2030 Io_error=0 2040 ON ERROR GOTO Hw_io_error 2050 IF NPAR=3 THEN 2060 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 2070 END IF 2080 Block_size=FNLib_sizeof(Block_array(*)) 2090 OUTPUT @Hpib_mod USING "#,K";"WBLD ";Block_id;",";Block_size;",#I" 2100 OUTPUT @Bin_hpib_mod;Block_array(*) 2110 IF 0 THEN 2120 Hw_io_error:! 2130 Io_error=1 2140 END IF 2150 SUBEND 2160 ! 2170 Hw_read_blk:SUB Hw_read_blk(Block_id,INTEGER Block_array(*),OPTIONAL Timeout_time) 2180 ! 2190 ! This subprogram is used to read a short integer data block from a 2200 ! HP-IB module data RAM block. Short integer data will be read from 2210 ! the data RAM block specified by <block_id> until the short integer 2220 ! array <block_array(*)> is full. <Timeout_time> is an optional 2230 ! timeout parameter in seconds. 2240 ! 2250 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 2260 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 2270 INTEGER Pound_i 2280 REAL Block_size 2290 Io_error=0 2300 ON ERROR GOTO Hw_io_error 2310 IF NPAR=3 THEN 2320 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 2330 END IF 2340 Block_size=FNLib_sizeof(Block_array(*)) 2350 OUTPUT @Hpib_mod;"RBLD ";Block_id;",";Block_size 2360 ENTER @Hpib_mod USING "#,W";Pound_i 2370 IF Pound_i<>9033 THEN 2380 Io_error=1 2390 OUTPUT @Hpib_mod;" " 2400 ELSE 2410 ENTER @Bin_hpib_mod;Block_array(*) 2420 END IF 2430 IF 0 THEN 2440 Hw_io_error:! 2450 Io_error=1 2460 END IF 2470 SUBEND 2480 ! 2490 Hw_enter_blk:SUB Hw_enter_blk(INTEGER Block_array(*),OPTIONAL Timeout_time) 2500! 2510! This subprogram is used to read a short integer data array from a 2520! running ICODE program. See HP-IB module documentation for 2530! information on how ICODE can send data to the host. This 2540! subprogram uses the HP-IB module RBLK HP-IB command. After 2550! sending the RBLK command, data is read from HP-IB and put into the 2560! short integer array <block_array(*)>. Data is read until 2570! <Block_array(*)> is full. <Timeout_time> is an optional timeout 2580! parameter in seconds. 2590! 2600 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 2610 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 2620 INTEGER Pound_i 2630 Io_error=0 2640 ON ERROR GOTO Hw_io_error 2650 IF NPAR=2 THEN 2660 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 2670 END IF 2680 OUTPUT @Hpib_mod;"RBLK" 2690 ENTER @Hpib_mod USING "#,W";Pound_i 2700 IF Pound_i<>9033 THEN 2710 Io_error=1 2720 OUTPUT @Hpib_mod;" " 2730 ELSE 2740 ENTER @Bin_hpib_mod;Block_array(*) 2750 END IF 2760 IF 0 THEN 2770 Hw_io_error:! 2780 Io_error=1 2790 END IF 2800 SUBEND 2810 ! 2820 Hw_output_blk:SUB Hw_output_blk(INTEGER Block_array(*),OPTIONAL Timeout_time) 2830! 2840! This subprogram is used to send a short integer data array to a 2850! running ICODE program. For information on ICODE and how ICODE can 2860! accept a block of data, see HP-IB module documentation. This 2870! subprogram uses the HP-IB module WBLK HP-IB command. After 2880! issuing the WBLK command, the data in the short integer array 2890! <block_array(*)> is sent to HP-IB module. <Timeout_time> is an 2900! optional timeout parameter in seconds. 2910! 2920 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 2930 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 2940 INTEGER Pound_i 2950 Io_error=0 2960 ON ERROR GOTO Hw_io_error 2970 IF NPAR=2 THEN 2980 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 2990 END IF 3000 OUTPUT @Hpib_mod USING "#,K";"WBLK #I" 3010 OUTPUT @Bin_hpib_mod;Block_array(*) 3020 IF 0 THEN 3030 Hw_io_error:! 3040 Io_error=1 3050 END IF 3060 SUBEND 3070 ! 3080 Hw_read_mod_blk:SUB Hw_read_mod_blk(Mf_mod,INTEGER Block_array(*),OPTIONAL Timeout_time) 3090 ! 3100 ! This subprogram is used to read a short integer data block from an 3110 ! input module. This subprogram uses the HP-IB module RDT command. 3120 ! Data is read from the module specified by <mf_mod> and placed in 3130 ! <Block_array(*)>. Data is read until <Block_array(*)> is full. 3140 ! <Timeout_time> is an optional timeout parameter in seconds. 3150 ! 3160 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 3170 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 3180 INTEGER Pound_i 3190 REAL Block_size 3200 Io_error=0 3210 ON ERROR GOTO Hw_io_error 3220 IF NPAR=3 THEN 3230 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 3240 END IF 3250 Block_size=FNLib_sizeof(Block_array(*)) 3260 OUTPUT @Hpib_mod;"RDT ";Mf_mod;",";Block_size 3270 ENTER @Hpib_mod USING "#,W";Pound_i 3280 IF Pound_i<>9033 THEN 3290 Io_error=1 3300 OUTPUT @Hpib_mod;" " 3310 ELSE 3320 ENTER @Bin_hpib_mod;Block_array(*) 3330 END IF 3340 IF 0 THEN 3350 Hw_io_error:! 3360 Io_error=1 3370 END IF 3380 SUBEND 3390 ! 3400 Hw_write_fblk:SUB Hw_write_fblk(Block_id,Block_array(*),OPTIONAL Timeout_time) 3410 ! 3420 ! This function is used to write a floating point data array into a 3430 ! HP-IB module data RAM block. All floating point data in the array 3440 ! <block_array(*)> will be downloaded into the HP-IB module data RAM 3450 ! block specified by <block_id>. <Timeout_time> is an optional 3460 ! timeout parameter in seconds. 3470 ! 3480 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 3490 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 3500 Io_error=0 3510 ON ERROR GOTO Hw_io_error 3520 IF NPAR=3 THEN 3530 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 3540 END IF 3550 Block_size=FNLib_fsizeof(Block_array(*))*4 3560 OUTPUT @Hpib_mod USING "#,K";"WBLD ";Block_id;",";Block_size;",#I" 3570 OUTPUT @Bin_hpib_mod;Block_array(*) 3580 IF 0 THEN 3590 Hw_io_error:! 3600 Io_error=1 3610 END IF 3620 SUBEND 3630 Hw_read_fblk:SUB Hw_read_fblk(Block_id,Block_array(*),OPTIONAL Timeout_time) 3640 ! 3650 ! This subprogram is used to read a floating point data block from a 3660 ! HP-IB module data RAM block. Floating point data will be read 3670 ! from the data RAM block specified by <block_id> until the floating 3680 ! point array <block_array(*)> is full. <Timeout_time> is an 3690 ! optional timeout parameter in seconds. 3700 ! 3710 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 3720 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 3730 INTEGER Pound_i,I 3740 REAL Block_size 3750 Io_error=0 3760 ON ERROR GOTO Hw_io_error 3770 IF NPAR=3 THEN 3780 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 3790 END IF 3800 Block_size=FNLib_fsizeof(Block_array(*))*4 3810 OUTPUT @Hpib_mod;"RBLD ";Block_id;",";Block_size 3820 ENTER @Hpib_mod USING "#,W";Pound_i 3830 IF Pound_i<>9033 THEN 3840 Io_error=1 3850 OUTPUT @Hpib_mod;" " 3860 ELSE 3870 ENTER @Bin_hpib_mod;Block_array(*) 3880 END IF 3890 IF 0 THEN 3900 Hw_io_error:! 3910 Io_error=1 3920 END IF 3930 SUBEND 3940 ! 3950 Hw_enter_fblk:SUB Hw_enter_fblk(Block_array(*),OPTIONAL Timeout_time) 3960! 3970! This subprogram is used to read a floating point data array from a 3980! running ICODE program. See HP-IB module documentation for 3990! information on how ICODE can send data to the host. This 4000! subprogram uses the HP-IB module RBLK HP-IB command. After 4010! sending the RBLK command, data is read from HP-IB and put into the 4020! floating point array <Block_array(*)>. Data is read until 4030! <block_array(*)> is full. <Timeout_time> is an optional timeout 4040! parameter in seconds. 4050! 4060 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 4070 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 4080 INTEGER Pound_i 4090 Io_error=0 4100 ON ERROR GOTO Hw_io_error 4110 IF NPAR=2 THEN 4120 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 4130 END IF 4140 OUTPUT @Hpib_mod;"RBLK" 4150 ENTER @Hpib_mod USING "#,W";Pound_i 4160 IF Pound_i<>9033 THEN 4170 Io_error=1 4180 OUTPUT @Hpib_mod;" " 4190 ELSE 4200 ENTER @Bin_hpib_mod;Block_array(*) 4210 END IF 4220 IF 0 THEN 4230 Hw_io_error:! 4240 Io_error=1 4250 END IF 4260 SUBEND 4270 ! 4280 Hw_output_fblk:SUB Hw_output_fblk(Block_array(*),OPTIONAL Timeout_time) 4290! 4300! This subprogram is used to send a floating point data array to a 4310! running ICODE program. For information on ICODE and how ICODE can 4320! accept a block of data, see HP-IB module documentation. This 4330! subprogram uses the HP-IB module WBLK HP-IB command. After 4340! issuing the WBLK command, the data in the floating point array 4350! <block_array(*)> is sent to HP-IB module. <Timeout_time> is an 4360! optional timeout parameter in seconds. 4370! 4380 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 4390 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 4400 INTEGER Pound_i 4410 Io_error=0 4420 ON ERROR GOTO Hw_io_error 4430 IF NPAR=2 THEN 4440 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 4450 END IF 4460 OUTPUT @Hpib_mod USING "#,K";"WBLK #I" 4470 OUTPUT @Bin_hpib_mod;Block_array(*) 4480 IF 0 THEN 4490 Hw_io_error:! 4500 Io_error=1 4510 END IF 4520 SUBEND 4530 ! 4540 Hw_wait_mod_rdy:SUB Hw_wait_mod_rdy(Mf_mod,OPTIONAL Timeout_time) 4550! 4560! This subprogram is used to hold off execution of the host program 4570! until a specified HP3565S input module or source module is ready. 4580! When the HP3565S module specified by <mf_mod> has its ready bit 4590! asserted, this subprogram will terminate, returning host processor 4600! control to the caller. <Timeout_time> is an optional timeout 4610! parameter in seconds. 4620! 4630 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 4640 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 4650 INTEGER Status,Timeout_active 4660 REAL Start_time 4670 Io_error=0 4680 ON ERROR GOTO Hw_io_error 4690 Timeout_active=0 4700 IF NPAR=2 THEN 4710 IF Timeout_time>0 THEN Timeout_active=1 4720 END IF 4730 IF Timeout_active THEN 4740 ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 4750 Start_time=TIMEDATE 4760 REPEAT 4770 OUTPUT @Hpib_mod;"RMST ";Mf_mod 4780 ENTER @Hpib_mod;Status 4790 IF BIT(Status,4) THEN SUBEXIT 4800 UNTIL ABS(TIMEDATE-Start_time)>Timeout_time 4810 ELSE 4820 REPEAT 4830 OUTPUT @Hpib_mod;"RMST ";Mf_mod 4840 ENTER @Hpib_mod;Status 4850 IF BIT(Status,4) THEN SUBEXIT 4860 UNTIL 1=0 4870 SUBEXIT 4880 END IF 4890 Hw_io_error:Io_error=1 4900 SUBEND 4910 ! 4920 Hw_wait_gbl_rdy:SUB Hw_wait_gbl_rdy(OPTIONAL Timeout_time) 4930! 4940! This subprogram is used to hold off execution of the host program 4950! until all HP3565S input modules and source modules are ready. 4960! When all HP3565S modules (except the HP-IB module) have asserted 4970! their ready bits, this subprogram will terminate, returning host 4980! processor control to the caller. This subprogram uses the HP-IB 4990! module RGSS command. <Timeout_time> is an optional timeout 5000! parameter in seconds. 5010! 5020 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 5030 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 5040 INTEGER Status,Timeout_active 5050 REAL Start_time 5060 Io_error=0 5070 ON ERROR GOTO Hw_io_error 5080 Timeout_active=0 5090 IF NPAR=1 THEN 5100 IF Timeout_time>0 THEN Timeout_active=1 5110 END IF 5120 IF Timeout_active THEN 5130 ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 5140 Start_time=TIMEDATE 5150 REPEAT 5160 OUTPUT @Hpib_mod;"RGSS" 5170 ENTER @Hpib_mod;Status 5180 IF BIT(Status,4) THEN SUBEXIT 5190 UNTIL ABS(TIMEDATE-Start_time)>Timeout_time 5200 ELSE 5210 REPEAT 5220 OUTPUT @Hpib_mod;"RGSS" 5230 ENTER @Hpib_mod;Status 5240 IF BIT(Status,4) THEN SUBEXIT 5250 UNTIL 1=0 5260 END IF 5270 Hw_io_error:Io_error=1 5280 SUBEND 5290 ! 5300 Hw_mod_rst:SUB Hw_mod_rst(Mf_mod,OPTIONAL Timeout_time) 5310! 5320! This subprogram is used to reset an input module or an source 5330! module. The module to reset is specified by <mf_mod>. The module 5340! is reset through the use of the HP-IB module RST n command. 5350! <Timeout_time> is an optional timeout parameter in seconds. 5360 ! 5370 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 5380 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 5390 Io_error=0 5400 ON ERROR GOTO Hw_io_error 5410 IF NPAR=2 THEN 5420 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 5430 END IF 5440 OUTPUT @Hpib_mod;"RST ";Mf_mod 5450 IF 0 THEN 5460 Hw_io_error:Io_error=1 5470 END IF 5480 SUBEND 5490 ! 5500 Hw_gbl_mod_rst:SUB Hw_gbl_mod_rst(OPTIONAL Timeout_time) 5510 ! 5520 ! This subprogram is used to reset all modules on the fast bus (not 5530 ! the HP-IB module). This is equivalent to a power on state for the 5540 ! modules reset. <Timeout_time> is an optional timeout parameter in 5550 ! seconds. 5560 ! 5570 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 5580 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 5590 Io_error=0 5600 ON ERROR GOTO Hw_io_error 5610 IF NPAR=1 THEN 5620 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 5630 END IF 5640 OUTPUT @Hpib_mod;"RCF;TCF" ! this resets all inpt/srce modules 5650 IF 0 THEN 5660 Hw_io_error:Io_error=1 5670 END IF 5680 SUBEND 5690 ! 5700 Hw_rmst:DEF FNHw_rmst(Mf_mod,OPTIONAL Timeout_time) 5710! 5720! This function is used to get the module status register of the 5730! specified input module or source module. The module is specified 5740! by <mf_mod>. The value of the specified module's status register 5750! is returned to the caller in the function result. This function 5760! makes use of the HP-IB module RMST command. <Timeout_time> is an 5770! optional timeout parameter in seconds. 5780! 5790 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 5800 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 5810 Io_error=0 5820 ON ERROR GOTO Hw_io_error 5830 IF NPAR=2 THEN 5840 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 5850 END IF 5860 OUTPUT @Hpib_mod;"RMST ";Mf_mod 5870 ENTER @Hpib_mod;Temp 5880 IF 0 THEN 5890 Hw_io_error:! 5900 Io_error=1 5910 Temp=0 5920 END IF 5930 RETURN Temp 5940 FNEND 5950 ! 5960 Hw_gbl_rmst:DEF FNHw_gbl_rmst(OPTIONAL Timeout_time) 5970 ! 5980 ! This function is used to read the global fast bus module status 5990 ! register. For information on the global fast bus module status 6000 ! register, see RGSS in HP-IB module documentation. The global fast 6010 ! bus module status register is returned to the caller as the 6020 ! function result. <Timeout_time> is an optional timeout parameter 6030 ! in seconds. 6040 ! 6050 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 6060 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 6070 Io_error=0 6080 ON ERROR GOTO Hw_io_error 6090 IF NPAR=1 THEN 6100 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 6110 END IF 6120 OUTPUT @Hpib_mod;"RGSS" 6130 ENTER @Hpib_mod;Temp 6140 IF 0 THEN 6150 Hw_io_error:! 6160 Io_error=1 6170 Temp=0 6180 END IF 6190 RETURN Temp 6200 FNEND 6210 ! 6220 Hw_sel_abort:SUB Hw_sel_abort 6230! 6240! This function is used to cease activity on the HP-IB interface. 6250! If the host is not currently the active HP-IB controller, then it 6260! (the host) will assume active control. This is equivalent to the 6270! BASIC ABORT command. 6280! 6290 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 6300 Io_error=0 6310 ON ERROR GOTO Hw_io_error 6320 ABORT Sel_code 6330 IF 0 THEN 6340 Hw_io_error:Io_error=1 6350 END IF 6360 SUBEND 6370 ! 6380 Hw_wait_srq:SUB Hw_wait_srq(OPTIONAL Timeout_time) 6390! 6400! This subprogram is used to hold off execution of the host program 6410! until the HP-IB SRQ line is asserted. When the HP-IB SRQ line is 6420! asserted, this subprogram will terminate, returning host processor 6430! control to the caller. <Timeout_time> is an optional timeout 6440! parameter in seconds. 6450! 6460 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 6470 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 6480 INTEGER Status,Timeout_active 6490 REAL Start_time 6500 ON ERROR GOTO Hw_io_error 6510 Timeout_active=0 6520 IF NPAR=1 THEN 6530 IF Timeout_time>0 THEN Timeout_active=1 6540 END IF 6550 IF Timeout_active THEN 6560 Start_time=TIMEDATE 6570 REPEAT 6580 STATUS Sel_code,7;Status 6590 IF BIT(Status,10) THEN SUBEXIT 6600 UNTIL ABS(TIMEDATE-Start_time)>Timeout_time 6610 ELSE 6620 REPEAT 6630 STATUS Sel_code,7;Status 6640 IF BIT(Status,10) THEN SUBEXIT 6650 UNTIL 1=0 6660 END IF 6670 Hw_io_error:Io_error=1 6680 SUBEND 6690 ! 6700 Hw_wait_cntrlr:SUB Hw_wait_cntrlr(OPTIONAL Timeout_time) 6710! 6720! This subprogram is used to hold off execution of the host program 6730! until the host becomes the active HP-IB bus controller. When the 6740! host becomes the active controller of the HP-IB bus, this 6750! subprogram will terminate, returning host processor control to the 6760! caller. <Timeout_time> is an optional timeout parameter in 6770! seconds. 6780! 6790 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 6800 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 6810 INTEGER Status,Timeout_active 6820 REAL Start_time 6830 Io_error=0 6840 ON ERROR GOTO Hw_io_error 6850 Timeout_active=0 6860 IF NPAR=1 THEN 6870 IF Timeout_time>0 THEN Timeout_active=1 6880 END IF 6890 IF Timeout_active THEN 6900 Start_time=TIMEDATE 6910 REPEAT 6920 STATUS Sel_code,6;Status 6930 IF BIT(Status,6) THEN SUBEXIT 6940 UNTIL ABS(TIMEDATE-Start_time)>Timeout_time 6950 ELSE 6960 REPEAT 6970 STATUS Sel_code,6;Status 6980 IF BIT(Status,6) THEN SUBEXIT 6990 UNTIL 1=0 7000 END IF 7010 Hw_io_error:Io_error=1 7020 SUBEND 7030 ! 7040 Hw_io_error:DEF FNHw_io_error 7050 ! 7060 ! This function is used to see if an error occurred during the last 7070 ! activation of a hardware interface subprogram. A timeout is 7080 ! considered an error. Returned as the function result is a boolean 7090 ! with a value of true if an error or timeout did occur. 7100 ! 7110 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 7120 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 7130 INTEGER Temp 7140 Temp=Io_error 7150 Io_error=0 7160 RETURN Temp 7170 FNEND 7180 ! 7190 Hw_srq:DEF FNHw_srq 7200 ! 7210 ! This function is used to see if the HP-IB SRQ line is currently 7220 ! being asserted. Returned in the function result is a boolean 7230 ! value of true if the HP-IB SRQ line is currently being asserted. 7240 ! 7250 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 7260 INTEGER Status 7270 Io_error=0 7280 ON ERROR GOTO Hw_io_error 7290 STATUS Sel_code,7;Status 7300 IF 0 THEN 7310 Hw_io_error:! 7320 Io_error=1 7330 Status=0 7340 END IF 7350 RETURN BIT(Status,10) 7360 FNEND 7370 ! 7380 Hw_cntrlr:DEF FNHw_cntrlr 7390 ! 7400 ! This function is used to see if the host is currently the active 7410 ! controller of the HP-IB bus. Returned in the function result is a 7420 ! boolean with a value of true if the host is currently the active 7430 ! controller of the HP-IB bus. Otherwise, false is returned. 7440 ! 7450 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 7460 INTEGER Status 7470 Io_error=0 7480 ON ERROR GOTO Hw_io_error 7490 STATUS Sel_code,6;Status 7500 IF 0 THEN 7510 Hw_io_error:! 7520 Io_error=1 7530 Status=0 7540 END IF 7550 RETURN BIT(Status,6) 7560 FNEND 7570 ! 7580 Hw_pass_cntrlr:SUB Hw_pass_cntrlr(OPTIONAL Timeout_time) 7590 ! 7600 ! The subprogram is used to pass control of the HP-IB bus to the 7610 ! HP-IB module. What else can I say? 7620 ! 7630 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 7640 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 7650 Io_error=0 7660 ON ERROR GOTO Hw_io_error 7670 IF NPAR=1 THEN 7680 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 7690 END IF 7700 PASS CONTROL @Hpib_mod 7710 IF 0 THEN 7720 Hw_io_error:Io_error=1 7730 END IF 7740 SUBEND 7750 ! 7760 Hw_host_addr:DEF FNHw_host_addr 7770 ! 7780 ! This function is used to get the host HP-IB device address. The 7790 ! host HP-IB device address is returned in the function result. 7800 ! 7810 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 7820 INTEGER Host_addr 7830 Io_error=0 7840 ON ERROR GOTO Hw_io_error 7850 STATUS Sel_code,3;Host_addr 7860 IF 0 THEN 7870 Hw_io_error:! 7880 Io_error=1 7890 Host_addr=0 7900 END IF 7910 RETURN Host_addr MOD 32 7920 FNEND 7930 ! 7940 Hw_dev_clear:SUB Hw_dev_clear(OPTIONAL Timeout_time) 7950! 7960! This subprogram is used to send a device clear to the HP-IB 7970! module. A device clear will abort a running ICODE program and set 7980! the HP-IB module HP-IB interface to a reset state. Note that this 7990! does not dispose any HP-IB module memory blocks. 8000! 8010 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 8020 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 8030 ON ERROR GOTO Hw_io_error 8040 IF NPAR=1 THEN 8050 IF Timeout_time THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 8060 END IF 8070 Io_error=0 8080 CLEAR @Hpib_mod 8090 IF 0 THEN 8100 Hw_io_error:Io_error=1 8110 END IF 8120 SUBEND 8130 ! 8140 Hw_get_dev_sels:SUB Hw_get_dev_sels(INTEGER Dev_sel_list(*),INTEGER Cant_check_list(*)) 8150! 8160! This subprogram is used to find out the device select code of 8170! every HP3565S hardware system currently connected to the host. 8180! All selector slots (7 through 31) are checked for HP-IB cards. 8190! All selector slots that are found to have HP-IB cards are searched 8200! for HP3565S hardware. To search a selector slot for HP3565S 8210! hardware, all HP-IB device address (0 through 31 except host 8220! address) are sent ID?. If the device responds with 'HP35651A', 8230! then the device selector address is noted in <dev_sel_list(*)>. 8240! The list of HP3565S hardware device selector addresses is returned 8250! to the host in <dev_sel_list(*)>. Note that a device selector 8260! address of 934 can be broken down into a selector of 9 and a 8270! device address of 34. See BASIC manual for more information of 8280! device selectors. <Cant_check_list(*)> contains information about 8290! entire selectors and device selector addresses that could not be 8300! checked. If a HP-IB card is not an active controller, then the 8310! device addresses on that selector bus can not be checked. The 8320! selector number (7 through 31) of any non-active HP-IB controller 8330! is entered into <cant_check_list>. For every HP-IB card found, 8340! there is one device address that can not be checked. That is the 8350! address of the host on that bus. For every active controller 8360! HP-IB card in the host, the device selector address of the host is 8370! placed in <cant_check_list(*)> (700->731,800->831,...,3100->3131). 8380! Both <dev_sel_list(*)> and <cant_check_list(*)> are REDIMed to the 8390! number of elements placed in each respective list. If either 8400! array is not large enough to hold the entire list, then entries 8410! are made until the lists are full and an error is logged. If no 8420! HP3565S hardware system is found, then <dev_sel_list(*)> is 8430! REDIMed to one element containing one zero and an error is logged. 8440! 8450 COM /Hw_com2/ INTEGER Io_error,INTEGER Dummy1,INTEGER Dummy2 8460 INTEGER Dev_sel_size,Dev_sel_last,Cant_check_size,Cant_check_last 8470 INTEGER Sel_code,Sel_status,Hpib_addr,Host_hpib_addr,Dev_sel_code 8480 DIM Id_response$[255] 8490 ! 8500 Print_hpib_addr=1 8510 ! 8520 Io_error=0 8530 MAT Dev_sel_list= (0) 8540 Dev_sel_size=SIZE(Dev_sel_list,1) 8550 Dev_sel_last=0 8560 MAT Dev_sel_list= (0) 8570 Cant_check_size=SIZE(Cant_check_list,1) 8580 Cant_check_last=0 8590 ! 8600 FOR Sel_code=7 TO 31 8610 ON ERROR GOTO Hw_no_sel_code 8620 STATUS Sel_code,0;Sel_status 8630 IF 0 THEN 8640 Hw_no_sel_code:Sel_status=-1 8650 END IF 8660 IF Sel_status=1 THEN 8670 STATUS Sel_code,3;Sel_status 8680 IF NOT BIT(Sel_status,6) THEN !hp-ib card isn't active controller 8690 Cant_check_last=Cant_check_last+1 8700 IF Cant_check_last<=Cant_check_size THEN 8710 Cant_check_list(Cant_check_last)=Sel_code 8720 ELSE 8730 Io_error=1 8740 END IF 8750 ELSE !hp-ib card is active controller 8760 Host_hpib_addr=Sel_status MOD 32 !check all addrs except host addr 8770 FOR Hpib_addr=0 TO 31 8780 Dev_sel_code=(Sel_code*100)+Hpib_addr 8790 IF Hpib_addr=Host_hpib_addr OR Hpib_addr=Print_hpib_addr THEN 8800 Cant_check_last=Cant_check_last+1 8810 IF Cant_check_last<=Cant_check_size THEN 8820 Cant_check_list(Cant_check_last)=Dev_sel_code 8830 ELSE 8840 Io_error=1 8850 END IF 8860 ELSE 8870 ON TIMEOUT Sel_code,.1 GOTO Hw_no_response 8880 ON ERROR GOTO Hw_no_response 8890 CLEAR Dev_sel_code 8900 OUTPUT Dev_sel_code;" " 8910 OUTPUT Dev_sel_code;"ID?" 8920 ENTER Dev_sel_code;Id_response$ 8930 IF 0 THEN 8940 Hw_no_response:Id_response$="" 8950 END IF 8960 OFF TIMEOUT Sel_code 8970 OFF ERROR 8980 IF POS(Id_response$,"HP35651A") THEN 8990 Dev_sel_last=Dev_sel_last+1 9000 IF Dev_sel_last<=Dev_sel_size THEN 9010 Dev_sel_list(Dev_sel_last)=Dev_sel_code 9020 ELSE 9030 Io_error=1 9040 END IF 9050 END IF ! found Interface Module 9060 END IF 9070 NEXT Hpib_addr 9080 END IF ! host is active controller 9090 END IF ! hp-ib card present 9100 NEXT Sel_code 9110 ! 9120 REDIM Dev_sel_list(1:MIN(Dev_sel_size,MAX(Dev_sel_last,1))) 9130 REDIM Cant_check_list(1:MIN(Cant_check_size,MAX(Cant_check_last,1))) 9140 IF Dev_sel_list(1)=0 THEN Io_error=1 9150 ! 9160 SUBEND 9170 ! 9180 Hw_set_dev_sel:SUB Hw_set_dev_sel(INTEGER Dev_sel_code) 9190! 9200! This subprogram is used to set the current device select code for 9210! the HP3565S hardware. The current device select code will be set 9220! to <dev_sel_code>. Until this subprogram is used to set the 9230! current device select code, no other hardware interface subprogram 9240! may be used. The three exceptions to this are Hw_get_dev_sels, 9250! Hw_hw, and Hw_io_error. Once the current device select code is 9260! set, no other HP3565S demo program files need worry about device 9270! select codes, I/O addresses, or other such nasty things. Note 9280! that this subprogram should be used the CNFG file ONLY. 9290! 9300 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 9310 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 9320 Io_error=0 9330 ON ERROR GOTO Hw_bad_ds_code 9340 Sel_code=Dev_sel_code DIV 100 9350 Hpib_addr=Dev_sel_code MOD 100 9360 ASSIGN @Hpib_mod TO Dev_sel_code 9370 ASSIGN @Bin_hpib_mod TO Dev_sel_code;FORMAT OFF 9380 IF 0 THEN 9390 Hw_bad_ds_code:Io_error=1 9400 END IF 9410 SUBEND 9420 ! 9430 Hw_cur_dev_sel:DEF FNHw_cur_dev_sel 9440! 9450! This function is used to get the current device select code. The 9460! current device select code is returned as the function result. 9470! Note that the device select code is set by the configuration 9480! (CNFG) file. 9490! 9500 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 9510 Io_error=0 9520 RETURN Sel_code*100+Hpib_addr 9530 FNEND 9540 ! 9550 Hw_stat_2_str:DEF FNHw_stat_2_str$(Stat) 9560 ! 9570 ! This function is used to convert a HP-IB module status register 9580 ! value into a string containing a three letter mnemonic code for 9590 ! each active status bit. The mnemonic codes in the string will be 9600 ! separated by '|'. The mnemonic codes are as follows: 9610 ! 9620 ! Bit Value Bit Pos Mnemonic Definition 9630 ! --------- ------- -------- --------------------------------- 9640 ! 1= bit 0 RQC| Request Control of HP-IB bus. 9650 ! 2= bit 1 - - - - - not used - - - - - 9660 ! 4= bit 2 UPP| ICODE program paused. 9670 ! 8= bit 3 PRG| ICODE program complete. 9680 ! 16= bit 4 RDY| Ready for anything. 9690 ! 32= bit 5 ERR| Error condition exists. 9700 ! 64= bit 6 RQS| Service Request. 9710 ! 128= bit 7 MSG| A message is ready for the host. 9720 ! 256= bit 8 FRQ| Fast bus SRQ signal line. 9730 ! 512= bit 9 IRQ| Fast bus IRQ signal line. 9740 ! 1024= bit10 SHT| Fast bus SHUTDOWN signal line. 9750 ! 2048= bit11 TRG| Fast bus TRG signal line. 9760 ! 4096= bit12 - - - - - not used - - - - - 9770 ! 8091= bit13 - - - - - not used - - - - - 9780 ! 16384= bit14 PON| Power on. 9790 ! 9800 ! The string is returned to the caller in the function result string. 9810 ! For example, FNHw_stat_2_str$(2184) would return "PRG|MSG|TRG". 9820 ! 9830 DIM A$[255] 9840 A$="" 9850 IF BIT(Stat,0) THEN 9860 A$=A$&"RQC|" 9870 END IF 9880 IF BIT(Stat,2) THEN 9890 A$=A$&"UPP|" 9900 END IF 9910 IF BIT(Stat,3) THEN 9920 A$=A$&"PRG|" 9930 END IF 9940 IF BIT(Stat,4) THEN 9950 A$=A$&"RDY|" 9960 END IF 9970 IF BIT(Stat,5) THEN 9980 A$=A$&"ERR|" 9990 END IF 10000 IF BIT(Stat,6) THEN 10010 A$=A$&"RQS|" 10020 END IF 10030 IF BIT(Stat,7) THEN 10040 A$=A$&"MSG|" 10050 END IF 10060 IF BIT(Stat,8) THEN 10070 A$=A$&"FRQ|" 10080 END IF 10090 IF BIT(Stat,9) THEN 10100 A$=A$&"IRQ|" 10110 END IF 10120 IF BIT(Stat,10) THEN 10130 A$=A$&"SHT|" 10140 END IF 10150 IF BIT(Stat,11) THEN 10160 A$=A$&"TRG|" 10170 END IF 10180 IF BIT(Stat,14) THEN 10190 A$=A$&"PON|" 10200 END IF 10210 IF A$="" THEN RETURN "" 10220 RETURN TRIM$(A$[1,LEN(A$)-1]) 10230 FNEND 10240 ! 10250 Hw_mainmem_aval:DEF FNHw_mainmem_aval(OPTIONAL Timeout_time) 10260! 10270! This function is used to get the total amount (in words) of HP-IB 10280! module main data RAM that has not been allocated. The amount will 10290! be returned in the function result. Note that the value returned 10300! by this function is not necessarily the size of the largest block. 10310! <Timeout_time> is an optional timeout parameter in seconds. 10320! 10330 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 10340 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 10350 REAL Mem_available,Dummy 10360 Io_error=0 10370 ON ERROR GOTO Hw_io_error 10380 IF NPAR=1 THEN 10390 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 10400 END IF 10410 ! 10420 OUTPUT @Hpib_mod;"MEM?" 10430 ENTER @Hpib_mod;Mem_available,Dummy,Dummy,Dummy 10440 IF 0 THEN 10450 Hw_io_error:! 10460 Io_error=1 10470 Mem_available=0 10480 END IF 10490 RETURN Mem_available 10500 FNEND 10510 ! 10520 Hw_mainblk_aval:DEF FNHw_mainblk_aval(OPTIONAL Timeout_time) 10530! 10540! The function is used to get the size (in words) of the largest 10550! HP-IB module main data RAM block. This value will be returned as 10560! the function result. <Timeout_time> is an optional timeout 10570! parameter in seconds. 10580! 10590 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 10600 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 10610 REAL Mem_available,Dummy 10620 Io_error=0 10630 ON ERROR GOTO Hw_io_error 10640 IF NPAR=1 THEN 10650 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 10660 END IF 10670 OUTPUT @Hpib_mod;"MEM?" 10680 ENTER @Hpib_mod;Dummy,Mem_available,Dummy,Dummy 10690 IF 0 THEN 10700 Hw_io_error:! 10710 Io_error=1 10720 Mem_available=0 10730 END IF 10740 RETURN Mem_available 10750 FNEND 10760 ! 10770 Hw_spmem_aval:DEF FNHw_spmem_aval(OPTIONAL Timeout_time) 10780! 10790! This function is used to get the total amount (in words) of HP-IB 10800! module SP data RAM that has not been allocated. The amount will 10810! be returned in the function result. Note that the value returned 10820! by this function is not necessarily the size of the largest block. 10830! <Timeout_time> is an optional timeout parameter in seconds. 10840! 10850 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 10860 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 10870 REAL Mem_available,Dummy 10880 Io_error=0 10890 ON ERROR GOTO Hw_io_error 10900 IF NPAR=1 THEN 10910 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 10920 END IF 10930 OUTPUT @Hpib_mod;"MEM?" 10940 ENTER @Hpib_mod;Dummy,Dummy,Mem_available,Dummy 10950 IF 0 THEN 10960 Hw_io_error:! 10970 Io_error=1 10980 Mem_available=0 10990 END IF 11000 RETURN Mem_available 11010 FNEND 11020 ! 11030 Hw_spblk_aval:DEF FNHw_spblk_aval(OPTIONAL Timeout_time) 11040! 11050! The function is used to get the size (in words) if the largest 11060! HP-IB module SP data RAM block. This value will be returned as 11070! the function result. <Timeout_time> is an optional timeout 11080! parameter in seconds. 11090! 11100 COM /Hw_com1/ @Hpib_mod,@Bin_hpib_mod 11110 COM /Hw_com2/ INTEGER Io_error,INTEGER Sel_code,INTEGER Hpib_addr 11120 REAL Mem_available,Dummy 11130 Io_error=0 11140 ON ERROR GOTO Hw_io_error 11150 IF NPAR=1 THEN 11160 IF Timeout_time>0 THEN ON TIMEOUT Sel_code,Timeout_time GOTO Hw_io_error 11170 END IF 11180 OUTPUT @Hpib_mod;"MEM?" 11190 ENTER @Hpib_mod;Dummy,Dummy,Dummy,Mem_available 11200 IF 0 THEN 11210 Hw_io_error:Io_error=1 11220 Mem_available=0 11230 END IF 11240 RETURN Mem_available 11250 FNEND 11260 ! 11270 Hw_get_errstr:DEF FNHw_get_errstr$(Error_num) 11280! 11290! This function is used to convert an HP-IB module error number into 11300! the appropriate error message string. The error number (or error 11310! code) is passed to this function in <Error_num>. The appropriate 11320! error message string is returned to the caller in the function 11330! result string. If an invalid error number is passed in to this 11340! function, then VAL$(Error_num) is returned to the caller. 11350! 11360 DIM Msg$[100] 11370 INTEGER Current_err 11380 ON ERROR GOTO Hw_not_found 11390 REPEAT 11400 READ Current_err,Msg$ 11410 UNTIL Current_err=Error_num 11420 OFF ERROR 11430 RETURN Msg$ 11440 STOP 11450 Hw_not_found:OFF ERROR 11460 RETURN VAL$(Error_num) 11470 STOP 11480 DATA -100,"Command error (unknown command)" 11490 DATA -101,"Invalid character received" 11500 DATA -110,"Command Header error" 11510 DATA -111,"Header delimiter error" 11520 DATA -120,"Numeric argument error" 11530 DATA -121,"Wrong Data Type (numeric expected)" 11540 DATA -122,"Precision error; rounding occurred" 11550 DATA -123,"Numeric overflow" 11560 DATA -129,"Missing numeric argument" 11570 DATA -130,"non numeric argument error (char, string or block)" 11580 DATA -131,"Wrong Data Type (char expected)" 11590 DATA -132,"Wrong Data Type (string expected)" 11600 DATA -133,"Wrong Data Type (block type #A required)" 11610 DATA -134,"Data Overflow: string or block too long" 11620 DATA -139,"Missing non numeric argument" 11630 DATA -141,"Command Buffer Overflow" 11640 DATA -142,"Too many arguments" 11650 DATA -143,"Argument delimiter error" 11660 DATA -144,"Invalid message unit delimiter" 11670 DATA -200,"No Can Do (generic execution error)" 11680 DATA -201,"Not executable in local mode" 11690 DATA -202,"Settings lost due to rtl or pon " 11700 DATA -203,"Trigger ignored" 11710 DATA -211,"Legal command, but settings conflict" 11720 DATA -212,"Argument out of range" 11730 DATA -221,"Busy doing something else" 11740 DATA -222,"Insufficient capability or configuration" 11750 DATA -231,"Input buffer full or overflow" 11760 DATA -232,"Output buffer full or overflow" 11770 DATA -1,"unexpected interrupt" 11780 DATA -2,"stack overflow" 11790 DATA -3,"reference to NIL pointer" 11800 DATA -4,"integer overflow" 11810 DATA -5,"divide by zero" 11820 DATA -6,"real math overflow" 11830 DATA -7,"real math underflow" 11840 DATA -8,"value range error" 11850 DATA -9,"case value range error" 11860 DATA -10,"Bad input format or String subscript out of range" 11870 DATA -11,"CPU word access to odd address" 11880 DATA -12,"CPU bus error" 11890 DATA -13,"illegal CPU instruction" 11900 DATA -14,"CPU privilege violation" 11910 DATA -15,"bad argument SIN/COS" 11920 DATA -16,"bad argument LN" 11930 DATA -17,"bad argument SQRT" 11940 DATA -18,"bad argument real/BCD conversion" 11950 DATA -19,"bad argument BCD/real conversion" 11960 DATA -20,"stopped by user" 11970 DATA -21,"unassigned CPU trap" 11980 DATA -25,"undefined macro parameter" 11990 DATA -26,"I/O routine error" 12000 DATA -28,"CPU trace exception" 12010 DATA 101,"unable to allocate block. ( see NEW and SNEW )" 12020 DATA 102,"Undefined blockid." 12030 DATA 103,"Block will not hold all the data." 12040 DATA 104,"Output string buffer overflow." 12050 DATA 105,"Output request buffer overflow." 12060 DATA 200,"FP-IB bus is reset, unable to take control. (see TCF)" 12070 DATA 201,"Other FP-IB controller present. (see TCF)" 12080 DATA 202,"FP-IB read transfer timeout." 12090 DATA 203,"FP-IB write transfer timeout." 12100 DATA 204,"FP-IB read overflow." 12110 DATA 205,"Interface FP-IB address used." 12120 DATA 206,"Interface module not in control of FP-IB." 12130 DATA 207,"I/O aborted because the FP-IB module is not responding." 12140 DATA 208,"SYNC timeout error." 12150 DATA 209,"FP-IB went into an unexpected reset state." 12160 DATA 210,"Trigger sequence timeout error.(Someone is asserting trig line)" 12170 DATA 300,"An ICODE program is not running." 12180 DATA 301,"An ICODE program cannot be continued because it is not paused." 12190 DATA 302,"Command cannot be completed because an ICODE program is active." 12200 DATA 303,"Attempt to fetch past the end of an ICODE block has occurred." 12210 DATA 304,"Non-existent icode variable fetch." 12220 DATA 305,"Illegal blockid use." 12230 DATA 306,"ICODE value range error." 12240 DATA 307,"Block offset too large for block." 12250 DATA 308,"Branch out of bounds." 12260 DATA 309,"Access past block boundaries." 12270 DATA 310,"Subroutines nested more than 16." 12280 DATA 311,"An RTS instruction has been executed without an active sub." 12290 DATA 312,"f_thruput executed before a f_ready_ram or f_ready_disc." 12300 DATA 313,"Illegal block size" 12310 DATA 314,"Block exponent offset is out of header block." 12320 DATA 315,"Block exponent overflow." 12330 DATA 316,"Block exponent underflow." 12340 DATA 317,"No header block allocated for block exponent." 12350 DATA 318,"Requested window size is odd." 12360 DATA 319,"Illegal relationship between f_sample args." 12370 DATA 320,"Illegal opcode." 12380 DATA 321,"Work block not declared." 12390 DATA 322,"Work block is too small." 12400 DATA 323,"Fast average exponent out of range." 12410 DATA 324,"Missing mf_mod from f_ready_ram/f_ready_disc mf_mod list." 12420 DATA 325,"f_ready_ram/f_ready_disc mf_mod list block too small." 12430 DATA 326,"f_ready_disc disc segment block too small." 12440 DATA 327,"disc address not on block boundary." 12450 DATA 328,"f_keep_ready_ram with out f_ready_ram." 12460 DATA 401,"HP-IB deadlock." 12470 DATA 402,"The interface module is not in control of the HP-IB." 12480 DATA 403,"The interface module is not addressed to listen." 12490 DATA 404,"The interface module is not addressed to talk." 12500 DATA 405,"HP-IB timeout." 12510 DATA 406,"Disc Error reported." 12520 DATA 407,"Disc reports no device present." 12530 DATA 408,"Disc blocksize too large ( > 1024 )" 12540 DATA 409,"Disc reports bad mode." 12550 DATA 410,"Disc reports no such block." 12560 DATA 411,"The disc is uninitialized." 12570 DATA 412,"Disc initialization failed." 12580 DATA 413,"The disc is not ready." 12590 DATA 414,"The disc is write protected." 12600 DATA 415,"Disc reports no such block." 12610 DATA 416,"Disc reported a bad block." 12620 DATA 417,"The disc medium was changed during transfer." 12630 DATA 418,"A icode transfer of this type has not been set up. (RBLK,WBLK)" 12640 DATA 419,"HP-IB transfer not completed. (Usually to the host)" 12650 DATA 420,"Disc message length error." 12660 DATA 500,"undefined, reserved" 12670 DATA 501,"unexpected interrupt during power on tests" 12680 DATA 502,"interrupt test generation failure" 12690 DATA 503,"tms320 failure" 12700 DATA 504,"timer failure" 12710 DATA 505,"dma_failure" 12720 DATA 506,"fpib failure" 12730 DATA 507,"hpib failure" 12740 DATA 508,"undefined, reserved" 12750 DATA 509,"high byte rom checksum error" 12760 DATA 510,"low byte rom checksum error" 12770 DATA 511,"signal processor program ram failure" 12780 DATA 512,"signal processor data ram failure" 12790 DATA 513,"ram refresh failure" 12800 DATA 514,"ram error (non refresh error)" 12810 DATA 515,"not enough ram" 12820 DATA 523,"io dtack failure ( ie leds )" 12830 DATA 524,"timer chip dtack failure" 12840 DATA 525,"dma dtack failure" 12850 DATA 526,"fpib dtack failure" 12860 DATA 527,"hpib dtack failure" 12870 DATA 528,"sp program ram dtack failure" 12880 DATA 529,"sp data ram dtack failure" 12890 DATA 530,"main ram dtack failure" 12900 DATA 540,"main ram test failure" 12910 DATA 541,"fpib test failure" 12920 DATA 542,"sp ram failure" 12930 DATA 543,"sp random number generator failure" 12940 DATA 544,"sp USM chip failure" 12950 DATA 545,"novram checksum error" 12960 DATA 546,"sp not responding" 12970 DATA 547,"sp interrupt routine not responding" 12980 DATA 548,"dma chip is inactive" 12990 DATA 549,"bus error during dma operation" 13000 DATA 550,"generic sp failure." 13010 DATA 600,"bit 0 of main ram bad." 13020 DATA 601,"bit 1 of main ram bad." 13030 DATA 602,"bit 2 of main ram bad." 13040 DATA 603,"bit 3 of main ram bad." 13050 DATA 604,"bit 4 of main ram bad." 13060 DATA 605,"bit 5 of main ram bad." 13070 DATA 606,"bit 6 of main ram bad." 13080 DATA 607,"bit 7 of main ram bad." 13090 DATA 608,"bit 8 of main ram bad." 13100 DATA 609,"bit 9 of main ram bad." 13110 DATA 610,"bit 10 of main ram bad." 13120 DATA 611,"bit 11 of main ram bad." 13130 DATA 612,"bit 12 of main ram bad." 13140 DATA 613,"bit 13 of main ram bad." 13150 DATA 614,"bit 14 of main ram bad." 13160 DATA 615,"bit 15 of main ram bad." 13170 DATA 700,"bit 0 of signal processor data ram bad." 13180 DATA 701,"bit 1 of signal processor data ram bad." 13190 DATA 702,"bit 2 of signal processor data ram bad." 13200 DATA 703,"bit 3 of signal processor data ram bad." 13210 DATA 704,"bit 4 of signal processor data ram bad." 13220 DATA 705,"bit 5 of signal processor data ram bad." 13230 DATA 706,"bit 6 of signal processor data ram bad." 13240 DATA 707,"bit 7 of signal processor data ram bad." 13250 DATA 708,"bit 8 of signal processor data ram bad." 13260 DATA 709,"bit 9 of signal processor data ram bad." 13270 DATA 710,"bit 10 of signal processor data ram bad." 13280 DATA 711,"bit 11 of signal processor data ram bad." 13290 DATA 712,"bit 12 of signal processor data ram bad." 13300 DATA 713,"bit 13 of signal processor data ram bad." 13310 DATA 714,"bit 14 of signal processor data ram bad." 13320 DATA 715,"bit 15 of signal processor data ram bad." 13330 DATA 800,"bit 0 of signal processor prog ram bad." 13340 DATA 801,"bit 1 of signal processor prog ram bad." 13350 DATA 802,"bit 2 of signal processor prog ram bad." 13360 DATA 803,"bit 3 of signal processor prog ram bad." 13370 DATA 804,"bit 4 of signal processor prog ram bad." 13380 DATA 805,"bit 5 of signal processor prog ram bad." 13390 DATA 806,"bit 6 of signal processor prog ram bad." 13400 DATA 807,"bit 7 of signal processor prog ram bad." 13410 DATA 808,"bit 8 of signal processor prog ram bad." 13420 DATA 809,"bit 9 of signal processor prog ram bad." 13430 DATA 810,"bit 10 of signal processor prog ram bad." 13440 DATA 811,"bit 11 of signal processor prog ram bad." 13450 DATA 812,"bit 12 of signal processor prog ram bad." 13460 DATA 813,"bit 13 of signal processor prog ram bad." 13470 DATA 814,"bit 14 of signal processor prog ram bad." 13480 DATA 815,"bit 15 of signal processor prog ram bad." 13490 FNEND 13500 ! 13510 ! PAGE -> 13520 !*************************************************************** 13530 Hw_str_2_stat:DEF FNHw_str_2_stat(A$) 13540! 13550! This function is used to convert a string with HP-IB module status 13560! bit mnemonic codes into an numerical value representing that 13570! status string. Each mnemonic string can be delimited by a ',' or 13580! '|'. The list of valid mnemonic strings is as follows: 13590! 13600! Bit Value Bit Pos Mnemonic 13610! --------- ------- --------------------------------------- 13620! 1= bit 0 RQS or REQUEST CONTROL 13630! 2= bit 1 BIT1 13640! 4= bit 2 UPP or PAUSE 13650! 8= bit 3 PRG or STOPPED 13660! 16= bit 4 RDY or READY 13670! 32= bit 5 ERR or ERROR 13680! 64= bit 6 RQS 13690! 128= bit 7 MSG or MESSAGE 13700! 256= bit 8 FRQ or FAST BUS SRQ 13710! 512= bit 9 IRQ 13720! 1024= bit10 SHT or SHUT or SHUTDOWN 13730! 2048= bit11 TRG or TRIG or TRIGGER 13740! 4096= bit12 BIT12 13750! 8091= bit13 BIT13 13760! 16384= bit14 PON or POWER ON 13770! 13780! The numerical value calculated will be returned in the function 13790! result. For example, FNHw_str_2_stat("PAUSE|RQS,FAST BUS SRQ") 13800! would return 324 as a result. If any field of Hp_ib_stat_str$ is 13810! not recognized by this function, then an error is logged on the 13820! CRT and no value returned. This is the inverse of FNHw_stat_2_str$ 13830! which converts the numerical value into a status string containing 13840! a mnemonic entry for each active status bit. 13850! 13860 ALLOCATE Temp$[255],Bit$[40] 13870 Temp$=TRIM$(UPC$(A$)) 13880 Stat=0 13890 WHILE POS(Temp$,",") 13900 Temp$[POS(Temp$,",");1]="|" 13910 END WHILE 13920 WHILE POS(Temp$,"|") 13930 Bit$=Temp$[1,POS(Temp$,"|")-1] 13940 GOSUB Hw_add_bit_val 13950 Temp$=Temp$[POS(Temp$,"|")+1] 13960 END WHILE 13970 IF Temp$<>"" THEN 13980 Bit$=Temp$ 13990 GOSUB Hw_add_bit_val 14000 END IF 14010 RETURN Stat 14020 Hw_add_bit_val:! 14030 SELECT TRIM$(Bit$) 14040 CASE "RQC","REQUEST CONTROL" 14050 Stat=Stat+1 !bit 0 14060 CASE "BIT1" 14070 Stat=Stat+2 14080 CASE "UPP","PAUSE" 14090 Stat=Stat+4 !bit 2 14100 CASE "PRG","STOPPED" 14110 Stat=Stat+8 !bit 3 14120 CASE "RDY","READY" 14130 Stat=Stat+16 !bit 4 14140 CASE "ERR","ERROR" 14150 Stat=Stat+32 !bit 5 14160 CASE "RQS" 14170 Stat=Stat+64 !bit 6 14180 CASE "MSG","MESSAGE" 14190 Stat=Stat+128 !bit 7 14200 CASE "FRQ","FAST BUS SRQ" 14210 Stat=Stat+256 !bit 8 14220 CASE "IRQ" 14230 Stat=Stat+512 !bit 9 14240 CASE "SHT","SHUT","SHUTDOWN" 14250 Stat=Stat+1024 !bit 10 14260 CASE "TRG","TRIG","TRIGGER" 14270 Stat=Stat+2048 !bit 11 14280 CASE "BIT12" 14290 Stat=Stat+4096 !bit 12 14300 CASE "BIT13" 14310 Stat=Stat+8192 !bit 13 14320 CASE "PON","POWER ON" 14330 Stat=Stat+16384 !bit 14 14340 CASE ELSE 14350 User_error("*** Couldn't recognize "&Bit$&" in FNHw_str_2_stat***") 14360 END SELECT 14370 RETURN 14380 FNEND 14390 ! 14400 ! PAGE -> 14410 !****************************************************************