#!/usr/bin/tclsh # (c) 1999,2000 # Loren Wyard-Scott (wyard@ee.ualberta.ca) # The author hereby grants permission to copy and # modify this file as long as credit is given. # Simple file to pipe the named file to the named serial port # to an HC11 board running micro11 (by Grant Beattie). # Note that the baudrate must be established by some other program, # such as minicom. (i.e. minicom must be running on the same serial # port.) set serialport /dev/ttyS1 set Revision 0.1 # To save a little time if there is a problem loading the .s19 file, # load it now. # Get rid of the extension, if there is one. set base [lindex $argv 0] set base [file rootname $base] if [catch "open $base.s19 RDONLY" fileID] { puts stderr "Error: $fileID" exit 1 } # Open the serial port. if [catch "open $serialport WRONLY" serID] { puts stderr "Error: $serID" exit 1 } puts stdout "Entering download mode." # Pipe "escape" out to the micro11 monitor a few times to get to # the starting window (main menu). puts $serID "\x1B" flush $serID after 1000 puts $serID "\x1B" flush $serID after 1000 # Now enter download mode. puts $serID "d" flush $serID after 500 # Select Motorola .s19 file mode. puts $serID "m" flush $serID after 500 puts stdout "Sending $base.s19 to $serialport" while {![eof $fileID]} { # Read a single character from the .s19 file. set char [gets $fileID] # Send it out to the serial port. puts $serID $char puts stdout "$char" } # Send any unfinished serial characters. flush $serID # Simply use "cat" to list the file, piping output to # the serial port. The -v option shows nonprinting characters. #if [catch "exec /bin/cat -v $filename >@ $serID" errors] { # puts stdout "Problem sending file to the serial port:" # puts stdout $errors # close $serID # exit 1 #} puts stdout "Done sending to serial port." close $fileID close $serID