Subject: Re: can tcl/tk communicate with modem - DN [1]
Rolf Schroedter <Rolf.Schroedter@dlr.de> - 25 Oct 1999 - comp.lang.tcl
Try the following code and read the help-pages
(open, fconfigure, puts, flush, gets, read, fileevent):
####################################################
# Example A: blocking communication line by line
# Host-1
set chan [open com1: w]
fconfigure $chan -mode 9600,n,8,1 -buffering line
# Notice, this sends "2" CR LF
puts $chan "2"
# Host-2
set chan [open com1: r]
fconfigure $chan -mode 9600,n,8,1 -buffering line
# wait (block) until characters arrive
# Notice not all Tcl-versions really block,
# Tcl8.2 does, which is the correct behaviour.
gets $chan str
####################################################
# Example B: non-blocking communication char by char
# Host-1
set chan [open com1: w]
fconfigure $chan -mode 9600,n,8,1 -buffering none
# Notice, this sends "123"
puts -nonewline $chan "123"
# Host-2
set chan [open com1: r]
fconfigure $chan -mode 9600,n,8,1 -buffering none -blocking 0
# poll if there are characters on serial port
set str [read $chan]
if { [string length $str] } {
;# data has been received
}
#######################################################
# You could also use fileevents,
# but this is another chapter. See help on 'fileevent'.
#######################################################
Regards,
Rolf.
cwtay@angelfire.com wrote:
>
> yeah u are right abt me using windows platform.
> windows 98 to be exact.
> ...
> #######
> # host
>
> #open commport for writting
> %set channelId [open com1: w]
>
> #send character '2' to guest
> %puts $channelId 2
>
> ########
> # guest
>
> #open commport for reading
> %set channelId [open com1: r]
>
> #read from host
> %gets $channelId data
>
> after this command that my guest computer hangs.
> when i press ctrl-alt-del, it says console not
> responding
>
> hope the above description could help u to help me
> in resolving this matter. tanx once again kind
> sir.
>
> -END OF MESSAGE 10.22.1999-
>
---------------------------------------------------------------------
German Aerospace Center Rolf Schroedter
Inst. of Planetary Exploration Tel/Fax: +49 (30) 67055-416/384
Rudower Chaussee 5, D-12489 Berlin Internet: Rolf.Schroedter@dlr.de
Last modified
1999-11-04
1999-11-04
(195.108.246.50)
Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated
