How to setup 8E1 for a serial line - Unix

This is a discussion on How to setup 8E1 for a serial line - Unix ; Hi, If my serial line require one start bit, 8bits per byte, one stop bit and even parity, totally 11 bits for a character. How do I set fields in the termios struct? Thank you. - narke...

+ Reply to Thread
Results 1 to 5 of 5

Thread: How to setup 8E1 for a serial line

  1. How to setup 8E1 for a serial line

    Hi,

    If my serial line require one start bit, 8bits per byte, one stop bit
    and even parity, totally 11 bits for a character. How do I set fields
    in the termios struct? Thank you.

    -
    narke

  2. Re: How to setup 8E1 for a serial line

    On Jun 3, 11:36*pm, Steven Woody wrote:
    > Hi,
    >
    > If my serial line require one start bit, 8bits per byte, one stop bit
    > and even parity, totally 11 bits for a character. How do I set fields
    > in the termios struct? *Thank you.
    >
    > -
    > narke


    Even parity, one stop bit, and one start bit are the default. 8 bits
    per byte is implied by 'cfmakeraw', which you probably want anyway.
    Even parity is the default. To check parity on input, or INPCK into
    c_iflag and PARENB into c_oflag.

    DS

  3. Re: How to setup 8E1 for a serial line

    On Jun 4, 3:08 pm, David Schwartz wrote:
    > On Jun 3, 11:36 pm, Steven Woody wrote:
    >
    > > Hi,

    >
    > > If my serial line require one start bit, 8bits per byte, one stop bit
    > > and even parity, totally 11 bits for a character. How do I set fields
    > > in the termios struct? Thank you.

    >
    > > -
    > > narke

    >
    > Even parity, one stop bit, and one start bit are the default. 8 bits
    > per byte is implied by 'cfmakeraw', which you probably want anyway.
    > Even parity is the default. To check parity on input, or INPCK into
    > c_iflag and PARENB into c_oflag.
    >
    > DS


    really? from the tcsetattr man page, i get the code of cfmakeraw:

    01: termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK |
    ISTRIP
    02: | INLCR | IGNCR | ICRNL | IXON);
    03: termios_p->c_oflag &= ~OPOST;
    04: termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG |
    IEXTEN);
    05: termios_p->c_cflag &= ~(CSIZE | PARENB);
    06: termios_p->c_cflag |= CS8;

    In the line 05, I see PARENB is cleared, I think this means that
    parity check on input/output line is disabled. If so, I think
    cfmakeraw is 8N1 rather than 8E1 as you said. If I am wrong, would
    you please tell me how to set 8N1? Thanks.

    -
    narke

  4. Re: How to setup 8E1 for a serial line

    On Jun 4, 9:56*am, Steven Woody wrote:

    > really? * from the tcsetattr man page, i get the code of cfmakeraw:
    >
    > 01: * * * * * termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK|
    > ISTRIP
    > 02: * * * * * * * * * * * * * | INLCR | IGNCR | ICRNL | IXON);
    > 03: * * * * * termios_p->c_oflag &= ~OPOST;
    > 04: * * * * * termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON |ISIG |
    > IEXTEN);
    > 05: * * * * * termios_p->c_cflag &= ~(CSIZE | PARENB);
    > 06: * * * * * termios_p->c_cflag |= CS8;
    >
    > In the line 05, *I see PARENB is cleared, *I think this means that
    > parity check on input/output line is disabled. *If so, I think
    > cfmakeraw is 8N1 rather than 8E1 as you said. *If I am wrong, would
    > you please tell me how to set 8N1? Thanks.


    Whether or not the parity is checked has nothing to do with whether
    the parity would be even or odd if it was enforced. Even parity is the
    default, as opposed to odd parity. I didn't say the default was to
    generate or enforce it.

    DS

  5. Re: How to setup 8E1 for a serial line

    On Jun 5, 7:36 am, David Schwartz wrote:
    > On Jun 4, 9:56 am, Steven Woody wrote:
    >
    > > really? from the tcsetattr man page, i get the code of cfmakeraw:

    >
    > > 01: termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK |
    > > ISTRIP
    > > 02: | INLCR | IGNCR | ICRNL | IXON);
    > > 03: termios_p->c_oflag &= ~OPOST;
    > > 04: termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG |
    > > IEXTEN);
    > > 05: termios_p->c_cflag &= ~(CSIZE | PARENB);
    > > 06: termios_p->c_cflag |= CS8;

    >
    > > In the line 05, I see PARENB is cleared, I think this means that
    > > parity check on input/output line is disabled. If so, I think
    > > cfmakeraw is 8N1 rather than 8E1 as you said. If I am wrong, would
    > > you please tell me how to set 8N1? Thanks.

    >
    > Whether or not the parity is checked has nothing to do with whether
    > the parity would be even or odd if it was enforced. Even parity is the
    > default, as opposed to odd parity. I didn't say the default was to
    > generate or enforce it.
    >
    > DS


    For 8E1, one character is 11bits, so there is a parity bit within each
    11bit, am I right? According to the man page, ~PARENB means no
    parity generation on output. So when a character was sent, how can
    it be 11bit ?

    And, I am not so clear the difference of what you said 'generation'
    and 'enforce', can you explain? Thanks.

    If you can give the side by side termios fields comparation for 8E1
    and 8N1, I think I can better understand. Would you? Thanks in
    advance.

    -
    narke

+ Reply to Thread