Messages in this thread | | | Date | Thu, 01 Oct 2009 17:34:12 -0300 | From | Breno Leitao <> | Subject | Re: [PATCH] jsm: fixing termios structure to be compatible with stty application |
| |
Alan Cox wrote: > NAK > > termios->c_ispeed/ospeed are the actual baud rates not bit encodings Well, c_flag & CBAUD is the baud rate encoded in the Bfoo format.
> Use > > tty_termios_encode_baudrate(termios, ispeed, ospeed);
Well, let me explain you what I want to do. Actually stty.c source code do:
tcsetattr (STDIN_FILENO, TCSADRAIN, &mode) tcgetattr (STDIN_FILENO, &new_mode) ... if (memcmp (&mode, &new_mode, sizeof (mode)) != 0) error (EXIT_FAILURE, 0,....)
When I run stty -F /dev/ttyn0 speed 9600, the mode structure is different from new_mode, causing that error. Debugging those structure, I found that ispeed and ospeed were not set in the Bfoo format, as expected, since mode->[o|i]speed are set in Bfoo format.
Hence, I just assigned ospeed and ispeed with the requested speed in Bfoo format (c_flag & CBAUD).
I also tested the tty_termios_encode_baud_rate(), and it will basically do what I did:
termios->c_ispeed = ibaud; termios->c_ospeed = obaud;
Thanks for the review, and sorry if I missed the point completely. Breno
| |