<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -33,7 +33,7 @@ is right out for now. Watch this space for further developments!
 == USAGE
 
 The following code will read a 10-character string from the specified port,
-using the default port settings (9600/8/n/1)
+using the default port settings (9600/8/n/1/no flow control)
 
       @port = RB232::Port.new('/dev/ttyUSB0')
       message = @port.read_string(10)
@@ -43,7 +43,8 @@ You can provide alternative settings when you create a new port:
       RB232::Port.new('/dev/ttyS0', :baud_rate =&gt; 19200, 
                                     :data_bits =&gt; 7, 
                                     :parity =&gt; true, 
-                                    :stop_bits =&gt; 2)
+                                    :stop_bits =&gt; 2,
+                                    :hardware_flow_control =&gt; true)
 
 See http://github.com/Floppy/rb232/tree/master/spec/port_spec.rb or RB232::Port
 documentation for more details.</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -71,11 +71,15 @@ describe RB232::Port do
       @port.stop_bits.should be(1)
     end
 
+    it &quot;should have no flow control&quot; do
+      @port.hardware_flow_control.should be_false
+    end
+
   end
 
   describe &quot;created with non-default options&quot; do
     before :each do
-      @port = RB232::Port.new(TEST_PORT, :baud_rate =&gt; 19200, :data_bits =&gt; 7, :parity =&gt; true, :stop_bits =&gt; 2)
+      @port = RB232::Port.new(TEST_PORT, :baud_rate =&gt; 19200, :data_bits =&gt; 7, :parity =&gt; true, :stop_bits =&gt; 2, :hardware_flow_control =&gt; true)
     end
 
     it &quot;should have a baud rate of 19200&quot; do
@@ -94,6 +98,10 @@ describe RB232::Port do
       @port.stop_bits.should be(2)
     end
 
+    it &quot;should have flow control&quot; do
+      @port.hardware_flow_control.should be_true
+    end
+
   end
 
   describe &quot;created with faulty options&quot; do</diff>
      <filename>spec/port_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,7 @@ struct RB232_Port_Data {
     int data_bits;
     BOOL parity;
     int stop_bits;
+    BOOL hardware_flow_control;
     /* Internals */
     int port_handle;
     struct termios settings;
@@ -69,6 +70,7 @@ VALUE rb232_port_initialize_with_options(VALUE self, VALUE port, VALUE options)
     port_data-&gt;data_bits = rbx_int_from_hash_or_default(options, ID2SYM(rb_intern(&quot;data_bits&quot;)), 8);
     port_data-&gt;parity = rbx_bool_from_hash_or_default(options, ID2SYM(rb_intern(&quot;parity&quot;)), FALSE);
     port_data-&gt;stop_bits = rbx_int_from_hash_or_default(options, ID2SYM(rb_intern(&quot;stop_bits&quot;)), 1);
+    port_data-&gt;hardware_flow_control = rbx_bool_from_hash_or_default(options, ID2SYM(rb_intern(&quot;hardware_flow_control&quot;)), FALSE);
     /* Open the serial port */
     port_data-&gt;port_handle = open(port_data-&gt;port_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
     if (port_data-&gt;port_handle &lt; 0) {
@@ -161,6 +163,8 @@ VALUE rb232_port_initialize_with_options(VALUE self, VALUE port, VALUE options)
         default:
             rb_raise(rb_eArgError, &quot;stop_bits must be 1 or 2&quot;);
     }
+    /* Flow control */
+    if (port_data-&gt;hardware_flow_control) port_data-&gt;settings.c_cflag |= CNEW_RTSCTS;
     /* Other settings */
     port_data-&gt;settings.c_iflag = IGNPAR | ICRNL;
     port_data-&gt;settings.c_oflag = 0;
@@ -230,7 +234,7 @@ VALUE rb232_port_get_data_bits(VALUE self) {
  * Get the parity setting, as set in the _options_ argument to Port#new.
  */
 VALUE rb232_port_get_parity(VALUE self) {
-    /* Return baud rate */
+    /* Return parity setting */
     if (get_port_data(self)-&gt;parity == TRUE)
         return Qtrue;
     else
@@ -245,6 +249,17 @@ VALUE rb232_port_get_stop_bits(VALUE self) {
     return rb_uint_new(get_port_data(self)-&gt;stop_bits);
 }
 
+/*
+ * Get the hardware flow control setting, as set in the _options_ argument to Port#new.
+ */
+VALUE rb232_port_get_hardware_flow_control(VALUE self) {
+    /* Return flow control setting */
+    if (get_port_data(self)-&gt;hardware_flow_control == TRUE)
+        return Qtrue;
+    else
+        return Qfalse;
+}
+
 /* 
  * Read raw data from port
  */</diff>
      <filename>src/port.c</filename>
    </modified>
    <modified>
      <diff>@@ -47,6 +47,11 @@ VALUE rb232_port_get_parity(VALUE self);
 VALUE rb232_port_get_stop_bits(VALUE self);
 
 /*
+ * Get the hardware flow control setting, as set in the _options_ argument to Port#new.
+ */
+VALUE rb232_port_get_hardware_flow_control(VALUE self);
+
+/*
  * Read _count_ raw byte values from the port.
  * Returns an array of values. Useful for binary protocols.
  * call-seq:</diff>
      <filename>src/port.h</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,7 @@ void Init_rb232() {
     rb_define_method(RB232_Port, &quot;data_bits&quot;, rb232_port_get_data_bits, 0); /* in port.c */
     rb_define_method(RB232_Port, &quot;parity&quot;, rb232_port_get_parity, 0); /* in port.c */
     rb_define_method(RB232_Port, &quot;stop_bits&quot;, rb232_port_get_stop_bits, 0); /* in port.c */
+    rb_define_method(RB232_Port, &quot;hardware_flow_control&quot;, rb232_port_get_hardware_flow_control, 0); /* in port.c */
     rb_define_method(RB232_Port, &quot;read_bytes&quot;, rb232_port_read_bytes, 1); /* in port.c */
     rb_define_method(RB232_Port, &quot;read_string&quot;, rb232_port_read_string, 1); /* in port.c */
 }</diff>
      <filename>src/rb232.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a91493a83329309e556243cc7a2e60a7063f4bad</id>
    </parent>
  </parents>
  <author>
    <name>James Smith</name>
    <email>james@floppy.org.uk</email>
  </author>
  <url>http://github.com/Floppy/rb232/commit/1becc4efc535897078b24d16bc1b0d21c7eb80f8</url>
  <id>1becc4efc535897078b24d16bc1b0d21c7eb80f8</id>
  <committed-date>2009-10-29T15:31:13-07:00</committed-date>
  <authored-date>2009-10-29T15:31:13-07:00</authored-date>
  <message>Add support for hardware flow control flag</message>
  <tree>042637d127719501d381b3aabeaaf7d0fc0d00ed</tree>
  <committer>
    <name>James Smith</name>
    <email>james@floppy.org.uk</email>
  </committer>
</commit>
