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

serial communication with tcl

522 views
Skip to first unread message

grp62

unread,
Feb 28, 2008, 10:12:50 AM2/28/08
to
Hello,
I'd like to program with tcl language the serial ports of my arm
target (sam9260).
I built a rootfilesystem including the tcl package (tcl-8.4.9) with
buildroot.
On my target (kernel-2.6.23) when i tried to execute the following
commands

set serial [open /dev/ttyS0 RDWR]
fconfigure $serial -mode "115200,n,8,1"

here's the message i get:

bad option "-mode": should be one of -blocking, -buffering, -
buffersize, -encoding, -eofchar, or -
translation
while
executing
"fconfigure $serial -mode "115200,n,8,1" "

Any ideas ?
regards

Larry W. Virden

unread,
Feb 28, 2008, 12:21:17 PM2/28/08
to
On Feb 28, 10:12 am, grp62 <gr...@yahoo.fr> wrote:

> set serial [open /dev/ttyS0 RDWR]
> fconfigure $serial -mode "115200,n,8,1"
>
> here's the message i get:
>
>  bad option "-mode": should be one of -blocking, -buffering, -
> buffersize, -encoding, -eofchar, or -
> translation


The -mode flag was moved to tcl's open command back in 2003. Read the
second n open man page (see the link at the top of http://wiki.tcl.tk/open
if you don't have local man pages) for more details.

derek....@csr.com

unread,
Feb 28, 2008, 12:36:10 PM2/28/08
to
Hi

Seems to work for me on Ubuntu 7.10
TkCon screen dump

loading history file ... 48 events added
buffer line limit: 512 max line length: unlimited
Main console display active (Tcl8.4.15 / Tk8.4.15)
(dp01) 49 % set fd [ open /dev/ttyS0 r+]
file6
(dp01) 50 % fconfigure $fd -mode "9600,n,8,1"
(dp01) 51 % close $fd
(dp01) 52 % set fd [ open /dev/ttyS0 RDWR]
file6
(dp01) 53 % fconfigure $fd -mode "9600,n,8,1"
(dp01) 54 % close $fd
(dp01) 57 % set fd [ open /dev/ttyS0 RDWR]
file6
(dp01) 58 % fconfigure $fd -mode "115200,n,8,1"
(dp01) 59 %

Jonathan Bromley

unread,
Feb 28, 2008, 12:40:29 PM2/28/08
to
On Thu, 28 Feb 2008 07:12:50 -0800 (PST),
grp62 <gr...@yahoo.fr> wrote:

>On my target (kernel-2.6.23) when i tried to execute the following
>commands
>
>set serial [open /dev/ttyS0 RDWR]
>fconfigure $serial -mode "115200,n,8,1"
>
>here's the message i get:
>
> bad option "-mode": should be one of -blocking, -buffering, -

Is it possible that /dev/ttyS0 is not truly an
asynchronous serial device?
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan...@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.

Ralf Fassel

unread,
Feb 28, 2008, 1:45:56 PM2/28/08
to
* grp62 <gr...@yahoo.fr>

| bad option "-mode": should be one of -blocking, -buffering, -
| buffersize, -encoding, -eofchar, or -
| translation
| while
| executing
| "fconfigure $serial -mode "115200,n,8,1" "

That sounds like TCL did not recognize /dev/ttyS0 as a serial port but
as a 'real' file. Can you confirm that /dev/ttyS0 is indeed the
correct pathname to the port on that platform?

R'

Rolf Schroedter

unread,
Feb 29, 2008, 5:24:42 AM2/29/08
to

If I recall correctly, there are Linux distribution with incorrectly
configured Tcl.
You should try to recompile Tcl.

grp62

unread,
Feb 29, 2008, 5:31:24 AM2/29/08
to

Yes i confirm /dev/ttyS0 is the correct pathname to the serial port of
my target.
If i issue the same commands on my host (ubuntu), it works !
Thanks in advance

grp62

unread,
Feb 29, 2008, 5:33:04 AM2/29/08
to
On 28 fév, 18:40, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
wrote:

> On Thu, 28 Feb 2008 07:12:50 -0800 (PST),
>
> grp62 <gr...@yahoo.fr> wrote:
> >On my target (kernel-2.6.23) when i tried to execute the following
> >commands
>
> >set serial [open /dev/ttyS0 RDWR]
> >fconfigure $serial -mode "115200,n,8,1"
>
> >here's the message i get:
>
> > bad option "-mode": should be one of -blocking, -buffering, -
>
> Is it possible that /dev/ttyS0 is not truly an
> asynchronous serial device?
> --
> Jonathan Bromley, Consultant
>
> DOULOS - Developing Design Know-how
> VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
>
> Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
> jonathan.brom...@MYCOMPANY.comhttp://www.MYCOMPANY.com

>
> The contents of this message may contain personal views which
> are not the views of Doulos Ltd., unless specifically stated.

What do you mean by that ?

Ralf Fassel

unread,
Feb 29, 2008, 10:19:30 AM2/29/08
to
* grp62 <gr...@yahoo.fr>

| > That sounds like TCL did not recognize /dev/ttyS0 as a serial port but
| > as a 'real' file. Can you confirm that /dev/ttyS0 is indeed the
| > correct pathname to the port on that platform?
|
| Yes i confirm /dev/ttyS0 is the correct pathname to the serial port
| of my target.

Well, then... However, if you open /dev/ttyS0 in tcl, and then do an
fconfigure on the fd, and you don't see the -mode in the response,
this tells you that TCL is not seeing /dev/ttyS0 as a serial device:

fconfigure [open /tmp/xxx w+]
=> -blocking 1 -buffering full -buffersize 4096 -encoding iso8859-1 \
-eofchar {{} {}} -translation {auto lf}

fconfigure [open /dev/ttyS0 w+]
=> -blocking 1 -buffering full -buffersize 4096 -encoding iso8859-1 \
-eofchar {{} {}} -translation {auto crlf} \
-mode 9600,n,8,1 -xchar {^Q ^S}

Someone else pointed out that maybe it is worth to recompile TCL
yourself for that platform in question.



| If i issue the same commands on my host (ubuntu), it works !

This does not tell you anything about whether /dev/ttyS0 is the
correct path on your ARM platform.

R'

Eric Hassold

unread,
Mar 1, 2008, 7:25:45 AM3/1/08
to
grp62 a écrit :

Hi,

If -mode configure option is missing, it means isatty() system call on
file descriptor for this channel failed to report it as a TTY. This may
occur either if the kernel driver is failing to report itself as a TTY
(some broken/partial implementation of serial drivers on embedded
systems have this problem), or if Tcl is wrongly configured (especially
when cross-compiling, since configure script may fails to set
USE_TERMIOS, etc... correctly).

If you want to try another Tcl binary for your arm-linux system, so you
can test if problem comes from kernel driver or Tcl/libc, eTcl binary
for arm-linux is a standalone, statically linked executable which should
run on your platform as is, by simply copying it anywhere on your
filesystem.

http://www.evolane.com/software/etcl/index.html
http://www.evolane.com/download/etcl/linux/etcl-1.0-rc25-linux-arm.tar.gz
http://www.evolane.com/download/etcl/linux/etcl-1.0-rc25-linux-arm-all.tar.gz

Next release (coming very soon) will include Tcl only (no Tk) binaries
for embedded linux targets, so binary will be much smaller (current
binaries are linked with libX11, ... statically too).

Eric

grp62

unread,
Mar 4, 2008, 3:04:46 AM3/4/08
to
hi,
Thank you very much for all these informations.
I'll try to investigate in order to see where does the problem come
from.
In the meantine, i'll try etcl.
Thanks
greg

> http://www.evolane.com/software/etcl/index.htmlhttp://www.evolane.com/download/etcl/linux/etcl-1.0-rc25-linux-arm.ta...http://www.evolane.com/download/etcl/linux/etcl-1.0-rc25-linux-arm-al...

0 new messages