Can't seem to disconnect properly from the com port in use and end the spawned process. I need to disconnect from the COM port, then reconnect.
# Read the COM port from the command line
if { $argc >= 1 } {
set file [lindex $::argv 0]
} else {
set file /dev/ttyUSB0
}
set fh [open $file RDWR]
fconfigure $fh -mode "115200,n,8,1" -blocking 0 -buffering none -eofchar {}
spawn -open $fh -noecho
The problem was that I was using "source" to run my other tcl scripts when I should have been using exec. Now I can allow my device to shut off, then turn back on and communicate again.