我正在查询一台旧的 Tektronix 11801B 采样示波器。当我查询任何内容时,它总是返回我的结果,然后是一个设备上的“ÿ”或另一台设备上的“ÿ..”(均为同一型号)的无尽字符串。因此,我决定在查询时点击“ÿ”之前阅读所有内容。
以下是我尝试过的两种方法:
# Issue command
puts ${ChannelId} ${Command}
# Set loop variables
set Result [list]
set Byte [read ${ChannelId} 1]
set BadByte ÿ
# Loop until BadByte is found
while {![string equal -nocase ${Byte} ${BadByte}]} {
# Append good bytes to a list
lappend Result ${Byte}
# Read next byte
set Byte ::visa::read ${ChannelId} 1]
}
# Join and return result list
return [join ${Result}]
和:
# Set loop variable
set Result [list]
# Read channel 1 byte at a time until ÿ is found
while {![string equal -nocase [set Character [read ${ChannelId} 1]] "ÿ"]} {
# Append non ÿ characters to a list
lappend Result ${Character}
}
# Join the result and return it
return [join ${Result}]
在这两种情况下,我的循环总是返回 true 并变为无限。但是,如果我逐行运行命令行,希望一切正常。