diff --git a/site_ansto/instrument/getDMCprog.tcl b/site_ansto/instrument/getDMCprog.tcl new file mode 100755 index 00000000..da9fc6c5 --- /dev/null +++ b/site_ansto/instrument/getDMCprog.tcl @@ -0,0 +1,36 @@ +#!/usr/bin/tclsh +# DMC2280 uses cont-Z (hex 1a) as the EOF char +# Usage: +# ./getDMCprog.tcl -host dmcIP -port dmcPort > dmcprog.txt +# To fetch the code from the dmc2280 controller at dmcIP and +# write it to dmcprog.txt, dmcPort should be 1034. +# Note: Your computer must be on the same NBI vlan as the dmc +# controller for this to work. However you can use ssh port +# forwarding to work remotely. + +# On your computer run the following ssh command, +# ssh -L 1034:dmcIP:1034 sicsHostIP -lroot +# Then send the code with +# ./getDMCprog.tcl -host localhost -port 1034 > dmcprog.txt + +array set args $argv + +set con4 [socket $args(-host) $args(-port)] +fconfigure $con4 -buffering line -translation crlf -eofchar \x1a + +proc Echo {chan } { + global forever + + if {[eof $chan]} { + # A rude exit works best. Closing the socket and terminating the forever loop is unreliable + exit + #close $chan + #set forever done + } else { + puts [gets $chan] + } +} + +fileevent $con4 readable [list Echo $con4] +puts $con4 UL +vwait forever diff --git a/site_ansto/instrument/putDMCprog.tcl b/site_ansto/instrument/putDMCprog.tcl new file mode 100755 index 00000000..8dc3f0d3 --- /dev/null +++ b/site_ansto/instrument/putDMCprog.tcl @@ -0,0 +1,60 @@ +#!/usr/bin/tclsh +# NOTE: If any threads are running this will fail, kill all threads +# by sending an HX command to the controller. +# DMC2280 uses cont-Z (hex 1a) as the EOF char +# Usage: +# ./putDMCprog.tcl -host dmcIP -port dmcPort -file dmcprog.txt +# To send the code in dmcprog.txt to the dmc2280 controller at +# dmCIP:dmcPort, dmcPort should be 1034. +# Note: Your computer must be on the same NBI vlan as the dmc +# controller for this to work. However you can use ssh port +# forwarding to work remotely. + +# On your computer run the following ssh command, +# ssh -L 1034:dmcIP:1034 sicsHostIP -lroot +# Then send the code with +# ./putDMCprog.tcl -host localhost -port 1034 -file dmcprog.txt + +# NOTE: +# It takes the controller about 0.5msec to process a command +# so we sleep 1msec between sends to guarantee the DMC2280 FIFO doesn't overflow. + +array set cmdln_opts $argv + +set dmcIP $cmdln_opts(-host) +set dmcPORT $cmdln_opts(-port) +set controller [socket $dmcIP $dmcPORT] +fconfigure $controller -buffering line -translation crlf -eofchar \x1a + +# sleep time msec +proc sleep {time} { + global end + after $time set end 1 + vwait end +} +sleep 500 +puts "Opening $cmdln_opts(-file)" +set fh [open $cmdln_opts(-file)] + +puts -nonewline $controller "DL;" +sleep 500 +while {[gets $fh line] >=0} { + puts "Sending $line" + sleep 50 + puts $controller $line +} + +sleep 500 +puts $controller "\x1a" +sleep 500 + +puts "\nBIG IMPORTANT NOTE" +puts "If the transfer succeeded you must burn the program manually." +puts "eg, Using telnet do," +puts "telnet $dmcIP $dmcPORT" +puts "After connecting press enter and you should see a ':' prompt." +puts "Enter LS to list the program, if it's OK you can burn it as follows." +puts "Enter BP at the prompt, after a while the ':' prompt returns" +puts "You must then restart the #AUTO routine by entering," +puts "XQ#AUTO" +puts "then you can exit with ^], end enter quit"