Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial Port Read from Agilent E3648A Power Supply

Status
Not open for further replies.

sihingsteve94931

Programmer
Jun 19, 2013
2
0
0
US
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.

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}
 
Try "flush".

_________________
Bob Rashkin
 
Thanks for the reply Bong.

Unfortunately "flush" does not change things. I've tried using the command in several different ways and it is not working the way I expect it too.

What I'm attempting seems very basic, and because of my problems I'm thinking something is wrong with my entire approach. The entire script, when finished, is supposed to be interactive with the user. At this point I wonder if I should be using Expect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top