Solaris 1.1 - can't set serial port characteristics??

Solaris 1.1 - can't set serial port characteristics??

Post by Jon Arno » Sat, 16 Oct 1993 20:56:19



I'm a little bit new to unix, but this problem seems to have everyone stumped,
including our local Sun tech rep.  If any of you have encountered this before
and know of a solution, please email me.  The bottom lineis that we would
*like* to be able to have the serial port characteristicsset before the
program starts, since the code within the program thatuses the specific
runtime can't set the characteristics as documentedin the runtime
documentation.  (It's *supposed* to be able to do it,but the Solaris 1.1
implementation of this runtime apparently has somebugs and it does not do it).

Solaris 1.1 on a Sparc Classic.  It's got two serial ports on the
cpu box (ttya and ttyb), and also has an 8-port mux which make up
ttyz01-08.  The system default for serial ports is 9600-8N1.  All the
ports have "off" in their etc/ttytab file setting.  All applications
work fine for the applications where data is *outbound only* (ie,
nothing coming back into the cpu from the port), presumably because
the applications require 9600-8N1 (the default).

The reason that the ports need to have "off" in their etc/ttytab
status setting is because the application is using these ports to talk
to external devices.  If the status is "on", then getty grabs the
port as soon as data starts to come in thru the port, and gallantly
throws out a logon banner.  Don't want/need getty for this.  But even
so, as long as the data from the Sun to the external device is only
going *to* the device with nothing coming back, it appears to make
no difference whether this flag is on or off.  It appears that getty
only gets involved when something comes *in* thru the port.

One application in particular requires 19200-7E1.  Apparently no
can do.  If you set the characteristics with stty, they "appear" to
be applied, but the millisecond that the application accesses the
port, it reverts back to 9600-8N1.  The application runtime release
notes suggest that one should start a line like (trying to remember
it from memory):

(stty 9600 cs7 parenb -parodd; do ;: sleep 3600 ;: done)</dev/ttyz01&

(that's pretty close).  Supposedly, this runs in background and keeps
resetting the port to those characteristics.  But even after starting
this loop (and according to a 'vp stty', it's running), you can go to
another window and do a 'stty -a</dev/ttyz01' and see that the char-
acteristics are not that way!?  It says to put this statement in one
of the startup rc files, but although it seems to be running, looking
at the port characteristics from another window with stty -a shows
that the command is having no effect.

The runtime documentation also suggests (another way to solve the same
problem) is to add 'port characteristic modifiers' to the device open
statement in the application, but that has no effect. However, while
the documentation says that this is an 'acknowledged unix problem for
any unix application', and that both of these workarounds have been
'successfully tested on various flavors of unix', they do not claim that
it has been specifically tested under Solaris 1.1.  Methinks that
perhaps therein lies the kicker.

One workaround that will [presumably] work is to have the application
program itself call an ioctl routine and set the characteristics for
the port.  But is there any way to have those port characteristics set
*before* the program starts running, and avoid having to change any
of the program code?  Any ideas or suggestions welcomed.

Jon

----------------------------------------------------------------------------
Jon Arnold          newcomer to Melbourne, Florida      
      "If you ain't the lead dog, the view never changes."

Disclaimer: The views & opinions expressed here are my own, and have no
necessary relevancy to the views & opinions of my employer.
----------------------------------------------------------------------------

 
 
 

Solaris 1.1 - can't set serial port characteristics??

Post by Lupe Christo » Mon, 18 Oct 1993 04:52:38



>I'm a little bit new to unix, but this problem seems to have everyone stumped,
>including our local Sun tech rep.

Is he new to Unix, too? :-)

Quote:>If any of you have encountered this before
>and know of a solution, please email me.  The bottom lineis that we would
>*like* to be able to have the serial port characteristicsset before the
>program starts, since the code within the program thatuses the specific
>runtime can't set the characteristics as documentedin the runtime
>documentation.  (It's *supposed* to be able to do it,but the Solaris 1.1
>implementation of this runtime apparently has somebugs and it does not do it).

I have not seen bugs in this part of SunOS *ever* (not saying there were none
at any point in time, but that code is quite solid). Can you supply details?

... deleted ...

Quote:>The reason that the ports need to have "off" in their etc/ttytab
>status setting is because the application is using these ports to talk
>to external devices.  If the status is "on", then getty grabs the
>port as soon as data starts to come in thru the port, and gallantly
>throws out a logon banner.  Don't want/need getty for this.  But even
>so, as long as the data from the Sun to the external device is only
>going *to* the device with nothing coming back, it appears to make
>no difference whether this flag is on or off.  It appears that getty
>only gets involved when something comes *in* thru the port.

Not quite right: getty will change a few of the settings. I'm not sure
about which, but you might see different behaviour when you send a
CR or an LF.

Quote:>One application in particular requires 19200-7E1.  Apparently no
>can do.  If you set the characteristics with stty, they "appear" to
>be applied, but the millisecond that the application accesses the
>port, it reverts back to 9600-8N1.

This is because the driver resets the port settings on each first open.
(When the STREAMS stack is created.)

Quote:>The application runtime release
>notes suggest that one should start a line like (trying to remember
>it from memory):
>(stty 9600 cs7 parenb -parodd; do ;: sleep 3600 ;: done)</dev/ttyz01&

Pretty crude if the application changes the settings itself. Better do this:

        sleep 999999999 > /dev/ttyz01 &
        stty 9600 cs7 parenb -parodd > /dev/ttyz01

The first mistak your "application runtime release notes" make is
that SunOS 4.1.3 (Sol1.1) behaves like a SysV. It doesn't. This is
a Bezerkeley system with Version 7 behaviour: stty uses *stdout*
rather than stdin for the settings. Output is written to stderr rather
than stdout. The above statement changes your *controlling tty*.
You probably were not on a modem line or a directly connected
terminal but on the "*" console or in OpenWindows. Otherwise
you would have noticed :-)

Quote:>(that's pretty close).  Supposedly, this runs in background and keeps
>resetting the port to those characteristics.  But even after starting
>this loop (and according to a 'vp stty', it's running), you can go to
>another window and do a 'stty -a</dev/ttyz01' and see that the char-
>acteristics are not that way!?  It says to put this statement in one
>of the startup rc files, but although it seems to be running, looking
>at the port characteristics from another window with stty -a shows
>that the command is having no effect.

Again, the '<' should be a '>'. In another window you see the
characteristics of that windows rather than those of the port.

Quote:>The runtime documentation also suggests (another way to solve the same
>problem) is to add 'port characteristic modifiers' to the device open
>statement in the application, but that has no effect. However, while
>the documentation says that this is an 'acknowledged unix problem for
>any unix application', and that both of these workarounds have been
>'successfully tested on various flavors of unix', they do not claim that
>it has been specifically tested under Solaris 1.1.  Methinks that
>perhaps therein lies the kicker.

Sure. Those people were clueless about stty on SunOS 4.1.3. BTW, SunOS 5.x
changes this to the behaviour you used! (It's SVR4...)

As for the "acknowledged unix problem", this is an acknowledgement of
ignorance. There is only so much variation of the interfaces various Unixes
use. If you look, e.g. at Taylor uucp, you find exactly three flavours
of interfaces: sgtty, termio, POSIX termios.

Quote:>One workaround that will [presumably] work is to have the application
>program itself call an ioctl routine and set the characteristics for
>the port.  But is there any way to have those port characteristics set
>*before* the program starts running, and avoid having to change any
>of the program code?  Any ideas or suggestions welcomed.

I'd rather change the program. But if you are not familiar with the
type of interface, it's probably easier for you to use the sleep/stty
I proposed above.
--

| ...!unido!ukw!lupe        (company, German EUNet)  | This is an unofficial  |
| suninfo!alanya!lupe       (via Sun Germany)        | opinion of Christoph & |
| Non sunt multiplicanda entia praeter necessitatem. | Imschweiler Consulting |

 
 
 

Solaris 1.1 - can't set serial port characteristics??

Post by Guy Harr » Mon, 18 Oct 1993 07:45:34


Quote:>This is because the driver resets the port settings on each first open.
>(When the STREAMS stack is created.)

You might want to point out that this predates STREAMS, and that "first
open" isn't just the first open after a reboot, it's the first open
after a reboot *or* after the last close of the device.

I.e., it's a long-standing UNIX tradition, for better or worse, that
when a not-currently-open tty is opened, its tty settings get reset to
their defaults.

 
 
 

1. Serial port printing Solaris 1.1.1b

Hi,

I need to know how to set up a printer using the serial ports on a
Sparcstation20 (yes I've got a splitter..) using Solaris 1.1.1b (SunOS
4.1.3).

Bascially, do I just need to edit the printcap file a make entries
there for each printer on each port ? If so can anyone suggest default
settings for Epson 9pin printer 9600 baud rate ?

I realise that there's alot of options to include in the printcap file,
but any suggestions would be useful.

If it's more complicated than adding a definition to the 'printcap'
file then please let me know the commands and procedure to follow...

Sorry if this is a silly, question, I'm just not sure where to look.

Replies by email if possible...

--
Andy

'Skippy Lives'

2. Not Networking

3. Serial Ports on a SPARC10 running Solaris 1.1

4. problems with pcnfs deamon

5. serial port characteristics

6. TclTk killed my X-server

7. Serial ports on 1.0/1.1

8. Wake Up Frame, how to send?

9. Setting inbound async port characteristics.

10. help needed: serial port overflows under NetBSD 1.1

11. HELP - Need The Solaris 2.3 equivalent of Solaris 1.1's "bar"

12. Porting `gopher' 1.1 client to AIX 3.2

13. Can't set serial port!!!!