From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Pascal Obry <obry@adacore.com>
Subject: [Ada] Fix serial port control setting on GNU/Linux
Date: Mon, 30 Nov 2020 09:17:11 -0500 [thread overview]
Message-ID: <20201130141711.GA117766@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 546 bytes --]
This fixes an issue when setting the control flags of the serial
communication port. The c_cflag termios field should not be set with the
baud rate. The speed of the communication is set using the c_ispeed and
c_ospeed fields. Setting the baud rate into the c_cflag has unexpected
results as it will wrongly set some bits used to control other aspects
of the communication channel (bits, parity...).
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* libgnat/g-sercom__linux.adb (Set): Fix control flags of the
serial port setting.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2068 bytes --]
diff --git a/gcc/ada/libgnat/g-sercom__linux.adb b/gcc/ada/libgnat/g-sercom__linux.adb
--- a/gcc/ada/libgnat/g-sercom__linux.adb
+++ b/gcc/ada/libgnat/g-sercom__linux.adb
@@ -52,34 +52,6 @@ package body GNAT.Serial_Communications is
function fcntl (fd : int; cmd : int; value : int) return int;
pragma Import (C, fcntl, "fcntl");
- C_Data_Rate : constant array (Data_Rate) of unsigned :=
- (B75 => OSC.B75,
- B110 => OSC.B110,
- B150 => OSC.B150,
- B300 => OSC.B300,
- B600 => OSC.B600,
- B1200 => OSC.B1200,
- B2400 => OSC.B2400,
- B4800 => OSC.B4800,
- B9600 => OSC.B9600,
- B19200 => OSC.B19200,
- B38400 => OSC.B38400,
- B57600 => OSC.B57600,
- B115200 => OSC.B115200,
- B230400 => OSC.B230400,
- B460800 => OSC.B460800,
- B500000 => OSC.B500000,
- B576000 => OSC.B576000,
- B921600 => OSC.B921600,
- B1000000 => OSC.B1000000,
- B1152000 => OSC.B1152000,
- B1500000 => OSC.B1500000,
- B2000000 => OSC.B2000000,
- B2500000 => OSC.B2500000,
- B3000000 => OSC.B3000000,
- B3500000 => OSC.B3500000,
- B4000000 => OSC.B4000000);
-
C_Bits : constant array (Data_Bits) of unsigned :=
(CS7 => OSC.CS7, CS8 => OSC.CS8);
@@ -229,8 +201,7 @@ package body GNAT.Serial_Communications is
-- Change settings now
- Current.c_cflag := C_Data_Rate (Rate)
- or C_Bits (Bits)
+ Current.c_cflag := C_Bits (Bits)
or C_Stop_Bits (Stop_Bits)
or C_Parity (Parity)
or CREAD;
reply other threads:[~2020-11-30 14:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201130141711.GA117766@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=obry@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).