From 42c3898c1d9a5351eaac6ffd792a5d1aaa268435 Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Tue, 8 Apr 2008 08:42:41 +0200 Subject: g-sercom.ads, [...] (Data_Rate): Add B115200. 2008-04-08 Pascal Obry * 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 --- gcc/ada/g-sercom.ads | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'gcc/ada/g-sercom.ads') diff --git a/gcc/ada/g-sercom.ads b/gcc/ada/g-sercom.ads index bbd8f91e331..3d327cec76f 100644 --- a/gcc/ada/g-sercom.ads +++ b/gcc/ada/g-sercom.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2007, AdaCore -- +-- Copyright (C) 2007-2008, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -47,12 +47,19 @@ package GNAT.Serial_Communications is function Name (Number : Positive) return Port_Name; -- Returns the port name for the given port number - type Data_Rate is (B1200, B2400, B4800, B9600, B19200, B38400, B57600); + type Data_Rate is + (B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200); -- Speed of the communication type Data_Bits is (B8, B7); -- Communication bits + type Stop_Bits_Number is (One, Two); + -- One or two stop bits + + type Parity_Check is (None, Even, Odd); + -- Either no parity check or an even or odd parity + type Serial_Port is new Ada.Streams.Root_Stream_Type with private; procedure Open @@ -62,14 +69,18 @@ package GNAT.Serial_Communications is -- opened. 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); -- The communication port settings. If Block is set then a read call -- will wait for the whole buffer to be filed. If Block is not set then - -- the given Timeout (in seconds) is used. + -- the given Timeout (in seconds) is used. Note that the timeout precision + -- may be limited on some implementation (e.g. on GNU/Linux the maximum + -- precision is a tenth of seconds). overriding procedure Read (Port : in out Serial_Port; @@ -96,14 +107,13 @@ private end record; Data_Rate_Value : constant array (Data_Rate) of Interfaces.C.unsigned := - (B1200 => 1_200, - B2400 => 2_400, - B4800 => 4_800, - B9600 => 9_600, - B19200 => 19_200, - B38400 => 38_400, - B57600 => 57_600); - - Bit_Value : constant array (Data_Bits) of Interfaces.C.unsigned := (8, 7); + (B1200 => 1_200, + B2400 => 2_400, + B4800 => 4_800, + B9600 => 9_600, + B19200 => 19_200, + B38400 => 38_400, + B57600 => 57_600, + B115200 => 115_200); end GNAT.Serial_Communications; -- cgit v1.2.1