ProcommPlus Rep,
I have used the ProcommPlus transmit and waitfor commands so much, that I would like to now write a function call with passed params to get rid of the thousands of hard coded lines of waitfor and transmit code.
I can get the waitfor to work with the 1st string param, but need a way to also concatinate the time integer, and 4 constants that can be concatinated to the end of this command.
I have attached some example code that I am working on.
If Procomm had a structure, then maybe this would work, since the waitfor command uses 3 parameters of different typedefs. (i.e. waitfor string, integer, constant, constant, constant, constant.
Any ideas and/or suggestions would be appreciated !!
;*****************************************************************************
;* PROCEDURE NAME: TransmitCall
;*----------------------------------------------------------------------------
;* CALLED BY: Any Procedure(s)
;* Description: : processes the ProcommPlus TRANSMIT command with ALL params per the spec
;* and then checks the FAILURE/SUCCESS flags and passes back a return msg
;* INPUT: transmitCmd, transmitXlate, transmitMsg
;* OUTPUT: FAILURE/SUCCESS
;* RETURN: TRUE/FALSE
;*****************************************************************************
func TransmitCall : integer
param string transmitCmd
param string transmitXlate
;param string transmitAddCR
;param string transmitAddLF
param string transmitMsg
string transmitString = ""
if nullstr transmitCmd
goto TC_CRASH
else
;strquote transmitCmd
strcat transmitString transmitCmd
;strcat transmitString " "
endif
if not nullstr transmitXlate
strcat transmitString " "
strcat transmitString transmitXlate
endif
strcat transmitString transmitCmd
strreplace transmitString "\0" ""
TRANSMIT transmitString
if FAILURE
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": FAILED`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
elseif SUCCESS
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": PASSED`r`n"
termmsg MyTermMsg
return TRUE
else
TC_CRASH:
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": ProcommPlus PASS/FAIL Transmit Program CRASHED !`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
endif
endfunc
;*****************************************************************************
;* PROCEDURE NAME: WaitForCall
;*----------------------------------------------------------------------------
;* CALLED BY: Any Procedure(s)
;* Description: : processes the ProcommPlus WAITFOR command with ALL params per the spec
;* and then checks the FAILURE/SUCCESS flags and passes back a return msg
;* INPUT: waitForCmd, waitForTime, waitForCase, waitForCase, waitForXlate, waitForStrip
;* waitForMsg
;* OUTPUT: FAILURE/SUCCESS
;* RETURN: TRUE/FALSE
;*****************************************************************************
func WaitForCall : integer
param string waitForCmd
param string waitForTime
param string waitForever
param string waitForCase
param string waitForXlate
param string waitForStrip
param string waitForMsg
string waitForString = ""
string waitForString2 = ""
string waitForString3 = ""
integer waitForTimeInt = 0
;string waitForString = "("
if nullstr waitForCmd
goto WFC_CRASH
else
;strquote waitForCmd
strcpy waitForString waitForCmd
endif
atoi waitForTime waitForTimeInt
;itoa waitForTime waitForTimeStr
if not nullstr waitForTime
strfmt waitForString "%s %i" waitForString waitForTimeInt
;strcat waitForString " "
;strcat waitForString waitForTime
endif
if not nullstr waitForever
strcat waitForString " FOREVER"
endif
if not nullstr waitForCase
strcat waitForString " MATCHCASE"
endif
if not nullstr waitForXlate
strcat waitForString " RAW"
endif
if not nullstr waitForStrip
strcat waitForString " STRIP"
endif
strreplace waitForString "\0" ""
strreplace waitForString "`"" ""
strfmt myErrorMsg "`r`nMY WAITFOR Messsage is: %s`r`n" waitForString
termmsg myErrorMsg
WAITFOR waitForString
;WAITFOR (waitForCmd, waitForTime, waitForever, waitForCase, waitForXlate, waitForStrip) NO TEST MESSAGE INCLUDED
if FAILURE
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": FAILED`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
elseif SUCCESS
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": PASSED`r`n"
termmsg MyTermMsg
return TRUE
else
WFC_CRASH:
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": ProcommPlus PASS/FAIL Waitfor Program CRASHED !`r`n"
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
endif
endfunc
proc Switch_BOOT_Config
BOOT_Config_Flag = 0
WaitForCall ("The system is coming up, please wait...", "10", $NULLSTR, $NULLSTR, $NULLSTR, $NULLSTR, "1st BOOT Indicator: The system is coming up, please wait...")
WaitForCall ("Checking system RAM - press any key to stop test", "10", $NULLSTR, $NULLSTR, $NULLSTR, $NULLSTR, "2nd BOOT Indicator: Checking system RAM ...")
TransmitCall("^M", $NULLSTR, "Proceeding to STOP Brocade RAM Test!")
;TransmitCall(VK_ESCAPE, $NULLSTR, "Proceeding to STOP Brocade RAM Test!")
sendvkey VK_ESCAPE
WaitForCall ("host is alive", "30", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "Waiting for host is alive, BEFORE RESET PASSWORDS!")
WaitForCall ("setting passwd to defaults", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "setting passwd to defaults, BEFORE RESET PASSWORDS!")
WaitForCall ("time Bomb has been removed", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "time Bomb has been removed, BEFORE RESET PASSWORDS!")
WaitForCall ("Passwords have been reset. Please power cycle the switch.", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "Waiting for user to power cycle the switch!")
DialogBox_2("Comtek DialogBox2", "Please Power Cycle the Switch a 2nd Time !")
endproc
***********************************************************
Thanks, Willy113
I have used the ProcommPlus transmit and waitfor commands so much, that I would like to now write a function call with passed params to get rid of the thousands of hard coded lines of waitfor and transmit code.
I can get the waitfor to work with the 1st string param, but need a way to also concatinate the time integer, and 4 constants that can be concatinated to the end of this command.
I have attached some example code that I am working on.
If Procomm had a structure, then maybe this would work, since the waitfor command uses 3 parameters of different typedefs. (i.e. waitfor string, integer, constant, constant, constant, constant.
Any ideas and/or suggestions would be appreciated !!
;*****************************************************************************
;* PROCEDURE NAME: TransmitCall
;*----------------------------------------------------------------------------
;* CALLED BY: Any Procedure(s)
;* Description: : processes the ProcommPlus TRANSMIT command with ALL params per the spec
;* and then checks the FAILURE/SUCCESS flags and passes back a return msg
;* INPUT: transmitCmd, transmitXlate, transmitMsg
;* OUTPUT: FAILURE/SUCCESS
;* RETURN: TRUE/FALSE
;*****************************************************************************
func TransmitCall : integer
param string transmitCmd
param string transmitXlate
;param string transmitAddCR
;param string transmitAddLF
param string transmitMsg
string transmitString = ""
if nullstr transmitCmd
goto TC_CRASH
else
;strquote transmitCmd
strcat transmitString transmitCmd
;strcat transmitString " "
endif
if not nullstr transmitXlate
strcat transmitString " "
strcat transmitString transmitXlate
endif
strcat transmitString transmitCmd
strreplace transmitString "\0" ""
TRANSMIT transmitString
if FAILURE
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": FAILED`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
elseif SUCCESS
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": PASSED`r`n"
termmsg MyTermMsg
return TRUE
else
TC_CRASH:
strfmt MyTermMsg "`r`n%s" transmitMsg
strcat MyTermMsg ": ProcommPlus PASS/FAIL Transmit Program CRASHED !`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
endif
endfunc
;*****************************************************************************
;* PROCEDURE NAME: WaitForCall
;*----------------------------------------------------------------------------
;* CALLED BY: Any Procedure(s)
;* Description: : processes the ProcommPlus WAITFOR command with ALL params per the spec
;* and then checks the FAILURE/SUCCESS flags and passes back a return msg
;* INPUT: waitForCmd, waitForTime, waitForCase, waitForCase, waitForXlate, waitForStrip
;* waitForMsg
;* OUTPUT: FAILURE/SUCCESS
;* RETURN: TRUE/FALSE
;*****************************************************************************
func WaitForCall : integer
param string waitForCmd
param string waitForTime
param string waitForever
param string waitForCase
param string waitForXlate
param string waitForStrip
param string waitForMsg
string waitForString = ""
string waitForString2 = ""
string waitForString3 = ""
integer waitForTimeInt = 0
;string waitForString = "("
if nullstr waitForCmd
goto WFC_CRASH
else
;strquote waitForCmd
strcpy waitForString waitForCmd
endif
atoi waitForTime waitForTimeInt
;itoa waitForTime waitForTimeStr
if not nullstr waitForTime
strfmt waitForString "%s %i" waitForString waitForTimeInt
;strcat waitForString " "
;strcat waitForString waitForTime
endif
if not nullstr waitForever
strcat waitForString " FOREVER"
endif
if not nullstr waitForCase
strcat waitForString " MATCHCASE"
endif
if not nullstr waitForXlate
strcat waitForString " RAW"
endif
if not nullstr waitForStrip
strcat waitForString " STRIP"
endif
strreplace waitForString "\0" ""
strreplace waitForString "`"" ""
strfmt myErrorMsg "`r`nMY WAITFOR Messsage is: %s`r`n" waitForString
termmsg myErrorMsg
WAITFOR waitForString
;WAITFOR (waitForCmd, waitForTime, waitForever, waitForCase, waitForXlate, waitForStrip) NO TEST MESSAGE INCLUDED
if FAILURE
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": FAILED`r`n"
termmsg MyTermMsg
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
elseif SUCCESS
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": PASSED`r`n"
termmsg MyTermMsg
return TRUE
else
WFC_CRASH:
strfmt MyTermMsg "`r`n%s" waitForMsg
strcat MyTermMsg ": ProcommPlus PASS/FAIL Waitfor Program CRASHED !`r`n"
strreplace MyTermMsg "`r`n" ""
errormsg MyTermMsg
SF_Flag = false
return FALSE
endif
endfunc
proc Switch_BOOT_Config
BOOT_Config_Flag = 0
WaitForCall ("The system is coming up, please wait...", "10", $NULLSTR, $NULLSTR, $NULLSTR, $NULLSTR, "1st BOOT Indicator: The system is coming up, please wait...")
WaitForCall ("Checking system RAM - press any key to stop test", "10", $NULLSTR, $NULLSTR, $NULLSTR, $NULLSTR, "2nd BOOT Indicator: Checking system RAM ...")
TransmitCall("^M", $NULLSTR, "Proceeding to STOP Brocade RAM Test!")
;TransmitCall(VK_ESCAPE, $NULLSTR, "Proceeding to STOP Brocade RAM Test!")
sendvkey VK_ESCAPE
WaitForCall ("host is alive", "30", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "Waiting for host is alive, BEFORE RESET PASSWORDS!")
WaitForCall ("setting passwd to defaults", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "setting passwd to defaults, BEFORE RESET PASSWORDS!")
WaitForCall ("time Bomb has been removed", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "time Bomb has been removed, BEFORE RESET PASSWORDS!")
WaitForCall ("Passwords have been reset. Please power cycle the switch.", "15", $NULLSTR, "MATCHCASE", $NULLSTR, $NULLSTR, "Waiting for user to power cycle the switch!")
DialogBox_2("Comtek DialogBox2", "Please Power Cycle the Switch a 2nd Time !")
endproc
***********************************************************
Thanks, Willy113