sihingsteve94931
Programmer
Greetings all....
I've created a couple of TCL scripts that write strings to the Agilent Power supply, now I am working on a read/write version of the same thing.
Been having problems receiving characters properly from the bench supply.
1. If I run my code in a tclsh, I get nothing back from the device at all.
2. If I run my code in an ActiveTcl wish console, I can get data back from the bench supply but only if I either halt script execution after the "read" command or I enter the "read" command manually.
Here is the minimal code I've been working with. Any help is appreciated.
I've created a couple of TCL scripts that write strings to the Agilent Power supply, now I am working on a read/write version of the same thing.
Been having problems receiving characters properly from the bench supply.
1. If I run my code in a tclsh, I get nothing back from the device at all.
2. If I run my code in an ActiveTcl wish console, I can get data back from the bench supply but only if I either halt script execution after the "read" command or I enter the "read" command manually.
Here is the minimal code I've been working with. Any help is appreciated.
Code:
set msg ""
set w_time 1000
proc rd_chid {chid} {
if { [catch {set msg [read -nonewline $chid] } ] } {
puts "error"
} else {
puts stdout $msg
#puts "com recv"
}
}
#open the com ports
set psone [open "com1" r+]
fconfigure $psone -mode 9600,n,8,1 -blocking 0 -translation auto -buffering none
fileevent $psone readable [list rd_chid $psone]
# set device into remote control mode
puts $psone "SYSTEM:REMOTE"
# select first node of dual node supply
puts $psone "INSTRUMENT:nSel 1"
# read voltage
puts $psone "MEASure:VOLTage:DC?"
#puts $psone "*OPC?"
#puts $psone "*CLS"
#puts $psone "SYSTEM:LOCAL"
#after 5000 {close $psone}