# load tclvisa package into Tcl shell package require tclvisa # get handle to default resource manager if { [catch { set rm [visa::open-default-rm] } rc] } { puts stderr "Error opening default resource manager\n$rc" exit } # open device set visaAddr "TCPIP0::10.80.84.54::lan0::INSTR" if { [catch { set vi [visa::open $rm $visaAddr] } rc] } { puts "Error opening instrument `$visaAddr`\n$rc" # `rm` handle is closed automatically by Tcl exit } # Set proper timeout fconfigure $vi -timeout 500 # Send command to instrument. New line character is added automatically by `puts`. puts $vi "*CLS" # Send command to query device identity string puts $vi "*IDN?" # Read device's answer. Trailing new line character is removed by `gets`. set id [gets $vi] puts "Identity of `$visaAddr` is `$id`" # close channels close $vi close $rm