Why is there a line break in this "pending" code?

I created the following routine pending work with the Agilent Base Station Simulator:

proc get_bss_parameter_value {bss parameter_string} {
global bss_array

set bss_str "$parameter_string?"

puts "String 1"
set bss_str "oa;$bss_array(gpib):$bss_str\r"
send "$bss_str"
expect {nopattern^}

puts "String 2"
set bss_str "en;$bss_array(gpib)"
puts "Sending bss_str: $bss_str"
send "$bss_str\r"
expect .*

set receive_buffer $expect_out(buffer)
puts "receive_buffer START: $receive_buffer"
puts "END"

return $receive_buffer
}

      

=============================================== === ====== OUTPUT:

Line 1

<P →

oa; 05: SIS: APPL? Line 2 Send bss_str: ru; 05 "CDMA 2000 Lab Application"

cannot read "expect_out (buffer)": no such variable when executing "set receive_buffer $ expect_out (buffer)" (procedure "get_bss_parameter_value" line 20)

=============================================== === ====== If "." is replaced with "" in the above code, this is OUTPUT:

Line 1

<P →

oa; 05: SIS: APPL? Line 2 Send bss_str: ru; 05 receive_buffer START:

oa; 05: SIS: APPL

END Current application

oa; 05: SIS: APPL

Problem:
1) I cannot get the "CDMA 2000 Lab App T" value in the expect_out (buffer) variable, which should match (due to. *) The Agilent device pin. Is there something wrong with the code? 2) In both cases, the command "en; 05" is sent, but not displayed on stdout. Although we see the expected result in the first case.

0


a source to share


2 answers


Note that the [expect] command defaults to glob-style , not regexp-style . So where do you write:

expect .*

      

you are actually looking for a string that starts with a literal dot followed by any number of characters. Since it doesn't match, the expect_out array is not populated. As you noted

expect *

      



behaves as you expect, because the ball pattern "*" matches any string.

If you really want ". *" You need to specify

expect -re .*
set receive_buffer $expect_out(buffer)

      

+1


a source


I was under the impression that the expect_out variable was global. If I'm right, you need the following:

global expect_out

      



Or you can refer to it as global explicitly using the namespace qualifier "::"

set receive_buffer $::expect_out(buffer)

      

0


a source







All Articles