Re: rs232 tcl

From: Rolf Schroedter (me_at_privacy.net)
Date: 06/15/04


Date: Tue, 15 Jun 2004 16:17:14 +0200

Hmm, the problem with your question is that you are not setting all bits
    of the tio flags, but you are taking the current settings and reset
some flags. Tcl's defaults are:
        iostate.c_iflag = IGNBRK;
        iostate.c_oflag = 0;
        iostate.c_lflag = 0;
        iostate.c_cflag |= CREAD;
        iostate.c_cc[VMIN] = 1;
        iostate.c_cc[VTIME] = 0;

Ok, let me guess:

Michael Schuster wrote:
> Hi,
> I'm running tcl with linux and want to open a rs232 - com with
> the same settings as with my c-progs.
> How do I open e.g. /dev/ttyS55 with the settings:
> tio.c_lflag &=~ (ECHO|ICANON|ISIG|IEXTEN);

That looks like you are selecting raw input.
Okay, that's Tcl's way to work with serial ports.
I would additionally recommend to
        fconfigure $serial -translation binary
after opening the port.

> tio.c_iflag &=~ (ICRNL|BRKINT|IXON|ISTRIP|INPCK);

Again that's raw input, no character mapping, no break, no XON.
But, is there any secret, why you e.g. switch off IXON,
but don't touch IXOFF,IXANY ?
Why do you disable BRKINT but don't touch IGNBRK ?
Probably it works, because these flags aren't set,
but it seems to me that Tcl is more straight:
        iostate.c_iflag = IGNBRK;

> tio.c_cflag &= ~(CSIZE| PARENB);
> tio.c_cflag = CS8 |CREAD| CLOCAL;

Disable parity, enable 8 bit char's, enable receiver
Okay that's typically done with
        fconfigure $chan -mode bbbb,n,8,s
where bbbb=baud rate (you should know your baud rate)
and s=stop bits (you don't touch this but you should know).

> tio.c_oflag &= ~(OPOST);

That's raw output. That's what Tcl does. But again you probably want
no CRLF processing by Tcl's channel system:
        fconfigure $serial -translation binary

> tio.c_cc[VMIN]=1;
> tio.c_cc[VTIME]=0;

That's Tcl's default, unless you do a
        fconfigure $chan -timeout

> in tcl?
> Any help is welcome. Thanks in advance
> Michael

IMO everything looks fine, you should have no trouble to communicate.
I guess the problem is that you do not know your baudrate & stop bit
settings. Are you using some system defaults ?

Regards,
Rolf.

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

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



Relevant Pages

  • Re: DDK build result different from VS result
    ... The only flags of interest with respect to ... > built using the standard settings from the ddk. ... that now go entirely into the sources file. ...
    (microsoft.public.development.device.drivers)
  • Restore my flags (and PATH)!
    ... The simplest program I know of for restoring flag settings ... while also retaining the originally saved settings ... If I change some settings (flags and/or current directory) ... to automatically restore those flags after a RESTORE). ...
    (comp.sys.hp48)
  • Re: HP38/39: How to set DEG mode?
    ... they are linked to an applet, so each applet have their own flags and settings. ... If you do what you suggest, it will only switch the settings temporarily, if you ever suspend your aplet to run a calculation in the HOME screen for example, your settings will be lost. ... you need to change the settings as you describe (playing with the system flags) or using the supported entry SetSysAngle but you also need to set it up in your aplet structure. ...
    (comp.sys.hp48)
  • Re: HP38/39: How to set DEG mode?
    ... > they are linked to an applet, so each applet have their own flags and ... > If you do what you suggest, it will only switch the settings ... to TOL, because I like well-done work, but I have no documentation. ...
    (comp.sys.hp48)