Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

talk with modem

10 views
Skip to first unread message

francis

unread,
Aug 31, 2005, 4:45:42 PM8/31/05
to
Hi,

I am able to send AT cmd to the modem. However, I can't see the
response. Setting blocking to 0 or 1 can't solve the problem.

#!/usr/bin/tclsh8.3
set devname "/dev/ttyS0"
set port [open $devname RDWR]
fconfigure $port -mode 19200,n,8,1 -blocking 0

puts -nonewline $port "AT\r"
flush $port

foreach line [split [read $port] \n] {
puts $line
}
close $port

stever

unread,
Aug 31, 2005, 9:06:38 PM8/31/05
to
francis wrote:
> Hi,
>
> I am able to send AT cmd to the modem. However, I can't see the
> response. Setting blocking to 0 or 1 can't solve the problem.

Here's a snippet from one of my apps. Perhaps it will help:

set com [open /dev/ttyS4 RDWR]
fconfigure $com -mode 115200,n,8,1 -handshake rtscts -blocking 0 \
-buffering none -translation binary

puts -nonewline $com "ATZ\r"
flush $com
after 100
puts "Modem send: [gets $com]"
puts "Modem echo: [gets $com]"


Steve

Rolf Schroedter

unread,
Sep 1, 2005, 2:29:56 AM9/1/05
to
http://wiki.tcl.tk/1108

As already pointed out the modem and the communication needs some time.
Sending 3 characters @19200 bps physically takes ~1.5 milliseconds.

You may consider to
(a) setup a fileevent callback to keep your tcl-application alive.
(b) setup an after callback, continously checking for serial data.

(a) guaranties the fastest reaction, but when communicating
line-by-line, you need to be aware that you might receive only part
of the incoming line in a single [fileevent] callback.
(b) might be a bit easier to implement, because you can use [gets].

In both cases setting up a proper [fconfigure -timeout] can be helpful.

Regards,
Rolf.


--

---------------------------------------------------------------
Rolf Schroedter, German Aerospace Center

Remove .nospam to reply: mailto:Rolf.Sc...@dlr.de.nospam

francis

unread,
Sep 1, 2005, 9:29:51 AM9/1/05
to
Steve and Rolf,

Thank you very much!! You saved my day :P

Francis

0 new messages