#!/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"