From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751986AbeEMT5a (ORCPT ); Sun, 13 May 2018 15:57:30 -0400 Received: from www.llwyncelyn.cymru ([82.70.14.225]:52936 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751295AbeEMT52 (ORCPT ); Sun, 13 May 2018 15:57:28 -0400 Date: Sun, 13 May 2018 20:57:26 +0100 From: Alan Cox To: Grant Edwards Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: serial: custom baud rate Message-ID: <20180513205726.5029c88a@alans-desktop> In-Reply-To: References: Organization: Intel Corporation X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 3 May 2018 18:27:14 +0000 (UTC) Grant Edwards wrote: > On 2018-05-03, Muni Sekhar 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 > > 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