[C3SL-git] Framework 2.0 branch, master, updated. libfsobasics-0.9.0-1859-g0e387c1

smartphones-commits at linuxtogo.org smartphones-commits at linuxtogo.org
Sat Jul 9 20:45:24 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Framework 2.0".

The branch, master has been updated
       via  0e387c1dd10192eb4d731fa1cec002c2c3dd8b8d (commit)
      from  d3796f2b2ff54139677a7746a5ac39bd433e6c85 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0e387c1dd10192eb4d731fa1cec002c2c3dd8b8d
Author: Simon Busch <morphis at gravedo.de>
Date:   Sat Jul 9 20:43:12 2011 +0200

    libfsotransport: hsuart: implement suspend/resume methods
    
    When suspending the device we need to disable the flow control of the hsuart and drain all
    remaining bytes from the buffer. On resume we need to enable flow control again.

-----------------------------------------------------------------------

Summary of changes:
 libfsotransport/fsotransport/hsuart.vala |   67 +++++++++++++++++++++++++++++-
 libfsotransport/vapi/hsuart.vapi         |   12 +++---
 2 files changed, 72 insertions(+), 7 deletions(-)


Changes between commits d3796f..0e387c
diff --git a/libfsotransport/fsotransport/hsuart.vala b/libfsotransport/fsotransport/hsuart.vala
index c4d1c49..e5e9746 100644
--- a/libfsotransport/fsotransport/hsuart.vala
+++ b/libfsotransport/fsotransport/hsuart.vala
@@ -48,6 +48,9 @@ public class FsoFramework.HsuartTransport : FsoFramework.BaseTransport
         return "<Hsuart %s@%u (fd %d)>".printf( name, speed, fd );
     }
 
+    /**
+     * Configure the high speed to be ready for sending and receiving bytes.
+     **/
     protected override void configure()
     {
         // Flush everything
@@ -70,7 +73,69 @@ public class FsoFramework.HsuartTransport : FsoFramework.BaseTransport
         // We want flow control for the rx line
         Linux.ioctl(fd, Hsuart.IoctlType.RX_FLOW, Hsuart.RxFlowControlType.ON);
     }
+
+    /**
+     * This will suspend the transport. After it is suspend we can't send any more bytes
+     * to the remote side.
+     **/
+    public bool suspend()
+    {
+        int rc = 0;
+
+        // We need to deactivate flow control so we don't get interrupted during the
+        // suspend by the other side.
+        rc = Posix.ioctl(fd, Hsuart.IoctlType.RX_FLOW, Hsuart.RxFlowControlType.OFF);
+        if (rc < 0)
+        {
+            logger.error(@"Could not deactivate flow control for the transport!");
+            return false;
+        }
+
+        // Check wether we have any bytes left to receive.
+        rc = Posix.ioctl(fd, Hsuart.IoctlType.RX_BYTES, 0);
+        if (rc > 0)
+        {
+            logger.error(@"Could not suspend the transport as we have bytes left to send.");
+            return false;
+        }
+
+        // Drain all left bytes for transmission to the remote side. NOTE this will block
+        // until all bytes are send or it timed out (2000ms).
+        rc = Posix.ioctl(fd, Hsuart.IoctlType.TX_DRAIN, 2000);
+        if (rc < 0)
+        {
+            logger.error(@"Could not drain the last bytes from hsuart buffer!");
+
+            // Try again as non-blocking call; this will give us only the status of
+            // transmission buffer and will not drain the bytes from the buffer.
+            rc = Posix.ioctl(fd, Hsuart.IoctlType.TX_DRAIN, 0);
+            logger.error(@"Status of tx is $(rc)");
+
+            return false;
+        }
+
+        logger.debug(@"Successfully suspended the transport!");
+
+        return true;
+    }
+
+    /**
+     * Resume the transport so we can send and receive our bytes again.
+     **/
+    public void resume()
+    {
+        int rc = 0;
+
+        // Enable rx flow control again
+        rc = Posix.ioctl(fd, Hsuart.IoctlType.RX_FLOW, Hsuart.RxFlowControlType.ON);
+        if (rc < 0)
+        {
+            logger.error(@"Could not enable rx flow control!");
+            return;
+        }
+
+        logger.debug(@"Successfully enabled rx flow control!");
+    }
 }
 
 // vim:ts=4:sw=4:expandtab
-
diff --git a/libfsotransport/vapi/hsuart.vapi b/libfsotransport/vapi/hsuart.vapi
index eee35a5..e0e9f25 100644
--- a/libfsotransport/vapi/hsuart.vapi
+++ b/libfsotransport/vapi/hsuart.vapi
@@ -42,7 +42,7 @@ namespace PalmPre.Hsuart
         PARITY_ODD,
         PARITY_EVEN,
     }
-    
+
     /*
      * Specifies target HSUART_IOCTL_CLEAR_FIFO/HSUART_IOCTL_FLUSH
      */
@@ -55,11 +55,11 @@ namespace PalmPre.Hsuart
         RX_QUEUE,
         TX_QUEUE,
     }
-    
+
     /*
      *  Rx flow control
      */
-     
+
     [CCode (cname = "int", has_type_id = false, cprefix = "HSUART_RX_FLOW_", cheader_filename = "hsuart.h")]
     public enum RxFlowControlType
     {
@@ -67,7 +67,7 @@ namespace PalmPre.Hsuart
         AUTO,
         ON,
     }
-    
+
     [CCode (cname = "int", has_type_id = false, cprefix = "HSUART_IOCTL_", cheader_filename = "hsuart.h")]
     public enum IoctlType
     {
@@ -84,14 +84,14 @@ namespace PalmPre.Hsuart
         RX_FLOW,
         FLUSH,
     }
-    
+
     [CCode (cname = "struct hsuart_mode", cheader_filename = "hsuart.h")]
     public struct Mode
     {
         public int speed;
         public int flags;
     }
-    
+
     [CCode (cname = "struct hsuart_stat", cheader_filename = "hsuart.h")]
     public struct Stat
     {


hooks/post-receive
--
Framework 2.0



More information about the smartphones-commits mailing list