diff --git a/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl b/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl index 16ac2d1..53701f2 100644 --- a/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl +++ b/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl @@ -1,6 +1,6 @@ ; ============================================================================= ; Script A for Blanton -; Version : V1.0.3 +; Version : V1.0.4 ; Date : 2026-08-21 ; Author : ETWen ; ============================================================================= @@ -16,6 +16,8 @@ ; ScriptB/C Add Traffic Test ; V1.0.3 2026-08-21 utils/wait_init.ttl Created ; ScriptA Add Wait DUT Ready +; V1.0.4 2026-08-21 utils/wait_init.ttl Wait on bcmcmd port-up +; count (both units > 216) ; ============================================================================= include "config.ttl" diff --git a/src/Script_ABC_Blanton/utils/wait_init.ttl b/src/Script_ABC_Blanton/utils/wait_init.ttl index 207e2da..df53470 100644 --- a/src/Script_ABC_Blanton/utils/wait_init.ttl +++ b/src/Script_ABC_Blanton/utils/wait_init.ttl @@ -1,30 +1,68 @@ -; ============================================================================= -; File : utils/wait_init.ttl -; Version : V1.0.0 -; Date : 2026-08-21 -; Author : ETWen -; ============================================================================= -; Wait until "show platform temperature" is not "Thermal Not detected". -; Enter : prompt of the previous command is NOT consumed. -; Exit : "show platform temperature" is sent, prompt NOT consumed. -; -; Version History: -; V1.0.0 2026-08-21 Initial Version -; ============================================================================= -wt_interval = 10 -timeout = 30 -wait prompt_sonic_root - -:WAIT_THERMAL -sendln "show platform temperature" -wait "Thermal Not detected" prompt_sonic_root -if result = 2 then - goto THERMAL_OK -endif -wait prompt_sonic_root -pause wt_interval -goto WAIT_THERMAL - -:THERMAL_OK -timeout = 0 -sendln "show platform temperature" +; ============================================================================= +; File : utils/wait_init.ttl +; Version : V2.0.0 +; Date : 2026-08-21 +; Author : ETWen +; ============================================================================= +; Wait until BOTH switch units report more than WT_MIN ports up: +; bcmcmd -n 0 -c ps | grep -w up | wc -l +; bcmcmd -n 1 -c ps | grep -w up | wc -l +; +; Enter : prompt of the previous command is NOT consumed. +; Exit : a command has been sent, prompt NOT consumed (caller does the wait). +; +; Why the "PORTS0=" marker instead of reading the number straight off the +; screen: TTL can only test for a string, so counting requires capturing the +; output. Wrapping the count in an echo gives waitregex a unique anchor, and +; the ECHO of the command itself cannot false-match -- it reads +; "PORTS0=$(bcmcmd ..." and the regex demands a digit right after the "=". +; +; Version History: +; V1.0.0 2026-08-21 Initial Version (waited on "show platform temperature" +; until it stopped reporting "Thermal Not detected") +; V2.0.0 2026-08-21 Wait on the bcmcmd port-up count of BOTH switch units +; instead of the thermal sensors; proceed only when both +; are greater than WT_MIN (216). +; ============================================================================= +WT_MIN = 216 ; both units must report MORE than this many ports up +WT_INTERVAL = 10 ; seconds between polls + +timeout = 60 ; per-wait cap; bcmcmd ps is not instant +wait prompt_sonic_root + +:WAIT_PORTS +; --- unit 0 ----------------------------------------------------------------- +wt_up0 = 0 +sendln "echo PORTS0=$(bcmcmd -n 0 -c ps | grep -w up | wc -l)" +waitregex "PORTS0=[ ]*([0-9]+)" +if result = 1 then + str2int wt_up0 groupmatchstr1 +endif +wait prompt_sonic_root + +; --- unit 1 ----------------------------------------------------------------- +wt_up1 = 0 +sendln "echo PORTS1=$(bcmcmd -n 1 -c ps | grep -w up | wc -l)" +waitregex "PORTS1=[ ]*([0-9]+)" +if result = 1 then + str2int wt_up1 groupmatchstr1 +endif +wait prompt_sonic_root + +; --- both above the threshold? ---------------------------------------------- +; Nested ifs rather than "and": in TTL "and" is bitwise, so keeping the two +; comparisons separate leaves no room for precedence surprises. +if wt_up0 > WT_MIN then + if wt_up1 > WT_MIN then + goto PORTS_OK + endif +endif + +pause WT_INTERVAL +goto WAIT_PORTS + +:PORTS_OK +timeout = 0 +; Exit contract: send something without waiting, so the caller's next +; "wait prompt_sonic_root" has a prompt to match. +sendln ""