`DECLARE SUB readword ()
`DECLARE SUB vlink (s AS ANY)
`DECLARE SUB acqfile (srecord AS ANY, arecord AS ANY, wfile$,
`xfile$, yfile$, zfile$)
`' $INCLUDE: 'struct.bas'
`DECLARE SUB srequest ()
`DEFINT A-Y: DEFSNG Z
`DIM SHARED r(256)
`
`' "Roadx" is a real time data acquisition routine for
`collecting
`' sweep data around an alert event.
`
`DIM srecord AS alertcon, arecord AS peakdata
`DIM s AS rdata
`
`' Set up the file I/O
`CALL acqfile(srecord, arecord, wfile$, xfile$, yfile$, zfile
`
`$)
`
`pointer
`
`recnum = 1' Initialize record number
`apoint = 0' Initialize circular buffer
`
`' Define buffers for file I/O
`
`DIM a(600), xk(600), ka(600)
`
`' Get 'define functions'
`' $INCLUDE: 'fun.bas'
`
`' Constants
`' $INCLUDE: 'dcon.bas'
`
`CALL vlink(s)' Get the variable link address from ABS
`
`file
`q:
`dis: CLS 0
`
`bad = 0
`sbad = 0
`tbad = 0
`
`' Open third file here & write 'image7' & theversion to
`record radio
`' settup information such as power up threshold.
`
`'*****> Write data collection description file 'zfile$'
`
`1
`
`Escort Ex. 2058, pg. 1
`
`
`
`OPEN zfile$ FOR OUTPUT AS #2
`PRINT #2, r(s.theversion)
`PRINT #2, r(s.image7)
`CLOSE #2
`
`PRINT "Begin Data Collection on "; DATE$
`
`'*********************************Begin Data
`Collection********************
`display:
`CALL srequest ' Get next record of data
` IF check <> 0 THEN bad = bad + 1: PRINT "Fiber checksum Error":
`GOTO display
` IF scheck <> 0 THEN sbad = sbad + 1: PRINT "Serial Checksum
`Error": GOTO display
`
`' Data Collection Activity Display
`v = r(s.swcnt) AND &H7FFF' # of sweeps
`z = 65536 * r(s.swcnt + 1) + v
`IF r(s.swcnt) < 0 THEN z = z + 32768
`IF z - zlast > 5 THEN
`zlast = z
`LOCATE , 1
`PRINT z;
`END IF
`
`' Test for end of data collection process
`a$ = INKEY$
`IF a$ = CHR$(27) THEN STOP
`IF LEN(a$) > 0 THEN newalert = 0: r = 1: GOTO getit
`
`xscan: GOTO ee
`r = r(s.regtim)
`p1 = r AND 15
`p2 = r AND &HF0
`p3 = r AND &HF00
`p4 = r AND &HF000
`IF (NOT e1) AND p1 THEN PRINT "1": e1 = p1
`IF (NOT e2) AND p2 THEN PRINT "2": e2 = p2
`IF (NOT e3) AND p3 THEN PRINT "3": e3 = p3
`IF (NOT e4) AND p4 THEN PRINT "4": e4 = p4
`ee: r = r(s.set1) AND 7
`getit: zalert = r(s.set3) AND 2
`IF r OR zalert OR (remain > 0) THEN
` IF newalert = 0 THEN
`PRINT "***"; CHR$(7);
`newalert = 1' If onset of new alert
`remain = keep
`r = r(s.set1) AND 7
`xdetect = r AND 1: IF xdetect THEN xdetect = -1
`kdetect = r AND 2: IF kdetect THEN kdetect = -1
`
`2
`
`Escort Ex. 2058, pg. 2
`
`
`
`kadetect = r AND 4: IF kadetect THEN kadetect = -1
`IF kadetect THEN xdetect = 0: kdetect = 0
`xkdetect = xdetect OR kdetect
`' Record following conditions from sweep that generates the alert
`srecord.date = DATE$
`srecord.time = TIME$
`srecord.rset1 = r(s.set1)
`srecord.rset2 = r(s.set2)' Configuration
`srecord.rset3 = r(s.set3)' Diagnostics
`srecord.rset4 = r(s.set4)
`srecord.rset6 = r(s.set6)
`srecord.rset7 = r(s.set7)
`srecord.bad = bad
`srecord.sbad = sbad
`srecord.tbad = tbad' Transfer Diagnostics
`srecord.rimages = r(s.images)
`END IF' End handling onset of alert
`IF remain = 1 THEN
`srecord.rset8 = r(s.set8)' Alert type info
`srecord.rset9 = r(s.set9)' not useful till
`
`now
`
`THEN STOP
`
`alert
`
`'IF (r(s.set8) = 0) AND (r(s.set9) = 0)
`
`END IF
`ELSE ' If not new alert or timing out old
`
`remain = 0: newalert = 0
`END IF
`
`'**************** Put data from alerting source into circular
`queue
`
`IF xkdetect THEN pp = s.xkpeak ELSE pp = s.kapeak
`level = apoint * zsize' Element # of Nth record in
`circular queue
`
`' All the data is inserted into the 'a' array here to minimize
`' data acquistion execution time. If disk I/O were to be
`performed here it
`' could result in missed records. After all data received
`following an alert,
`' it will be written to disk in next section.
`
`FOR i = 0 TO peakdt1' # magnitudes & indicies
`xk(level + i) = r(s.xkpeak + i)
`ka(level + i) = r(s.kapeak + i)
`NEXT i
`a(level + 20) = r(s.swcnt)
`a(level + 21) = r(s.swcnt + 1)
`a(level + 22) = r(s.set1)
`a(level + 23) = r(s.set5)
`t = r(s.kaener): u = r(s.kalevn)
`
`3
`
`Escort Ex. 2058, pg. 3
`
`
`
`IF xkdetect THEN t = r(s.xkener): u = r(s.xklevn)
`a(level + 24) = t
`a(level + 25) = u
` r = r(s.set1)
`IF r AND 1 THEN p1 = r(s.xset): p2 = r(s.xset + 1)
`IF r AND 2 THEN p1 = r(s.kset): p2 = r(s.kset + 1)
`IF r AND 4 THEN p1 = r(s.kaset): p2 = r(s.kaset + 1)
`a(level + 26) = p1
`a(level + 27) = p2
`a(level + 28) = r(s.regtim)
`
` IF remain <= 0 THEN GOTO donext
`remain = remain - 1
`IF remain > 0 THEN GOTO donext
`
`'******>Write new data to disk
`PRINT "Adding new ";
`IF xdetect THEN PRINT "x band";
`IF kdetect THEN PRINT "k band";
`IF kadetect THEN PRINT "Ka band";
`PRINT " record "; recnum; " to "; xfile$;
`PRINT " at "; TIME$
`
`'******> Write Description File 'xfile$'
`OPEN xfile$ FOR RANDOM AS #3 LEN = LEN(srecord)
`PUT #3, recnum, srecord
`CLOSE #3
`
`'*****> Write Data file 'Yfile$'
`
`' But first, move data associated with
`alert
`' into primary 'a' array.
`FOR i = 0 TO glast1' Each record
` level = i * zsize
`FOR j = 0 TO peakdt1' by index &
`
`magnitude
`
`aloc = level + j
`IF xkdetect THEN
`a(aloc) = xk(aloc)
`
`ELSE
`
`a(aloc) = ka(aloc)
`END IF
`NEXT j
`NEXT i
`
`OPEN yfile$ FOR RANDOM AS #4 LEN = LEN(arecord)
`FOR i = 0 TO glast1' # records in queue
`'Advance circular array point to oldest member of set
`apoint = apoint + 1: IF apoint = glast THEN
`
`apoint = 0
`
`level = apoint * zsize
`
`4
`
`Escort Ex. 2058, pg. 4
`
`
`
`arecord.a0 = a(level + 0)
`arecord.a1 = a(level + 1)
`arecord.a2 = a(level + 2)
`arecord.a3 = a(level + 3)
`arecord.a4 = a(level + 4)
`arecord.a5 = a(level + 5)
`arecord.a6 = a(level + 6)
`arecord.a7 = a(level + 7)
`arecord.a8 = a(level + 8)
`arecord.a9 = a(level + 9)
`arecord.b0 = a(level + 10)
`arecord.b1 = a(level + 11)
`arecord.b2 = a(level + 12)
`arecord.b3 = a(level + 13)
`arecord.b4 = a(level + 14)
`arecord.b5 = a(level + 15)
`arecord.b6 = a(level + 16)
`arecord.b7 = a(level + 17)
`arecord.b8 = a(level + 18)
`arecord.b9 = a(level + 19)
`arecord.swcnt1 = a(level + 20)
`arecord.swcnt2 = a(level + 21)
`arecord.rset1 = a(level + 22)
`arecord.rset5 = a(level + 23)
`arecord.energy = a(level + 24)
`arecord.qstick = a(level + 25)
`arecord.p1 = a(level + 26)
`arecord.p2 = a(level + 27)
`arecord.rregtim = a(level + 28)
`zpoint = i + glast * (CSNG(recnum) - 1) + 1
`PUT #4, zpoint, arecord
`NEXT i
`CLOSE #4
`
`'*****> File 'wfile$' always contains total # of records. Rewrite
`it here
`
`OPEN wfile$ FOR OUTPUT AS #4
`PRINT #4, recnum
`CLOSE #4
`
`Number
`
`recnum = recnum + 1' Advance Record
`
`' End record write section
`'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
`''''''''
`
`donext: apoint = apoint + 1' Circular buffer
`pointer
`
`IF apoint = glast THEN apoint = 0
`
`5
`
`Escort Ex. 2058, pg. 5
`
`
`
`GOTO display
`
`SUB acqfile (srecord AS alertcon, arecord AS peakdata, wfile$,
`xfile$, yfile$, zfile$)
`
`' xfile$ = "tt": GOTO nu
`
`rtry: CLS
`INPUT "Enter Root name for the '.dat' data collection file";
`xfile$
`
`IF LEN(xfile$) < 8 THEN GOTO fok
`PRINT "File name must be less than 7 characters"
`GOTO rtry
`
`nu:
`fok: IF xfile$ = "" THEN
`default$ = "ROAD"
`PRINT "Using default file name "; default$
`xfile$ = default$
`END IF
`
`' Four files are used to store sweep data
`d$ = ".dat"
`wfile$ = xfile$ + "w" + d$
`yfile$ = xfile$ + "y" + d$
`zfile$ = xfile$ + "z" + d$
`xfile$ = xfile$ + d$
`
`END SUB
`
`SUB reads
`
`ERR = 0: ON ERROR RESUME NEXT
`
`SHARED readi
` time = 20000: timeout = 0
`WHILE LOC(1) = 0
`time = time - 1: IF time = 0 THEN timeout = -1: GOTO
`
`zend
`
`WEND
`
`zend:
`END SUB
`
`'
`
`readi = ASC(INPUT$(1, #1))
`ON ERROR GOTO 0
`
`' Read two bytes from serial interface & form word
`SUB readword
`SHARED readi, iv, iv1, iv2
`CALL reads: POKE iv1, readi
`IF timeout THEN GOTO tend
`CALL reads: POKE iv2, readi
`
`tend:
`END SUB
`
`6
`
`Escort Ex. 2058, pg. 6
`
`
`
`SUB srequest
`SHARED readi, iv, iv1, iv2
`
`' Read Record of data from Serial Interface
`
`' Request data from interface
`
`rec:
`
`by
`
`timeout = 0' transfer request is generated
`
`GOTO findsync' setting parallel bit high,low.
` ' This is previously done to improve
`
`throughput
`
`' R
`
`ETRY: tbad = tbad + 1
`'
`
`timeout = 0
`LPRINT CHR$(1)' Set parallel port bit high
`LPRINT CHR$(0)' Set parallel port bit low
`
`' Locate the sync
`findsync: WHILE readi <> &HAA
`CALL reads
`IF timeout THEN GOTO RETRY
`
`WEND
`CALL reads
`IF timeout THEN GOTO RETRY
`IF readi <> &HAA THEN GOTO findsync
`CALL readword: check = iv' Read checksum
`IF timeout THEN GOTO RETRY
`CALL readword: words = iv' Read # of words
`IF timeout THEN GOTO RETRY
`IF words > 256 THEN GOTO findsync
`
`'
`
`' Read remaining data into array
`' Data comes in two sets..
`' The first set is 'words' in size
`scheck = 0
` FOR n = 0 TO words - 1
`CALL readword
`IF timeout THEN GOTO RETRY
`' PRINT HEX$(iv),
` r(n) = iv: scheck = scheck + (iv AND 255)
` NEXT n
`' The next set has the peak data & is 40
`words
`
`FOR n = 128 TO 167
`CALL readword
`IF timeout THEN GOTO RETRY
`' PRINT HEX$(iv),
` r(n) = iv: scheck = scheck + (iv AND 255)
` NEXT n
`'
`
`7
`
`Escort Ex. 2058, pg. 7
`
`
`
`'
`
`CALL readword' Read the checksum
`scheck = scheck AND 255
`scheck = scheck - iv' Test to see if checksum of serial
`xfer correct
`scheck = scheck AND 255
`
`'
`
`'
`
`LPRINT CHR$(1)' Set parallel port bit high
`LPRINT CHR$(0)' Set parallel port bit low
`
`END SUB
`
`SUB vlink (s AS rdata)
`
`DIM bit(512), ss$(512), ss(512), C$(512), v(500)
`PRINT "Acquires data for Version 245 and higher"
`
`'
`
` OPEN "COM1:19200,n,8,1,RB1024,bin,RS,RB1000,op0,cd0,ds0" FOR
`RANDOM AS #1
`
`' Start next transfer
`
`LPRINT CHR$(1)' Set parallel port bit high
`LPRINT CHR$(0)' Set parallel port bit low
`
`' Read a record from interface and extract the software
`version #
`grec:
`
` CALL srequest
`
`' I
`
`F check <> 0 THEN PRINT "Fiber checksum error "; fnx$(check):
`GOTO grec
`IF scheck <> 0 THEN PRINT "Serial Transfer error"; fnx$(scheck):
`GOTO grec
`'
`
`IF timeout <> 0 THEN GOTO grec
`
`'
`
`version = r(0)
`CLS
`PRINT : PRINT : PRINT : PRINT
`PRINT "Software in target is version "; HEX$(version)
`
`' '
`
` Locate the ".abs" file and extract the bss symbol
`table and
`'
`
`file$ = "C3X_" + HEX$(version) + ".ABS"
`PRINT "Extracting symbol table from "; file$
`
`'
`
`OPEN file$ FOR INPUT AS #2
`bss$ = ".bss ": bit$ = "bit ": group$ = "group
`
`" '
`
` Extract symbol names from the file
`
`8
`
`Escort Ex. 2058, pg. 8
`
`
`
`i = 0
`readline:
`LINE INPUT #2, a$
`x = INSTR(a$, bss$)' Does this line contain a symbol ?
`IF x <> 0 THEN GOTO bss
`x = INSTR(a$, group$)
`IF x <> 0 THEN GOTO group
`x = INSTR(a$, bit$)' Does this line contain a bit
`symbol?
`IF x = 0 THEN GOTO readline
`
`' '
`
` ******************* If 'bit', handle
`here
`'
`
`IF group = 0 THEN GOTO readline' Must be in 'group' mode
`bit(i) = group: group = group * 2
`x = x + LEN(group$)
`y = INSTR(a$, ",")' If so, locate the , following
`symbol name
`LENGTH = y - x' Calculate the string length
`ss$(i) = MID$(a$, x, LENGTH)' Get the symbol name
`a = ss(i - 1)
`GOTO storeadr
`
`' '
`
` ******************* If 'group', handle
`here
`
`' g
`
`roup: group = 1' Set group flag
`bit(i) = 0
`bitcount = 0
`x = x + LEN(group$)' x--> beginning of symbol
`a = LEN(a$)
`FOR y = 1 TO 23
`IF x + y = a THEN LENGTH = y + 1: GOTO gotlength
`IF MID$(a$, x + y, 1) = " " THEN GOTO gotz
`NEXT y
`PRINT #u, "Error in program"
`STOP
`gotz: LENGTH = y
`gotlength:
`'
`
`ss$(i) = MID$(a$, x, LENGTH)
`a = ss(i - 1) + 1
`GOTO storeadr
`
`' '
`
` ************************************If 'bss', handle
`here
`bss:
`
`group = 0: bit(i) = 0' Clear group flag
`x = x + LEN(bss$)
`y = INSTR(a$, ",")' If so, locate the , following
`symbol name
`
`9
`
`Escort Ex. 2058, pg. 9
`
`
`
`LENGTH = y - x' Calculate the string length
`ss$(i) = MID$(a$, x, LENGTH)' Get the symbol name
`
`'
`
`ba$ = "&h" + MID$(a$, 10, 4)
`a = VAL(ba$)
`storeadr:
`ss(i) = a' Record address of this symbol
`' Strip out the comments
`C$ = ""
`y = INSTR(a$, ";") + 1
`IF y <> 1 THEN
`az = LEN(a$)
`clength = az - y + 1
`IF clength <= 0 THEN GOTO eject
`C$ = MID$(a$, y, clength)
`END IF
`eject: C$(i) = C$
`IF ss$(i) = "xend" THEN GOTO tablein
`i = i + 1
`GOTO readline
`
`' t
`
`ablein: ss(i) = 255: snumb = i:
`'
`
`' Extract needed variables from data set
`FOR i = 0 TO snumb
`v = v(ss(i))
`IF "alpha" = ss$(i) THEN s.alpha = ss(i)
`IF "xkener" = ss$(i) THEN s.xkener = ss(i)
`IF "kaener" = ss$(i) THEN s.kaener = ss(i)
`IF "x_deviat" = ss$(i) THEN s.xdeviat = ss(i)
`IF "k_deviat" = ss$(i) THEN s.kdeviat = ss(i)
`IF "ka_deviat" = ss$(i) THEN s.kadeviat = ss(i)
`IF "xk_levn" = ss$(i) THEN s.xklevn = ss(i)
`IF "ka_levn" = ss$(i) THEN s.kalevn = ss(i)
`IF "xk_decy" = ss$(i) THEN s.xkdecy = ss(i)
`IF "ka_decy" = ss$(i) THEN s.kadecy = ss(i)
`IF "set10" = ss$(i) THEN s.set10 = ss(i)
`IF "set9" = ss$(i) THEN s.set9 = ss(i)
`IF "set8" = ss$(i) THEN s.set8 = ss(i)
`IF "set7" = ss$(i) THEN s.set7 = ss(i)
`IF "set6" = ss$(i) THEN s.set6 = ss(i)
`IF "set5" = ss$(i) THEN s.set5 = ss(i)
`IF "set4" = ss$(i) THEN s.set4 = ss(i)
`IF "set3" = ss$(i) THEN s.set3 = ss(i)
`IF "set2" = ss$(i) THEN s.set2 = ss(i)
`IF "set1" = ss$(i) THEN s.set1 = ss(i)
`IF "image_s" = ss$(i) THEN s.images = ss(i)
`IF "image_4" = ss$(i) THEN s.image4 = ss(i)
`IF "image_7" = ss$(i) THEN s.image7 = ss(i)
`IF "swcnt" = ss$(i) THEN s.swcnt = ss(i)
`IF "dynamicx" = ss$(i) THEN s.dynamicx = ss(i)
`IF "dynamicka" = ss$(i) THEN s.dynamicka = ss(i)
`
`10
`
`Escort Ex. 2058, pg. 10
`
`
`
`IF "xset" = ss$(i) THEN s.xset = ss(i)
`IF "kset" = ss$(i) THEN s.kset = ss(i)
`IF "kaset" = ss$(i) THEN s.kaset = ss(i)
`IF "pair" = ss$(i) THEN s.pair = ss(i)
`IF "theversion" = ss$(i) THEN s.theversion = ss(i)
`IF "regtim" = ss$(i) THEN s.regtim = ss(i)
`s.xkpeak = &H80
`s.kapeak = &H92
`
`'
`
`NEXT i
`CLOSE #2
`
`' E
`
`ND SUB
`
`11
`
`Escort Ex. 2058, pg. 11
`
`