Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

feed back pleae on my first script 2

Status
Not open for further replies.

mop01995

Technical User
Oct 30, 2006
6
US
I would like some feed back on my first attempt to make a script. Please send any comments good or bad. Also if you see anything that would improve or speed up the script let me know. Thanks

;***************************************************************************************************************************
;Automated script for loading the TruePosition LMU's
;Version 2.0 By Scott Gayer 10-31-06
;***************************************************************************************************************************

;Global Variables
string sLat, sLong, sCLength, sAMSL, sDelay
float fCLength, fdelay, Famount

proc main
usermsg "Remove all RF cables!" ;Warning message to user
usermsg "Remove T-1 Cable!!" ;Warning message to user
call setupT1 ;Sets up the T-1
call SoftwareLoad ;Loads Software to the LMU
Call SettingGPS ;Sets up and enables the GPS
call SignalTests ;Checks out the LMU and cables
call Memorytests ;Checks out the LMU

endproc
proc LMUPrompt ;puts LMU into normal state
pwtitlebar "Getting the LMU Prompt"
transmit "^M" ;wake up unit
pause 1
transmit "reboot^M" ;reboot command if in T-Shell
pause 1
transmit "reset^M" ;resets unit when in Dshell
waitquiet 5 ;Gives LMU terminal display time to stabilize following a reset condition.
transmit "proc^M" ;tells LMU to Proceed
waitfor "Enter GPS message processing loop^M^J" ;waits for LMU to boot up
pause 5 ;pauses script for 5 seconds
transmit "^M" ;wakes up unit again
pause 1
transmit "^M"
waitfor "->" ;Waits for Target Shell
transmit "dshell^M" ;puts LMU into Dshell
waitfor "LMU>" ;waits for the LMU prompt
pause 1

endproc

proc setupT1 ;Sets up the T-1 for the LMU
call LMUPrompt ;Calls LMU Prompt
pwtitlebar "Setting up the T-1"
transmit "CLRDS0BIT^M" ;disables all DS0's
pause 1
transmit "SETNETWORKTYPE 0^M" ;enables T-1 Mode
pause 1
transmit "SET56KMODE 0^M" ;sets speed to 64kbps
pause 1
transmit "SETLINEMODE 0^M" ;sets line to B8ZS
pause 1
transmit "SETFRAMING 0^M" ;sets the frame to ESF
pause 1
transmit "ENABLEDS0BIT 23^M" ;enables timeslot 23
pause 1
transmit "SHOWCOMCFGS^M" ;shows current T-1 strapping
usermsg "Strapping is Done!"
endproc

proc SoftwareLoad ;loads version 9.1 software to the LMU
pwtitlebar "Sending LMUBOOT-R9.1BL007"
sendfile ASCII "LMUBOOT-R9.1BL007.hex" ;takes about 4 minutes
pause 250
call LMUPrompt

pwtitlebar "Sending LMUFLASH-R9.1BL133"
sendfile ASCII "LMUFLASH-R9.1BL133.hex" ;takes about 4 minutes
pause 250
call LMUPrompt

pwtitlebar "Sending LMUFPGA-R7.0BL14"
sendfile ASCII "LMUFPGA-R7.0BL14.hex" ;takes about 8 minutes
pause 500
call LMUPrompt

pwtitlebar "Sending TPGPSFLASH-R9.1BL010" ;takes about 4 minutes
transmit "dwnldtype GPS^M"
sendfile ASCII "TPGPSFLASH-R9.1BL010.srec"
pause 250
call LMUPrompt

pwtitlebar "Sending TPGPSFPGA-R7.0BL011" ;takes about 8 minutes
transmit "dwnldtype GPS^M"
sendfile ASCII "TPGPSFPGA-R7.0BL011.hex"
pause 500
call LMUPrompt
usermsg "Software Loading is Done!"
endproc

proc SignalTests ;checks out the receivers and cables
pwtitlebar "Checking the Noise Floor"
transmit "searchbcn none^M" ;Stops the beacon search
usermsg "Verify that all RF cables are disconnected!"
transmit "gain 1 43^M"
pause 1
transmit "bit 6 255 3 512 10 0^M"
usermsg "Record the readings as Port 1 No Cables"
pause 5
transmit "gain 2 43^M"
pause 1
transmit "bit 6 255 3 512 10 1^M"
usermsg "Record the readings as Port 2 No Cables"
pause 5
transmit "gain 3 43^M"
pause 1
transmit "bit 6 255 3 512 10 2^M"
usermsg "Record the readings as Port 3 No Cables"
pause 5
transmit "gain 4 43^M"
pause 1
transmit "bit 6 255 3 512 10 3^M"
usermsg "Record the readings as Port 4 No Cables"
pause 5
transmit "gain 5 43^M"
pause 1
transmit "bit 6 255 3 512 10 4^M"
usermsg "Record the readings as Port 5 No Cables"
pause 5
transmit "gain 6 43^M"
pause 1
transmit "bit 6 255 3 512 10 5^M"
usermsg "Record the readings as Port 6 No Cables"
pause 5
pwtitlebar "Testing RF Levels on the port cables"
Usermsg "Please connect all used port cables"
transmit "bit 6 255 3 512 10 0^M"
usermsg "Record the readings as Port 1 with Cables"
pause 5
transmit "bit 6 255 3 512 10 1^M"
usermsg "Record the readings as Port 2 with Cables"
pause 5
transmit "bit 6 255 3 512 10 2^M"
usermsg "Record the readings as Port 3 with Cables"
pause 5
transmit "bit 6 255 3 512 10 3^M"
usermsg "Record the readings as Port 4 with Cables"
pause 5
transmit "bit 6 255 3 512 10 4^M"
usermsg "Record the readings as Port 5 with Cables"
pause 5
transmit "bit 6 255 3 512 10 5^M"
usermsg "Record the readings as Port 6 with Cables"
pause 5
usermsg "Verify the differences in reading are as expected"
call LMUPrompt
endproc

proc SettingGPS ;initilizes and turns up the GPS
integer idelay
string GPSCommand
pwtitlebar "Setting up the GPS"
usermsg "Please connect the GPS Cable"
pause 1

dialogbox 0 8 20 368 169 67 "Setting GPS"
editbox 1 122 24 74 19 sLat 10
editbox 2 122 45 74 19 sLong 11
editbox 3 122 67 74 19 sCLength 6
editbox 4 122 88 74 19 sAMSL 4
pushbutton 5 70 121 184 32 "Continue" OK Default
text 6 40 24 74 19 "Latatude" right
text 7 40 88 74 19 "Antenna AMSL" right
text 8 40 67 74 19 "Antenna Cable Length" right
text 9 40 45 74 19 "Longitude" right
text 10 205 85 94 18 "Altitude from Handheld GPS in Meters" left
text 11 205 64 94 18 "Total GPS Cable length in Meters" left
text 12 205 44 94 18 "Longitude from Handheld GPS in -DDD.dddddd Format" left
text 13 205 24 94 18 "Latatude from Handheld GPS in DD.dddddd Format" left
text 14 14 2 344 14 "Initial GPS Settings from Handheld Unit." center
enddialog
GPSCommand = "GPS "
atof sCLength fCLength ;turns string into float
call cabledelay ;multiplies cable length by 4 to get cable delay
ftoa fDelay sDelay ;turns float back into a string
atoi sDelay iDelay ;turns string into an integer for rounding reasons
itoa idelay sDelay ;turns integer back into a string to be used later
strcat sLat " " ;adds a space to the end of the string
strcat sLong " " ;adds a space to the end of the string
strcat sDelay " " ;adds a space to the end of the string
strcat sAMSL "^M" ;adds a return to the end of the string
strcat GPSCommand sLat ;adds the latitude to the end of the GPS command string
strcat GPSCommand sLong ;adds the longitude to the end of the the above string
strcat GPSCommand sDelay ;adds the delay to the end of the above string
strcat GPSCommand sAMSL ;adds the AMSL to the end of the above string
transmit GPScommand ;sends the resulting completed string as the Set GPS location command
pause 5
transmit "gstat^M" ;checks the number of satellites
pause 3
transmit "bit 9^M" ;places LMU into self survey mode to dial in the location
pause 60
waitfor "LMU>" ;waits for the LMU prompt
pause 1
transmit "?gps^M" ;checks the resulting location
pause 5
usermsg "Record this location"
transmit "gstat^M" ;checks satellite status again
pause 1
usermsg "Record the number of satellites"
call LMUPrompt
endproc

proc cabledelay ;figures delay from 4(cable length)
famount = 4
fDelay=Famount*FCLength
endproc

proc MemoryTests ;tests all of the DSP's and checks the memory
pwtitlebar "Testing the DSP Memory"
transmit "bit 4 1^M"
waitfor "LMU>DSP 0 has come back online."
transmit "bit 4 2^M"
waitfor "LMU>DSP 1 has come back online."
transmit "bit 4 3^M"
waitfor "LMU>DSP 2 has come back online."
transmit "bit 4 4^M"
waitfor "LMU>DSP 3 has come back online."
usermsg "If you received a BIT 4 Failure Replace the LMU"
pwtitlebar "Testing the CP Memory"
transmit "bit 5^M"
waitfor "LMUBOOT>T1 line disconnected^M^J"
transmit "^M"
waitfor "LMUBOOT>"
transmit "proc^M"
waitfor "CP RAM Memory Test Passed"
pause 10
usermsg "If CP RAM Memory Test Failed replace LMU"
pwtitlebar "GSM Downlink Power Test"
transmit "^M"
pause 1
usermsg "Please connect the Beacon Antenna"
transmit "bit 8 5^M" ;tests the GSM beacon antenna for signal
waitfor "BIT 8 PASSED"
pwtitlebar "GSM Beacon Search"
transmit "searchbcn PCS^M" ;starts searching the PCS band for usable beacons
pause 180
waitfor "search of Beacon Ranges has completed"
usermsg "Please record the number of beacons found"
usermsg "Please reconnect the T-1"
transmit "reset^M"
usermsg "Please verify the LMU is up"
usermsg "Thank You, Please Hang up now"
endproc
 
I've always found it to be a good practice to include 'forever' after any waitfor's.

waitfor "CP RAM Memory Test Passed" forever
pause 10

I've seen circumstances where it's possible that the waitfor timed out and the program continued on too soon.

Other then that, things look good. You 'modulized' your code, and that's a good way of keeping things organized and maintainable.

I noticed all the values and file names are hard coded, if your data may change frequently, it might be worth while looking into DDE to pull data from an Excel file, or reading data in from a text file. But if your data is pretty static, then it's not worth the effort.
 
Thank you for the feed back.

I was looking into a few different ways to load the files. Each release has the first portion of the file names the same, so I was going to try some wildcards, but then I realized we have only had 1 new release in two years. I figured that I would have to make a few other changes with each new release anyway, so I would have to rebuild the script anyway.

Another reason I modulized the code is so I would be able to make a start up window where the user could click the options that they need. Each piece of equipment we receive has needed a few of the steps but not all. This does everything even if the equipment does not need it.

I am loading several hundred units a year, so I am looking for consistency between all of the equipment.
Again than you for taking the time to look this over and for the feed back.
With Consistency comes Predictability
 
On your sendfile commands, you might want to add these lines afterwards:

while $XFERSTATUS == 1
yield
endwhile

This may not be necessary for ASCII transfers as much as the other file transfer protocols, but will pause the script until the file transer has completed. You can also add some error checking in (see a couple of the examples on my site, link below), but again probably not necessary with most ASCII transfers.

 
I have added both sugestions, and I will retest it. Thank you both for your help.

Quote from kodr
"I noticed all the values and file names are hard coded, if your data may change frequently, it might be worth while looking into DDE to pull data from an Excel file, or reading data in from a text file. But if your data is pretty static, then it's not worth the effort."

How would I go about pulling the data from a text file?

Thank You
 
There's quite a few posts regarding this. A quick search will turn some good examples.

Basically use 'fopen' to open a text file, 'fgets' will read in a line of text and assign it to a string variable.

You can set up your file so that each item is it's on line in the text file, or seperate the data by a delimiter (comma, /, etc..)

 
Look at knob's response on this one.

thread448-1258092
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top