几个问题:
我可以在tcl中为函数(read_phy)分配变量(regvalue),如下所示吗?
$regvalue = read_phy $phy 19
我在Perl程序中有以下行。我想弄清楚应该是什么tcl等价物:
while((read_phy($phy, 18) >> 15) ne 0) { usleep(10000); };
read_phy
(tcl函数)如下所示:
proc read_phy {phy register} {
$value = exec ./read_phy.pl $phy $register
string trim $value;
if { $::DEBUG } {
puts [format "Read PHY %s register %s = 0x%0.8X" $phy $register $value]
}
if { $::DEBUG } {
puts [format "Read PHY %s register %s = 0x%0.8X" $phy $register $value]
}
set hex $value
return ($value);
}
答案 0 :(得分:3)
1
set regvalue [read_phy $phy 19]
2
while { ( [read_phy $phy 18] >> 15) != 0} { after 10 }
read_phy的前两行也应该是:
set value [exec ./read_phy.pl $phy $register]
set value [string trim $value]
- 字符串trim返回一个新值,它不会修改其输入值。