Initial working version

r2000 | dcl | 2007-06-01 16:55:34 +1000 (Fri, 01 Jun 2007) | 2 lines
This commit is contained in:
Douglas Clowes
2007-06-01 16:55:34 +10:00
parent fa5e2711e8
commit 7d28dd3cd4

View File

@@ -0,0 +1,75 @@
#!/usr/bin/tclsh
# DMC2280 uses cont-Z (hex 1a) as the EOF char
# Usage:
# ./putDMCprog.tcl -host dmcIP -port dmcPort < dmcprog.txt
# To send the code to the dmc2280 controller at dmcIP and
# read it from 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
# ./putDMCprog.tcl -host localhost -port 1034 < dmcprog.txt
global forever
set line_num 0
# Convert the argument list into a has table
array set args $argv
if { 0 } {
set con4 stdout
fconfigure $con4 -buffering line -translation crlf -eofchar \x1a
} else {
# Open the socket to the controller
set con4 [socket $args(-host) $args(-port)]
# Set up the socket for the controller
fconfigure $con4 -buffering none -translation crlf
}
proc Echo { chan } {
global forever
global line_num
if { [eof stdin] } {
puts stdout "\\"
puts $chan "\\"
flush stdout
flush $chan
after 500
set forever done
exit
} else {
set line [gets stdin]
if { "$line" != "" } {
set line_num [expr $line_num + 1]
puts stdout "$line_num: $line"
puts $chan $line
flush stdout
flush $chan
after 20
}
}
}
# Stop any execution that might interfere with the download
puts stdout "HX"
puts $con4 "HX"
after 50
# Start the download
puts stdout "DL"
puts $con4 "DL"
after 50
if { 0 } {
fileevent $con4 writable [list Echo $con4]
fileevent $con4 readable [list puts [gets $con4]]
vwait forever
} else {
while { 1 } {
Echo $con4
}
}