diff options
author | Pascal Obry <obry@adacore.com> | 2008-04-08 08:42:41 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2008-04-08 08:42:41 +0200 |
commit | 42c3898c1d9a5351eaac6ffd792a5d1aaa268435 (patch) | |
tree | 846458809f617b6811dda5e74ec15d1be5265eef /gcc/ada/g-sercom-linux.adb | |
parent | e68c63e3800a7ff463fc0c41cd769569793fb53b (diff) | |
download | gcc-42c3898c1d9a5351eaac6ffd792a5d1aaa268435.zip gcc-42c3898c1d9a5351eaac6ffd792a5d1aaa268435.tar.gz gcc-42c3898c1d9a5351eaac6ffd792a5d1aaa268435.tar.bz2 |
g-sercom.ads, [...] (Data_Rate): Add B115200.
2008-04-08 Pascal Obry <obry@adacore.com>
* g-sercom.ads, g-sercom.adb (Data_Rate): Add B115200.
(Stop_Bits_Number): New type.
(Parity_Check): Likewise.
(Set): Add parameter to set the number of stop bits and
the parity. Parameter timeout is now a duration instead
of a plain integer.
* g-sercom-linux.adb:
Implement the stop bits and parity support for GNU/Linux.
Fix handling of timeout, it must be given in tenth of seconds.
* g-sercom-mingw.adb:
Implement the stop bits and parity support for Windows.
Use new s-win32.ads unit instead of declaring Win32 services
directly into this body.
Update handling of timeout as now a duration.
* s-win32.ads, s-winext.ads: New files.
From-SVN: r134003
Diffstat (limited to 'gcc/ada/g-sercom-linux.adb')
-rw-r--r-- | gcc/ada/g-sercom-linux.adb | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/gcc/ada/g-sercom-linux.adb b/gcc/ada/g-sercom-linux.adb index bcb5952..cf8f805 100644 --- a/gcc/ada/g-sercom-linux.adb +++ b/gcc/ada/g-sercom-linux.adb @@ -43,6 +43,8 @@ with GNAT.OS_Lib; use GNAT.OS_Lib; package body GNAT.Serial_Communications is + use type Interfaces.C.unsigned; + type Port_Data is new int; subtype unsigned is Interfaces.C.unsigned; @@ -63,6 +65,8 @@ package body GNAT.Serial_Communications is CREAD : constant := 8#0200#; CSTOPB : constant := 8#0100#; CRTSCTS : constant := 8#020000000000#; + PARENB : constant := 8#00400#; + PARODD : constant := 8#01000#; -- c_cc indexes @@ -70,16 +74,23 @@ package body GNAT.Serial_Communications is VMIN : constant := 6; C_Data_Rate : constant array (Data_Rate) of unsigned := - (B1200 => 8#000011#, - B2400 => 8#000013#, - B4800 => 8#000014#, - B9600 => 8#000015#, - B19200 => 8#000016#, - B38400 => 8#000017#, - B57600 => 8#010001#); + (B1200 => 8#000011#, + B2400 => 8#000013#, + B4800 => 8#000014#, + B9600 => 8#000015#, + B19200 => 8#000016#, + B38400 => 8#000017#, + B57600 => 8#010001#, + B115200 => 8#010002#); + + C_Bits : constant array (Data_Bits) of unsigned := + (B7 => 8#040#, B8 => 8#060#); - C_Bits : constant array (Data_Bits) of unsigned := - (B7 => 8#040#, B8 => 8#060#); + C_Stop_Bits : constant array (Stop_Bits_Number) of unsigned := + (One => 0, Two => CSTOPB); + + C_Parity : constant array (Parity_Check) of unsigned := + (None => 0, Odd => PARENB or PARODD, Even => PARENB); procedure Raise_Error (Message : String; Error : Integer := Errno); pragma No_Return (Raise_Error); @@ -168,14 +179,14 @@ package body GNAT.Serial_Communications is --------- procedure Set - (Port : Serial_Port; - Rate : Data_Rate := B9600; - Bits : Data_Bits := B8; - Block : Boolean := True; - Timeout : Integer := 10) + (Port : Serial_Port; + Rate : Data_Rate := B9600; + Bits : Data_Bits := B8; + Stop_Bits : Stop_Bits_Number := One; + Parity : Parity_Check := None; + Block : Boolean := True; + Timeout : Duration := 10.0) is - use type unsigned; - type termios is record c_iflag : unsigned; c_oflag : unsigned; @@ -214,9 +225,10 @@ package body GNAT.Serial_Communications is Current.c_cflag := C_Data_Rate (Rate) or C_Bits (Bits) + or C_Stop_Bits (Stop_Bits) + or C_Parity (Parity) or CLOCAL or CREAD - or CSTOPB or CRTSCTS; Current.c_lflag := 0; Current.c_iflag := 0; @@ -224,7 +236,7 @@ package body GNAT.Serial_Communications is Current.c_ispeed := Data_Rate_Value (Rate); Current.c_ospeed := Data_Rate_Value (Rate); Current.c_cc (VMIN) := char'Val (0); - Current.c_cc (VTIME) := char'Val (Timeout); + Current.c_cc (VTIME) := char'Val (Natural (Timeout * 10)); -- Set port settings |