set chan [open "COM2:" r+]
# Read the current channel settings. Let's assume that
# we'll retain all the settings except for baud rate,
# which we'll want to change for sending data on the
# serial port.
set input [fconfigure $chan -mode]
# Split the values into separate variables.
foreach {baud parity data stop} $input {break}
# Assemble our channel settings for sending data.
set output "1200,$parity,$data,$stop"
# Change the channel mode to send some data.
fconfigure $chan -mode $output
puts $chan "My data"
# Go back to the original setting to read some data.
fconfigure $chan -mode $input
set num [gets $chan line]