[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Patches for making g-sercom work without rs232 flow control



The version of package GNAT.Serial_Communications shipped with GNAT does not support serial port communications without flow control.

The enclosed patches changes this without affecting applications using the "standard" version of package GNAT.Serial_Communications.

/Jacob
--
Jacob Sparre Andersen Research & Innovation
Vesterbrogade 148K, 1. th.
1620 København V
Danmark

Phone:    +45 21 49 08 04
E-mail:   jacob@jacob-sparre.dk
Web-site: http://www.jacob-sparre.dk/
--- g-sercom.ads	2010-01-25 17:24:20.000000000 +0100
+++ gnat-4.6/g-sercom.ads	2011-11-17 15:45:06.000000000 +0100
@@ -64,6 +64,8 @@
    type Parity_Check is (None, Even, Odd);
    --  Either no parity check or an even or odd parity
 
+   type Flow_Control is (None, Active);
+
    type Serial_Port is new Ada.Streams.Root_Stream_Type with private;
 
    procedure Open
@@ -79,7 +81,8 @@
       Stop_Bits : Stop_Bits_Number := One;
       Parity    : Parity_Check     := None;
       Block     : Boolean          := True;
-      Timeout   : Duration         := 10.0);
+      Timeout   : Duration         := 10.0;
+      Flow      : Flow_Control     := Active);
    --  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. Note that the timeout precision
--- g-sercom.adb	2010-06-17 14:26:10.000000000 +0200
+++ gnat-4.6/g-sercom.adb	2011-11-17 15:45:06.000000000 +0100
@@ -179,6 +179,9 @@
    -- Set --
    ---------
 
+   C_Flow_Control : constant array (Flow_Control) of unsigned :=
+                      (None => 0, Active => CRTSCTS);
+
    procedure Set
      (Port      : Serial_Port;
       Rate      : Data_Rate        := B9600;
@@ -186,7 +189,8 @@
       Stop_Bits : Stop_Bits_Number := One;
       Parity    : Parity_Check     := None;
       Block     : Boolean          := True;
-      Timeout   : Duration         := 10.0)
+      Timeout   : Duration         := 10.0;
+      Flow      : Flow_Control     := Active)
    is
       type termios is record
          c_iflag  : unsigned;
@@ -233,7 +237,7 @@
                                 or C_Parity (Parity)
                                 or CLOCAL
                                 or CREAD
-                                or CRTSCTS;
+                                or C_Flow_Control (Flow);
       Current.c_lflag      := 0;
       Current.c_iflag      := 0;
       Current.c_oflag      := 0;

Reply to: