All of lore.kernel.org
 help / color / mirror / Atom feed
* serial: custom baud rate
@ 2018-05-03 12:59 Muni Sekhar
  0 siblings, 0 replies; 9+ messages in thread
From: Muni Sekhar @ 2018-05-03 12:59 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

>From include/asm-generic/termbits.h , I see baudrate can be one of the
standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000,
576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000,
3500000, 4000000.


If I need to set a custom baud rates(e.g. 14400, 128000, 256000), does
Linux serial framework has any supporting method?

-- 
Thanks,
Sekhar

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: serial: custom baud rate
  2018-05-03 17:54 ` Theodore Y. Ts'o
  2018-05-04  9:04   ` Muni Sekhar
@ 2018-05-14 17:24   ` Andy Shevchenko
  1 sibling, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2018-05-14 17:24 UTC (permalink / raw)
  To: Theodore Y. Ts'o, Muni Sekhar, linux-serial,
	Linux Kernel Mailing List

On Thu, May 3, 2018 at 8:54 PM, Theodore Y. Ts'o <tytso@mit.edu> wrote:
> On Thu, May 03, 2018 at 06:09:13PM +0530, Muni Sekhar wrote:

> See the setserial man page:t
>
>         https://linux.die.net/man/8/setserial
>
> Not all serial devices support the spd_cust and divisor, however.  In
> general

Oh, please, do not advertise this old hack.

We have BOTHER that what people should use in new code.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: serial: custom baud rate
  2018-05-13 19:57   ` Alan Cox
@ 2018-05-14 15:36     ` Grant Edwards
  0 siblings, 0 replies; 9+ messages in thread
From: Grant Edwards @ 2018-05-14 15:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-serial

On 2018-05-13, Alan Cox <gnomes@lxorguk.ukuu.org.uk> wrote:
> On Thu, 3 May 2018 18:27:14 +0000 (UTC)
> Grant Edwards <grant.b.edwards@gmail.com> wrote:
>
>> On 2018-05-03, Muni Sekhar <munisekharrms@gmail.com> wrote:
>> 
>> > If I need to set a custom baud rates(e.g. 14400, 128000, 256000), does
>> > Linux serial framework has any supporting method?  
>> 
>> Sure, use the termios2 structure instead of the termios structure:
>> 
>>   #include <linux/termios.h>
>> 
>>   struct termios2 t;
>> 
>>   ioctl(fd, TCGETS2, &t)
>> 
>>   t.c_cflag &= ~CBAUD;
>>   t.c_cflag |= BOTHER;
>>   t.c_ispeed = baud;
>>   t.c_ospeed = baud;
>> 
>>   ioctl(fd, TCSETS2, &t)
>> 
>> [Not all devices/drivers support termios2]
>
> That shouldn't be true - all devices get passed ispeed/ospeed and
> everything in tree was using the correct fields as far as I could
> tell last time I checked this

Yep, my mistake.  It looks like the driver where I last ran into this
was an old out-of-tree driver.

-- 
Grant Edwards               grant.b.edwards        Yow! Mary Tyler Moore's
                                  at               SEVENTH HUSBAND is wearing
                              gmail.com            my DACRON TANK TOP in a
                                                   cheap hotel in HONOLULU!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: serial: custom baud rate
  2018-05-03 18:27 ` Grant Edwards
@ 2018-05-13 19:57   ` Alan Cox
  2018-05-14 15:36     ` Grant Edwards
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Cox @ 2018-05-13 19:57 UTC (permalink / raw)
  To: Grant Edwards; +Cc: linux-kernel, linux-serial

On Thu, 3 May 2018 18:27:14 +0000 (UTC)
Grant Edwards <grant.b.edwards@gmail.com> wrote:

> On 2018-05-03, Muni Sekhar <munisekharrms@gmail.com> wrote:
> 
> > If I need to set a custom baud rates(e.g. 14400, 128000, 256000), does
> > Linux serial framework has any supporting method?  
> 
> Sure, use the termios2 structure instead of the termios structure:
> 
>   #include <linux/termios.h>
> 
>   struct termios2 t;
> 
>   ioctl(fd, TCGETS2, &t)
> 
>   t.c_cflag &= ~CBAUD;
>   t.c_cflag |= BOTHER;
>   t.c_ispeed = baud;
>   t.c_ospeed = baud;
> 
>   ioctl(fd, TCSETS2, &t)
> 
> [Not all devices/drivers support termios2]

That shouldn't be true - all devices get passed ispeed/ospeed and
everything in tree was using the correct fields as far as I could tell
last time I checked this

Alan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: serial: custom baud rate
  2018-05-04  9:04   ` Muni Sekhar
@ 2018-05-04 13:59     ` Theodore Y. Ts'o
  0 siblings, 0 replies; 9+ messages in thread
From: Theodore Y. Ts'o @ 2018-05-04 13:59 UTC (permalink / raw)
  To: Muni Sekhar; +Cc: linux-serial, linux-kernel

On Fri, May 04, 2018 at 02:34:51PM +0530, Muni Sekhar wrote:
> > See the setserial man page:t
> >
> >         https://linux.die.net/man/8/setserial
> >
> > Not all serial devices support the spd_cust and divisor, however.  In
> > general, only devices where the kernel directly programs the
> > 8250/16450/16550 UART directly will support this feature.
> >
> So custom baud's can be set via TIOCSSERIAL IOCtl in kernel mode?

ioctl's are in general designed for use in userspace.  So are the
termios interface.

					- Ted

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: serial: custom baud rate
  2018-05-03 17:54 ` Theodore Y. Ts'o
@ 2018-05-04  9:04   ` Muni Sekhar
  2018-05-04 13:59     ` Theodore Y. Ts'o
  2018-05-14 17:24   ` Andy Shevchenko
  1 sibling, 1 reply; 9+ messages in thread
From: Muni Sekhar @ 2018-05-04  9:04 UTC (permalink / raw)
  To: Theodore Y. Ts'o, Muni Sekhar, linux-serial, linux-kernel

On Thu, May 3, 2018 at 11:24 PM, Theodore Y. Ts'o <tytso@mit.edu> wrote:
> On Thu, May 03, 2018 at 06:09:13PM +0530, Muni Sekhar wrote:
>> Hi All,
>>
>> From include/asm-generic/termbits.h , I see baudrate can be one of the
>> standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
>> 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000,
>> 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000,
>> 3500000, 4000000.
>>
>> If I need to set a custom baud rates(e.g. 14400, 128000, 256000), does
>> Linux serial framework has any supporting method?
>
> See the setserial man page:t
>
>         https://linux.die.net/man/8/setserial
>
> Not all serial devices support the spd_cust and divisor, however.  In
> general, only devices where the kernel directly programs the
> 8250/16450/16550 UART directly will support this feature.
>
So custom baud's can be set via TIOCSSERIAL IOCtl in kernel mode?
>                                                         - Ted



-- 
Thanks,
Sekhar

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: serial: custom baud rate
  2018-05-03 12:39 Muni Sekhar
  2018-05-03 17:54 ` Theodore Y. Ts'o
@ 2018-05-03 18:27 ` Grant Edwards
  2018-05-13 19:57   ` Alan Cox
  1 sibling, 1 reply; 9+ messages in thread
From: Grant Edwards @ 2018-05-03 18:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-serial

On 2018-05-03, Muni Sekhar <munisekharrms@gmail.com> wrote:

> If I need to set a custom baud rates(e.g. 14400, 128000, 256000), does
> Linux serial framework has any supporting method?

Sure, use the termios2 structure instead of the termios structure:

  #include <linux/termios.h>

  struct termios2 t;

  ioctl(fd, TCGETS2, &t)

  t.c_cflag &= ~CBAUD;
  t.c_cflag |= BOTHER;
  t.c_ispeed = baud;
  t.c_ospeed = baud;

  ioctl(fd, TCSETS2, &t)

[Not all devices/drivers support termios2]

-- 
Grant Edwards               grant.b.edwards        Yow! Are we live or on
                                  at               tape?
                              gmail.com            

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: serial: custom baud rate
  2018-05-03 12:39 Muni Sekhar
@ 2018-05-03 17:54 ` Theodore Y. Ts'o
  2018-05-04  9:04   ` Muni Sekhar
  2018-05-14 17:24   ` Andy Shevchenko
  2018-05-03 18:27 ` Grant Edwards
  1 sibling, 2 replies; 9+ messages in thread
From: Theodore Y. Ts'o @ 2018-05-03 17:54 UTC (permalink / raw)
  To: Muni Sekhar; +Cc: linux-serial, linux-kernel

On Thu, May 03, 2018 at 06:09:13PM +0530, Muni Sekhar wrote:
> Hi All,
> 
> From include/asm-generic/termbits.h , I see baudrate can be one of the
> standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
> 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000,
> 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000,
> 3500000, 4000000.
> 
> If I need to set a custom baud rates(e.g. 14400, 128000, 256000), does
> Linux serial framework has any supporting method?

See the setserial man page:t

	https://linux.die.net/man/8/setserial

Not all serial devices support the spd_cust and divisor, however.  In
general, only devices where the kernel directly programs the
8250/16450/16550 UART directly will support this feature.

							- Ted

^ permalink raw reply	[flat|nested] 9+ messages in thread

* serial: custom baud rate
@ 2018-05-03 12:39 Muni Sekhar
  2018-05-03 17:54 ` Theodore Y. Ts'o
  2018-05-03 18:27 ` Grant Edwards
  0 siblings, 2 replies; 9+ messages in thread
From: Muni Sekhar @ 2018-05-03 12:39 UTC (permalink / raw)
  To: linux-serial, linux-kernel

Hi All,

>From include/asm-generic/termbits.h , I see baudrate can be one of the
standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000,
576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000,
3500000, 4000000.


If I need to set a custom baud rates(e.g. 14400, 128000, 256000), does
Linux serial framework has any supporting method?



-- 
Thanks,
Sekhar

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-05-14 17:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 12:59 serial: custom baud rate Muni Sekhar
  -- strict thread matches above, loose matches on Subject: below --
2018-05-03 12:39 Muni Sekhar
2018-05-03 17:54 ` Theodore Y. Ts'o
2018-05-04  9:04   ` Muni Sekhar
2018-05-04 13:59     ` Theodore Y. Ts'o
2018-05-14 17:24   ` Andy Shevchenko
2018-05-03 18:27 ` Grant Edwards
2018-05-13 19:57   ` Alan Cox
2018-05-14 15:36     ` Grant Edwards

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.