Home/Support/Support Forum/Which configuration I need to enable onlcr flag in a serial port?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Which configuration I need to enable onlcr flag in a serial port?

0 votes
I need to change the flag tab3 to onlcr on my serial port configuration.

Im using a PortServer TS16 to send signals with a software which have issues with tab3 option instead of onlcr option, and Im not able to set onlcr flag on my serial port.

I was using PORTS/8 em model previously and had no problem, in fact, I had not need to configure it, because automatically it was set on my serial port.

On PORTS/8, when I do from my terminal:

stty < /dev/ttyD5
speed 9600 baud; line = 0;
intr = ^?; eof = ^A; min = 1; time = 0;
-icrnl ixoff ixany -imaxbel
-icanon -iexten -echo -echoctl -echoke

In PortServer:
stty < /dev/ttyD5
speed 9600 baud; line = 0;
intr = M-^?; quit = M-^?; erase = ^H; eof = ^A; min = 1; time = 0;
-icrnl ixoff ixany -imaxbel
-icanon -iexten -echo -echoctl -echoke

In PortServer I am using RealPort Profile and in PORTS/8 this is the conf file:
board Digi_AccelePort_Xem_PCI
io 0x000
mem 0x000000
module ports
nports 8
id D
start 0
module ports
nports 8
id D
start 8
altpin 0
useintr 0

Thks for your help!
asked Oct 20, 2014 in Realport by samx New to the Community (0 points)

Please log in or register to answer this question.

2 Answers

0 votes
You can use ditty to set the port parameters on your Unix host:

# ditty onlcr ttyD5

Meanwhile, I see that ixany is activated on the ports, this is not recommended and should be turned off in favor of xoff:

# ditty -ixany ixoff ttyD5

The method to make the settings sticky (i.e. remain after port closure and reboots) varies by O.S. version. What Unix version are you running?

To see the full list of port parameter settings:

# ditty -a ttyD5

Also, keep in mind that if you have getty enabled on the port(s), it will over-ride these settings, so you will need to ensure the getty configuration (gettydefs) contains the desired settings.
answered Oct 20, 2014 by userid0 Veteran of the Digi Community (2,158 points)
Im using Debian Kernel 2.6.28 and an ibm3151 on ttyD5, Im not using getty.

Reading again my question I notice that I asked wrong the question: I didnt want to enable but to disable that parameter (onlcr), so after reading your post I tried with:

# ditty -onlcr ttyD5

The command:

# ditty -ixany ixoff ttyD5

works without problems, Ixany is disable and ixoff is enable, but with onlcr doesnt work:

# ditty -onlcr ttyD5
stty: entrada est�ndar: no se pudieron realizar todas las operaciones solicitadas

I tried disabling onlcr or tab3, wich are the unique differents parameters in the serial port conf, but any of them can be changed:

# ditty -tab3 /dev/ttyD5
stty: argumento inv�lido `-tab3'
Pruebe `stty --help' para m�s informaci�n.

Also I tried:

# ditty -tabs /dev/ttyD5

but tab3 is still enable:

# ditty -a /dev/ttyD5
onstr \033[5i offstr \033[4i term ansi
maxcps 100 maxchar 50 bufsize 100 edelay 100
-forcedcd -altpin -fastbaud (9600) -printer -rtstoggle
-rtspace -dtrpace -ctspace -dsrpace -dcdpace
DTR+  RTS+  CTS-  CD-  DSR-  RI-
startc = 0x11 stopc = 0x13
-aixon astartc = 0x0 astopc = 0x0
speed 9600 baud; rows 0; columns 0; line = 0;
intr = M-^?; quit = M-^?; erase = ^H; kill = ^U; eof = ^A; eol = <undef>;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff
-iuclc ixany -imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab3 bs0 vt0 ff0
isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl -echoke
0 votes
Since you are using RealPort, try specifiying the proper ditty:

ditty-rp -onlcr ttyD5

Confirm the change:

ditty-rp -a ttyD5

If you see that the value gets set, but ends up changing, you should check your application or process running on the port to ensure it is not changing this value. In other words, once the value is set using ditty-rp, the only way it can change is if something is coming in and over-writing it.
answered Oct 22, 2014 by userid0 Veteran of the Digi Community (2,158 points)
Thnks for your help, Im trying to follow your recommendation but is not working.

I reviewed the help for ditty-rp and I am seeing that does not have support for flag onlcr, thats the razon why the ditty-rp command go to call stty command:

$man ditty-rp
"...Any unrecognized options are passed to stty(1) for interpretation..."

So the result with ditty-rp command is the same I posted on the last comment:

# ditty-rp -onlcr ttyD5
stty: entrada est�ndar: no se pudieron realizar todas las operaciones solicitadas

Also I noticed that  ditty is a symbolic link to ditty-rp.

$ls -la ditty
lrwxrwxrwx    1 root     root           17 2014-09-17 13:07 ditty -> /usr/bin/ditty-rp

So far, the problem is weird because with the previous device I was using this issue does not happens. Now the enviroment is the same except the Digi device. The same software, the same terminal attached on ttyD5 (an ibm3151), the same Unix Host kernel (Debian Kernel 2.6.28), the only change is the Digi device, previously I had a PORTS/8em and now  that this models are discontinued, I am using PortServer TS16, so I think PortServer need a special configuration in RealPort to support that flag, because with Digi AccelePort Xem PCI (PORTS8em) I had not need to setup anything in the ttyD5 serial line.

This are the flags in my serial port with the same environment and differents Digi devices:

$ stty < /dev/ttyD5
speed 9600 baud; line = 0;
-icrnl ixoff ixany -imaxbel
-icanon -iexten -echo -echoctl -echoke

$ stty < /dev/ttyD5
speed 9600 baud; line = 0;
-icrnl ixoff ixany -imaxbel
-icanon -iexten -echo -echoctl -echoke

(with ditty -a ttyD5 command the result is the same but more larger, so I prefer stty for show purposes)
Im doing some tests and I did a C program to change that value, because ditty-rp and stty commands didnt disable onlcr and tab3 flags.

I probed the code in my local serial port attached to my Unix Host. This is the result:

Parameters before I run the code:
# stty -F /dev/ttyS0 -a
... opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab3 bs0 ...

Parameters after I run the code:
# stty -F /dev/ttyS0 -a
 ... opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 ...

Then I probed the code on the serial ports created by dgrp (Digi Device) with Real Port and I dont see any change....

This is my code:
#include <stdio.h>   /* Standard input/output definitions */
#include <string.h>  /* String function definitions */
#include <unistd.h>  /* UNIX standard function definitions */
#include <fcntl.h>   /* File control definitions */
#include <errno.h>   /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <stdlib.h>

int openport(void);
int connected;
struct termios options;

int main(int argc, char *argv[])
        int fd = openport();
         tcgetattr(fd, &options);

//    Disabling onlcr and tab3 flags
         options.c_oflag |= OPOST;
         options.c_oflag &= ~TAB3;
         options.c_oflag |= TAB0;
         options.c_oflag &= ~ONLCR;

//    Setting the parameters
         tcsetattr(fd, TCSAFLUSH, &options);
         printf("UART1 configured...\n");


int openport(void)
          int fd; /* File descriptor for the port */
          fd = open("/dev/ttyD9", O_RDWR | O_NOCTTY | O_NDELAY);
            if (fd == -1)
                perror("open_port: Unable to open /dev/ttyf1 - ");
                        fcntl(fd, F_SETFL, FNDELAY);
                        fcntl(fd, F_SETOWN, getpid());
          return (fd);

Any clues...???
You are correct in that onlcr is off by default.  This means that something is activating this setting on the port.  Start be looking for other processess running on the port.  Also, take a look on the PortServer itself to ensure the port profile is set to RealPort (rp) and that the onlcr setting is off.  From the root prompt of the PortServer:

#> set ports
#> set line

The dev setting under set ports should be set to "rp" and the onlcr setting under set line should be off (default).
I just tested this and was able to replicate it using stty.

# stty -onlcr < /dev/ttyD5
stty: standard input: unable to perform all requested operations

I do not know why this is happening, however I may have found a workaround (although not very elegant):

# stty raw < /dev/ttyD5
stty: standard input: unable to perform all requested operations

It still produces and error, however you can now deactivate onlcr:

# stty -onclr < /dev/ttyD5
I'm realizing that, to touch any of the output attributes in the serial line, it must be changed the OPOST flag.

For ONLCR , letter O stands for output parameters, in the same way, INLCR flag, letter I stands for Input parameters.

So the elegant manner is to change OPOST attribute:
stty -opost < /dev/ttyD5

Then change ONLCR flag.
stty -onclr < /dev/ttyD5

And the changes are done without problems!
Thkns a lot!
Thanks for the update!