/ Forside / Teknologi / Udvikling / C/C++ / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
C/C++
#NavnPoint
BertelBra.. 2425
pmbruun 695
Master_of.. 501
jdjespers.. 500
kyllekylle 500
Bech_bb 500
scootergr.. 300
gibson 300
molokyle 287
10  strarup 270
RS232 programming
Fra : Ryan Cassel


Dato : 24-10-01 19:43

Under Linux, I just want to configure my port in 115200 baud with one
start and stop bit, and no parity in a C program. I've tried "ioctl" but
i didn't sucess to find the signification of flags. I try "termios" but
it's the same thing i can't find the flags corresponding at start and
stop bit...

Some one can tell me how can i do to configure my serial port to 115200
bauds one start stop bit with no parity.

thanks


 
 
Kent Friis (24-10-2001)
Kommentar
Fra : Kent Friis


Dato : 24-10-01 20:59

Den Wed, 24 Oct 2001 20:42:32 +0200 skrev Ryan Cassel:
>Under Linux, I just want to configure my port in 115200 baud with one
>start and stop bit, and no parity in a C program. I've tried "ioctl" but
>i didn't sucess to find the signification of flags. I try "termios" but
>it's the same thing i can't find the flags corresponding at start and
>stop bit...

Start bit:
AFAIK RS323 always uses one start bit.

Stop bit:

According to termios(3):

struct termios t;
t.c_cflag &= ~CSTOPB; /* zero the CSTOPB bit */

if the CSTOPB bit is 0, one stop bit is used. if this bit is 1, two
stop bits are used.

Mvh
Kent
--
War does not determine who is right, only who is left.

N/A (24-10-2001)
Kommentar
Fra : N/A


Dato : 24-10-01 22:07



Ryan Cassel (24-10-2001)
Kommentar
Fra : Ryan Cassel


Dato : 24-10-01 22:07

thanks but what is AFAIK ? ...

I want to use a 7 bit word do I use CS7 flag like that :

struct termios t;
t.c_cflag &= ~CSTOPB | CS7;

Kent Friis a écrit :

> Den Wed, 24 Oct 2001 20:42:32 +0200 skrev Ryan Cassel:
> >Under Linux, I just want to configure my port in 115200 baud with one
> >start and stop bit, and no parity in a C program. I've tried "ioctl" but
> >i didn't sucess to find the signification of flags. I try "termios" but
> >it's the same thing i can't find the flags corresponding at start and
> >stop bit...
>
> Start bit:
> AFAIK RS323 always uses one start bit.
>
> Stop bit:
>
> According to termios(3):
>
> struct termios t;
> t.c_cflag &= ~CSTOPB; /* zero the CSTOPB bit */
>
> if the CSTOPB bit is 0, one stop bit is used. if this bit is 1, two
> stop bits are used.
>
> Mvh
> Kent
> --
> War does not determine who is right, only who is left.


Kent Friis (25-10-2001)
Kommentar
Fra : Kent Friis


Dato : 25-10-01 16:07

Den Wed, 24 Oct 2001 23:06:36 +0200 skrev Ryan Cassel:
>thanks but what is AFAIK ? ...

As Far As I Know.
^ ^ ^ ^ ^
>I want to use a 7 bit word do I use CS7 flag like that :
>
>struct termios t;
>t.c_cflag &= ~CSTOPB | CS7;

Er, no.

The &= ~ is to clear the bit. You'll want to:

t.c_cflag &= ~CSTOPB;
t.c_cflag |= CS7;

If you build your termios from scratch (starting with every bit zero -
always a good idea, you never know who used the serial port last),
you'll want to do this instead:

t.c_cflag = CS7 | any | other | bit | you | want | to | set;

>Kent Friis a écrit :

French? You could try news:fr.comp.lang.c or fr.comp.os.linux

Mvh
Kent
--
War does not determine who is right, only who is left.

Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408925
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste