From 32c88f6dcb1d66b45b690c592754a0c65638486f Mon Sep 17 00:00:00 2001 From: Martin Kennedy Date: Sat, 26 Jul 2025 17:48:46 -0400 Subject: [PATCH] feat: first working version --- ap3825i.expect | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/ap3825i.expect b/ap3825i.expect index 3064f40..13da918 100755 --- a/ap3825i.expect +++ b/ap3825i.expect @@ -2,14 +2,47 @@ set timeout 100 exp_internal 1 - set send_slow {1 0.005} +# +# A procedure to send a string character by character, +# waiting for each character to be echoed before sending the next. +# +proc reliable_send {str} { + # Set a timeout for waiting for the echo of a single character + set timeout 2 + + # Loop through each character of the input string + for {set i 0} {$i < [string length $str]} {incr i} { + set char [string index $str $i] + + # Send the single character. + # The "--" argument ensures that if the character is a dash, + # it isn't interpreted as an option to the send command. + send -- $char + + # Expect the character to be echoed back + expect { + # If the echo is received, continue to the next iteration + -ex $char { + # Optional: uncomment the next line for debugging + # puts "Sent and received: $char" + continue + } + # If we time out waiting for the echo, handle the error + timeout { + puts "ERROR: Timed out waiting for echo of character: '$char'" + exit 1 + } + } + } +} + spawn picocom -b 115200 /dev/ttyUSB1 --logfile $env(OUTPUT_LOG_FILE) set term_id $spawn_id spawn ./toggle_jg928a_port.sh set spawn_id $term_id -#spawn ssh root@jg928a + expect "DRAM" send " " @@ -33,12 +66,11 @@ expect { expect { "Please press Enter to activate this console." { - send -s "\n" - sleep 50 - send -s { - sysupgrade https://downloads.openwrt.org/releases/23.05.2/targets/mpc85xx/p1020/openwrt-23.05.2-mpc85xx-p1020-extreme-networks_ws-ap3825i-squashfs-sysupgrade.bin; -done; -} + send "\n" + sleep 5 + reliable_send {while true; do sysupgrade https://downloads.openwrt.org/releases/23.05.2/targets/mpc85xx/p1020/openwrt-23.05.2-mpc85xx-p1020-extreme-networks_ws-ap3825i-squashfs-sysupgrade.bin; done + } } } +expect {Sending KILL to remaining processes}