Help using termios

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • goblin

    Help using termios

    Hi all

    I'm struggeling to get my serial port settings changed using termios.
    I can change the baud rate fine, but none of the control flags respond
    to my changes. As an example:

    #include <stdio.h>
    #Iinclude <termios.h>

    int main (void) {
    struct termios settings;
    FILE* pPort;

    if (!(pPort = fopen("/dev/ttyUSB0","r+")) ) {
    printf("Oops0\n ");
    return 1;
    }

    if (tcgetattr(file no(pPort), &settings) != 0) printf("Oops1\n ");
    cfsetispeed(&se ttings, B9600);
    cfsetospeed(&se ttings, B9600);
    settings.c_ifla g |= CSTOPB;
    if (tcsetattr(file no(pPort), TCSANOW, &settings) != 0)
    printf("Oops2\n ");

    fclose(pPort);
    }

    This will change the current baud rate to the selected 9600, but the
    will not set two stop bits as I think it should. What am I doing wrong
    here?

    Any help would be sincerely appreciated.

    Piet
  • Pietro Cerutti

    #2
    Re: Help using termios

    goblin wrote:
    Hi all
    >
    I'm struggeling to get my serial port settings changed using termios.
    I can change the baud rate fine, but none of the control flags respond
    to my changes.
    Termios is not part of the C standard, it's SUS2.

    You will find more useful answers in comp.unix.progr ammer.

    --
    Pietro Cerutti

    Comment

    • goblin

      #3
      Re: Help using termios

      Thank you for pointing me to the correct newsgroup. I have reposted
      there.

      Comment

      • Antoninus Twink

        #4
        Re: Help using termios

        On 22 May 2008 at 13:23, goblin wrote:
        I'm struggeling to get my serial port settings changed using termios.
        I can change the baud rate fine, but none of the control flags respond
        to my changes.
        [snip]
        settings.c_ifla g |= CSTOPB;
        You mean settings.c_cfla g (control settings, not input).

        Comment

        Working...